Final Project: Spider Robot


Hello everyone,

For my final project, I decided I wanted to make a spider robot that would walk using four legs. I wanted to incorporate a raspberry pi and allow Bluetooth connectivity since I have never used either of those before, and I wanted to learn how to use them. In order to complete this project I needed to do the following things:

  • Learn how to use the raspberry pi and program it using python in order to control the four legs of the robot
  • Learn how to utilize the Bluetooth functionality of the raspberry pi in order to give the robot commands from my phone
  • Cut the pieces of the robot using the laser cutter

My first step to the project was to create the CAD drawings that I would cut using the laser cutter.

CAD Drawing created using Fusion 360

I ended up having two servos for each of the legs. The first servo would allow each leg to move in an arc in the xy plane. The second servo would be used to rotate about the z axis. This would allow the robot to pick up its leg and then move to a different position. Once the leg is in a specific position, friction would then allow the robot to move forward. Luckily, I was able to find a bunch of different models for the individual servos, the raspberry pi, and the servo control board. This allowed me to easily model everything together resulting in each of the pieces fitting together. The main issue I had with assembly was actually the servos themselves. The hardware screws didn’t really work out when attaching the wooden legs to the servos, so I had to add some super glue in order to get it to stay on. The servos also still had some give to them though.

This is what the current robot looks like:

I was pretty happy with how the body turned out and how the raspberry pi and the control board fit. The screws I used were very good at holding in place.

The coding portion was actually pretty straightforward. I had to install some python packages onto the raspberry pi then I was able to get right into coding which was nice. Python was easier than I expected since I was able to import packages then use them pretty easily. It was pretty similar to coding on the Arduino just with a different language and access to more packages.

I ended up coding different functions for each walking process. So I had a function for moving forward, a function for moving right, etc.

For the Bluetooth, I ended up using the pybluez package that would allow me to start a bluetooth client and connect with my phone. I downloaded an app called bluetooth serial controller that allowed me to send data to the raspberry pi. In the program, depending on the data sent, that would determine what moving function to use.

The following is the code I ended up writing:

In the end, two of the servos ended up dying me once I finished the build, so I wasn’t able to get it to implement and test all of the movement functions that I wrote, but I was able to get it to scoot forward. This was a little disappointing and in hindsight I should have used more robust servos. I believe the servos would have been strong enough to life the robot, but they had a ton of give to them and I would have rather had it where I would screw the wooden parts into the servos. I was able to get the bluetooth working and I was happy with what I was able to do with the raspberry pi. It allowed me to learn more about something I have always been curious about.

Overall,  I really enjoyed this course. I always enjoyed tinkering with things, so being able to do that in a class was fun.