During March I spent most of my time programming the LIDAR which directs my robot’s movement.
I ran into some troubles with finding a module that could communicate with the LIDAR. I needed to read commands from the LIDAR, then go do another task and then come back into the LIDAR module to give it the correct start bytes so that I could gather another set of data points. I needed to be able to remain connected with the LIDAR. I ended up trying three different modules and finally found one that allowed me to run it once, exit the function, run other code and then re-enter the LIDAR statement without running into connectivity problems. I could not just gather data all the time. I have to gather a certain set of data points, do calculations with them, decide what to do with robot movement and then start over gathering more data points. After I gathered the data points I needed to establish at what angle and distance objects were from the LIDAR mounted on the robot. It was challenging to convince the Python code to make arrays instead of lists. If the data was in a list form it was non-iterable and therefore a “for” statement could not be used to run through all of the data points quickly to divide them into their appropriate categories. I spent a lot of time trying to get the Python code to append the correct data points into the correct format in an array. I wanted the data points in a numpy array. Numpy arrays allow more mathematical calculations and resizing to be done than just a regular Python array or list. This took a lot of iterations to successfully store the data, retrieve and work with it, and get it into a format that I could use successfully and quickly. Getting the Raspberry Pi 4 to connect to the Arduino was quite easy. All that was required was a USB cable and a module that allowed the Pi to read the serial print screen of the Arduino. After completing both of these tasks I was able to do some math that allowed the LIDAR to be able to do basic scanning to move. There are still a lot of problems with turning. I am having a problem trying to get it to turn while trying to read the sensors. This is because it is in two different def statements and they can’t be run at the same time due to the fact that there are timing issues with the LIDAR. This is causing me to go through a lot of iterations to try to get something that will allow the robot to turn when the LIDAR senses something in front of it. It just occurred to me that I have not explained what all the pieces do. The LIDAR hardware, using a laser, determines what is around my robot and where by triangulating the position. The Raspberry Pi 4 does all of the mathematical calculations to establish where things are and then tells the Arduino where to move the robot. The Arduino controls the H-Bridge, using the data from the Raspberry Pi 4. It gets the H-Bridge to turn the motors depending upon where the Raspberry Pi 4 wants the Arduino to direct the robot. The DC to DC converter steps the voltage from the 12V battery down to what the Raspberry Pi 4 and Arduino needs so they don’t blow up. The motors to turn the two wheels need the 12V straight up. I currently can move the robot around, sort of, but I need to fine tune it a lot to get it to perform the way I would like. This is going to require a lot of programming to get it to function in the manner that I had envisioned. I have also noticed that some of the connections are faulty. I need to take apart the robot and redo some of the wiring. Of note, I have successfully run my mother over with the robot. No one was injured.
0 Comments
|
AuthorWrite something about yourself. No need to be fancy, just an overview. Archives
April 2021
Categories |