Introduction: The Social Quadruped
This instructable was created in fulfillment of the project requirement of the Makecourse at the University of South Florida (www.makecourse.com).
In this Instructable I will demonstrate how to build the Social Quadruped from start to finish, and control it wirelessly using a Bluetooth enabled device.
The Social Quadruped is a 4-legged walker with 2 Degrees of Freedom, that walks using a crawling motion and is controlled wirelessly using a Bluetooth enabled device.
Step 1: 3D Printed Parts
Before you start to assemble the robot, you will need to print out the 3D printed parts that make up its body. I have provided .stl as well as .ipt files of the various parts, so that you can modify them as you wish. Some of the parts require some sanding to fit, so if you want to avoid that you can always make them smaller or the parts they fit into larger.
You will need to print:
3 Front and Back Base Joints
1 Front Face
4 Leg Joints
4 Lower Brackets
1 Rear Face
4 Side Base Joints
2 Side Faces
4 Upper Brackets
Step 2: Parts and Supplies
Below I give a list of supplies you will need to purchase in order to get the Social Quadruped functional, I will also list the approximate price without shipping, the quantity and provide a link to sites where you can purchase them from.
3D Printed Parts
~ 40 - 60$
Bluetooth Enabled Computer
Approximate Total Cost of Supplies: 197$ - 217$
Step 3: Assembly
In this step, I will demonstrate how to assemble the body of the robot. I will start with the assembly of the leg.
First take the joint and attach it to the upper servo bracket.
After you have successfully done this, take one servo and fit it in the joint, with the output spline closer to the bracket, and the spline pointing to your left.
Remember to center the servo by having the servo horn pointing down the servo when it is at 90 degrees. This will ensure you get the desired results when you run the sketch.
Next, take the lower servo bracket and align the servo spline with the hole on the bracket and fit it through it. All you have to do now is attach a servo horn to the spline and screw it in.
Moving on to the base, take the base of the robot and fit four servos into the four servo slots on the base, with the part of the servo that has the output spline closer to the center of the base. Attach the upper servo bracket to one of the servos on the base, with the output spline of the servo on the base pointing upward, attach a servo horn to the base and you will have successfully assembled one leg. Repeat this process for the next three legs.
Next attach the lower side joints to the sides of the robot, and the lower front and back joints to the front and back of the robot respectively.
Fit the ultrasonic sensor to the front face of the robot in the slot designated for it, and fit this face in the front joint. You can now fit the side and back faces to their respective joints.
Finally, attach the cover to the upper side, and back joints and fit them to the side and back faces, and you are done with the assembly.
Step 4: Wiring
First, stack the Arduino Sensor Shield on top of your Arduino.
Then, connect the 8 servos to any of the respective servo pins on the shield. Just remember to take note of the pins you use because you will need to define them in the Arduino sketch.
Next, connect the ultrasonic sensor to the respective ultrasonic sensor pins on the shield.
Once done, connect your Bluetooth Module to the COM port on the shield, with the RX pin of the module connected to the TX pin on the shield, and the TX pin on the module connected to the RX pin on the shield.
You can now connect the 4 AA batteries in the battery pack to the vcc and ground rails on the shield. The 4 AA Batteries will be used to power the servos separately from the Arduino to prevent any damage to the Arduino in case they draw too much current.
Finally connect the 9 Volt battery to the power slot on the Arduino.
Step 5: Walking Motions
Before I discuss the Arduino sketch, I would like to give a brief overview behind the walking motions I decided to use for the robot.
To move forward, the robot first moves its front right leg forward, and at the same time pushes the front left leg backwards. This shifts the right side of the robot forward. Next, the robot moves its rear left leg forward, while at the same time moving its rear right leg backward. This motion pushes the left side of the robot forward. Now, the robot moves its front left leg forward while moving its front right leg backward pushing the left side of its body even farther forward. This motion is what is key to getting the robot moving forward. Finally, the robot moves its rear left leg forward, and rear right body backward causing the robot to level out. Once you understand how the robot moves forward, the rest of the movements are simple to implement. Click on the gif image for a simple visual representation of the robot moving forward.
To move backward, the robot simply reverses the motions used to move forward.
To rotate right, the robot moves the front right leg forward, and then its rear right leg forward. It then moves its front right leg backward while keeping the rear left leg stationary. Next, it moves the front left leg forward and finally, it moves its rear right leg back, while moving its front left leg forward.
To rotate left, the robot moves its front left leg forward, and then its rear left leg forward. It then moves its front left leg backward while keeping the rear right leg stationary. Next, it moves its front right leg forward, and finally it moves its rear left leg backward, while moving its front right leg backward.
Step 6: Code
The code is split into two tabs, the first being The_Social_Quadruped.ino and the second is Quad_Functions.ino. I have attached both of these.
The first tab includes the Servo.h library which comes with the Arduino IDE as well as the NewPing.h library, which can be downloaded here. I first define the trigger pin, echo pin and max distance for the Ultrasonic Sensor after which I define a boolean variable that will be used to toggle the autonomy mode of the robot. I then define the servos. In the setup function, I attach the servos to their respective positions on the Arduino Sensor Shield, and initialize the Serial monitor to enable me to send commands to the Arduino. In the loop function, I set the Ultrasonic Sensor to send the distance of the nearest object to the serial monitor, and check for user input. If the user inputs the character f, b, r, l, w, s, u or a, the functions forward, back, right, left, wave, sleep, stand, or autonomy which are defined in the Quad_Functions.ino tab are called respectively. When the user presses a, however, the autonomy function will continue to loop until the user presses a again.
The second tab contains the definitions for all the functions. The respective step functions define one step for each type of movement, the stand function sets the servos in a position that causes the robot to stand up, the forward and back functions cause the robot to move forward and back respectively, the right and left functions cause the robot to rotate to the right and left respectively, the wave2 and wave functions cause the robot to wave using its left and right front legs respectively, the waveAuto function causes the robot to wave using its front right leg while it is in autonomous mode, the sleep function sets the servos in a position that causes the robot to lie flat on the ground, and finally the readPing function gets the readings from the Ultrasonic Sensor and converts them to centimeters.
Note: Ensure the servo pins you define match up with the pins you connected them to on the Arduino shield. Also, be sure to disconnect the Bluetooth module when uploading the sketch to the Arduino, as it sometimes interferes with the upload process.
Step 7: Wireless Control
First, ensure the Bluetooth module is properly connected as described in the Wiring step.
Next, enable Bluetooth on your computer and pair with the HC-06 module. You will be prompted for a passcode which for most HC-06 modules is usually 1234. Once you are paired, go to Control Panel and enter Bluetooth in the search box. Click on view devices and you should see the HC-06 module. Right click it and select Properties, then select the Services tab. The port it is using for Serial communication should be listed.
Now go to the Arduino IDE, and click on Tools -> Port and set the port to what was listed under the Services tab. You are now good to go.
Open the serial monitor, and you should be able to see the distance readings from the Ultrasonic Sensor as well as control the robot as you would when you were connected to it via USB.