Inspiration for the project:
Bubba is a project I embarked on to combine my love for mechantronics, motion planning algorithms and robotics (and Forrest Gump, hence the name!). During the COVID-19 lock down, I got interested in biologically-inspired robots and their unique motion style. Taking ENGI 301 this semester at Rice University and learning about embedded systems gave me the confidence to embark on my journey into building a biologically inspired robot.
Since I am terrified of spiders, I thought it would be a good idea to build a spider robot. I utilized JavierIH's github page for the.STL files required to print the chasis of the robot.
Link to JavierIH's github page (shout out to him for an awesome chasis design)
https://github.com/JavierIH/miniKame
To learn more about 3D printing, I signed up for the OEDK's 3D printing Fabshop class. I learnt to modify and design my own .STL file. This allowed me to amend some of the designs off Javier's Github such that they fit on my project. Using my personal Printrbot Simple Metal 3D printer, I printed the chasis of Bubba using PLA. This task was painstaking and took over a week since each of the components had to be printed individually and had to be carefully filed such that they connected smoothly. Some of my prints failed and I had to start over. Each of the legs took on average 4-7 hours to print.
I then researched online for versatile servo motors that could be used in such an application and decided that the SG-90 Servo motor was both a cost-effective and appropriate solution. The servo motors use a PWM based signal and for more information about how PWM's work, please checkout the following link I found to be very useful:
https://www.jameco.com/Jameco/workshop/Howitworks/how-servo-motors-work.html
After getting the chasis printed, I mounted the 8 servo motors into Bubba and wired them together. Here is a picture of Bubba's chasis put together with the motor wiring:
I then decided to make things more interesting and install an HC-SR04 ultrasonic sensor to give Bubba the ability to "see". I wanted him to be able to dynamically respond to obstacles in its environment. If he detects an obstacle in his environment, I want him to stop his motion so he avoids colliding with obstacles.
Work in progress: The servo motor's integration with the rest of the code base is currently a work in progress. I will update the github with a commit message once I have pushed the code for it! Stay tuned :)
Multi-threading
Bubba's movement relies on multi-threading. The code spawns 4 threads, one for each of its legs. One smart hack which I found after watching youtube videos of spiders moving in slow motions (terrifying!) is that the move their diagonal pairs of legs. I.e Front right and back left legs move together. I mimic'd this movement in code by having them move in the at the same duty cycle and frequency. I made the other 2 legs move at a slightly offset duty cycle such that Bubba made forward progress slowly rather than his legs cancelling out each other's motion.
Versatile Motion Planning Functions:
Douglas Crockford said this famous line:
“Code reuse is the Holy Grail of Software Engineering.”
I firmly believe in modularity, abstraction and the DRY principal (Do not Repeat Yourself) and hence have built motion functions. One difficult aspect of this project was synchronizing the movement of each of the motors. The Adafruit BBIO library provides a nice interface to control the PWM of the servo motors, however, it is insufficient in generating the required movement for Bubba.
To solve this, I developed a high-level abstraction of the movement of each of Bubba's 4 legs. Within each of this function is the low-level PWM control that moves the corresponding leg forward to generate motion. To move the legs, I highly recommend calling this high level abstract function rather than manipulating PWM and duty cycle values because it makes like so much easier!
Bubba has 4 more degrees of freedom present in the mid joint of each leg. These motors control the extension/bend in each leg. Using the functions provided in the code library, makers of this project can implement functions that manipulate these additional 4 motors to provide Bubba with even more refined movements. I was using the PocketBeagle development board for this project and thus was constrained to 4 PWM pins.
Operation Instructions:
1. 3D print the chasis based on JavierIH's github page.
2. Wire up the servo motors based on the Fritzing wiring guide attached in this project.
3. Dependencies - Please install the Adafruit BBIO library found here:
https://learn.adafruit.com/setting-up-io-python-library-on-beaglebone-black/using-the-bbio-library
4. Run Bubba.py on your development board and ensure that the pins have been connected correctly.
NextSteps + Future Developments:
The next steps of this project include the following :-
(I will periodically push changes as and when I complete these objectives and will provide an informative commit message once done!)
1. Add in additional code to make Bubba more responsive to obstacles in its environment and turn away when it detects an obstacle.
2. Stretch goal - I developed an autonomous motion planning algorithm with Dr. Lydia Kavraki at Kavraki Robotics Lab at Rice University. It is called the Rapidly Exploring Random Tree (RRT) algorithm and it helps robots plan motion to move autonomously.
My goal is to convert the output c++ code from this algorithm and map them to motor functions on Bubba. The dream would be to let Bubba roam free on Rice Campus autonomously!
Acknowledgements:
1. JavierIH for his designs on the chasis.
2. Limor Fried (Founder of Adafruit) for building cool sensors and developing libraries for them.
3. Erik Welsh, for his guidance and debugging help and for teaching me all the skills required to realize my craziest ideas!
Comments