Introduction: Arduino Quadruped Robot
Latest Hexapod: https://www.instructables.com/id/Arduino-Mega-Hexa...
This is my first robot that relies on calculations to position the servos vs. relying on pre-programmed sequences. I chose a quadruped to help keep the cost down.
Build Time 8 weeks
Weight 2 Pounds 14 Oz.
Dimensions 8 inches, 8 inches, 7 inches (L:W:H)
Run Time 15-30 minutes
Programing Language Arduino IDE
Control Method Blue-tooth Remote
Cost ~$540.00
Powersource: LiPo
1x 7.4V 1650Mah 2S LipPo
I am powering everything using a 2S LIPO & Turnigy 15A UBEC (Ultimate battery elimination circuit). I love the UBEC and will definitely be the regulator of choice for future robot projects.
Locomotion:
The body's roll, pitch & yaw are calculated using a rotation matrix. That in turn feeds into the Inverse Kinematics equations that position the legs. I am using a ripple gait for walking although I am still fine tuning that portion of the code. A few modes exists, 1: Body Translation/Body Position 2:Walking Mode 3:Accelerometer Mode. The first two modes are pretty self explanatory; accelerometer mode takes the x-axis & y-axis from the accelerometer, maps the values to (-20, 20), then use those values as the body's pitch & roll respectively. This allows the robot to stay level on uneven surfaces.
It has been some time since I have been enrolled in a math class. I also don't believe in re-inviting the wheel; I used the rotation matrix & inverse kinematics from NUKE (Nearly Universal Kinematic Engine). I am not using the micro-controller is was designed for so I could not use their python tools to generate the code I borrowed from. Instead they had an already completed sketch for a quad which is what I modeled my program after. A big thanks to the people that put that tool together, it was true to its name! Also big thanks to "tom_chang79" his discussion, "Let's Discuss Kinematics, Shall We?" was very helpful. Thanks, & thanks for your email responses!
I have built a blue-tooth remote control which has worked great so far. As I continue to progress I intend to build more functionality into my remote and robot. I found some 3-funtion joysticks at servo city that will replace the parallax joysticks I have now.
Here is the link to the ideal joysticks from servocity:
http://www.servocity.com/html/3_function_joystick...
Controller/CPU: Arduino MegaMini 2560, Lynxmotion SSC-32
The Arduino Mega handles all of the computation along with taking input from the accelerometer & blue-tooth. Once all the calculations are complete it sends the appropriate commands to the SSC-32 servo sequencer. I love the SSC-32 it is super great!
Sensors
Triple Axis Accelerometer (ADXL335)
When I started off I thought that I would need a 3-axis gyroscope in addition to the accelerometer. My thought was that I would need to mesh the data together using a Kalman filter. I have worked with IMU's (Inertial measurement unit) in the past and needed to use directional cosine matrix's to mesh the accelerometer, gyroscope and compass readings together. This creates very stable orientation data and outputs a single yaw, pitch & roll that doesn't drift. In the end I was able to get the data I needed from just the accelerometer. This is good thing, I would most likely need another MCU to process all that data.
Actuators
I am using HS-422 servo's; I have been very impressed with all the HITEC Servos. At some point I will replace the HS-422 servos with HS-465MG servos which have more torque and metal gears instead of composite.
Step 1: Acquire Parts
Mechanical Parts:
Robot Body (Qty. 1) Price: $19.95
http://www.robotshop.com/lynxmotion-symmetric-quadrapod-body-kit-mini.html
Aluminum Femur Pair (Qty. 2) Price: $16.95 (each)
http://www.robotshop.com/lynxmotion-3-aluminum-femur-pair-2.html
Tibia Pair (Legs )(Qty. 2) Price: $19.95 (each)
http://www.robotshop.com/lynxmotion-robot-leg-rl-01.html
Arduino Mega Platform(Qty. 1) Price: $8.99
http://www.allerc.com/gaui-330x-payload-mount-set-p-5495.html
Electronics:
HS-422 Servos (Qty. 12) Price: $9.99 (each)
http://www.robotshop.com/productinfo.aspx?pc=RB-Hit-27&lang=en-US
Lynxmotion SSC-32 Servo Controller: (Qty. 1) Price: 39.95
http://www.robotshop.com/productinfo.aspx?pc=RB-Lyn-100&lang=en-US
MegaMini 2560 (Qty. 1) Price: $42.00
https://www.tindie.com/products/jkdevices/megamini-2650-atmega2560-breakout-with-usb/
Triple Axis Accelerometer ADXL245: (Qty. 1) Price: $27.95
https://www.sparkfun.com/products/9836
Parallax Xbee Wireless Pack(Qty. 1) Price: $79.99
http://www.parallax.com/Store/Accessories/CommunicationRF/tabid/161/CategoryID/36/List/0/SortField/0/catpageindex/3/Level/a/ProductID/785/Default.aspx
Battery & Regulator For Robot:
1300mAh 2S 7.4V 20C Li-Po, 13 AWG EC2 (Qty. 1) Price:18.99
http://www.hobbytown.com/Shop/1300mAh-2S-7-4V-20C-Li-Po-13-AWG-EC2/
TURNIGY 8-15A UBEC for Lipoly (Qty. 1) Price: 15.40
http://www.hobbyking.com/hobbyking/store/__6233__turnigy_8_15a_ubec_for_lipoly.html
Remote Control Part List:
Black Plastic Project Box (Qty. 1)
Circuit Board (Qty. 1) Price: $4.49
http://www.radioshack.com/product/index.jsp?productId=2102843
Arduino Nano (Qty. 1) Price: $34.95
http://www.frys.com/product/6745715?site=sr:SEARCH:MAIN_RSLT_PG
Parallax LCD (Qty. 1) Price: $29.99
http://www.parallax.com/StoreSearchResults/tabid/768/txtSearch/lcd/List/0/SortField/4/ProductID/50/Default.aspx
Joysticks (Qty. 2) Price: $3.99
http://www.parallax.com/Store/Accessories/HumanInterfaceDevices/tabid/822/CategoryID/90/List/0/SortField/0/Level/a/ProductID/581/Default.aspx
5 Cell 6V 1600mAh NiMH Battery(Qty. 1) Price:17.49
http://www.hobbytown.com/Shop/5-Cell-6V-1600mAh-NiMH-Flat-Receiver-Battery/
Total Cost For Robot : ~$540
Tools Required:
Phillips Head Screw Driver
Soldering Iron
Solder
Dremel
Hex Screw Drivers
Small Philips & Flat Head Screwdrivers
Pliers
Patience
Step 2: Build Front Left Leg
Note: Pay close attention to the orientation of each part; the left & right legs will look a little different. All of the screws and plastic servo retainers come with the parts and for the most part is pretty self explanatory.
When building the legs I connected all of the servos for one leg into ports 0, 1, 2 on the SSC-32. Afterward I uploaded the following sketch to the arduino to center all of the motors on those ports:
void setup()
{
Serial.begin(115200);
}
void loop()
{
Serial.println("#0P1500T100 #1P1500T100 #2P1500T100");
delay(500);
}
I used one of my batteries to power everything; The same thing is done when attaching the legs to the body to assure that everything is centered correctly. If you don't get it exactly right don't panic because you can always re-adjust things later if needed.
Step 3: Build Right Front Leg
Note: Pay close attention to the orientation of each part
The build process for the right leg is the same as the left leg; the only difference being the orientation of the parts.
Step 4: Completed Legs
This is how the front two legs should look when finished; this is also how the rear legs will also look when finished.
You will want to go ahead and build the rear legs which will also look exactly like the front two legs. Once that is complete you can move to step 5 and attach the legs to the body.
Step 5: Attaching Legs to Body
Note: Sorry for the bad picture quality.
When connecting the legs to the body I would suggest a friend hold the body while you attach the leg. All of the servos are being centered while I attached the legs to the body. If you are confused as to how I am centering the servos please refer to step 3.
You will want to attach each of the coxa (hip) servos at a 45 degree angle to the body.
Step 6: Preparing Arduino Mini
At his point you will want to go ahead and solder some pin headers onto the Arduino Mini 2560 as seen in the picture above. This makes it easier to disconnect things later if needed.
The pins that needs headers are listed below
VIN, GND (The Arduino gets power from the 5V, GND on the ssc-32 which is also used to power the servos)
18 (Connects to SSC-32 RX Pin)
GND (Accelerometer Gnd)
3.3V (Accelerometer Power)
5V, GND (Xbee Power)
17 (Connects to Dout from Xbee)
GND (Connects to GND on SSC-32)
A0, A1, A2 (Accelerometer X, Y, Z respectfully)
Step 7: Preparing SSC-32
There is very little that you will need to do concerning the SSC-32. Firstly you will want to make sure the corrected baud rate is selected on the SSC-32. There are 6 sets of pins in the middle of the board; they are labled "BAUD" & "ABCD". You will want to make sure that there are jumpers on both of the BAUD Pins and no jumpers on A,B,C,D.
You will also want to remove the jumpers on the RX, TX Pins down below the Serial Connector. This is because will will attach a wire to the GND & RX pins that will run to the Arduino. This is how the SSC-32 gets it's commands from the Arduino.
Step 8: Install Electronics Onto Body
The arduino mega is installed on a plate that sits above the SSC-32 pictured above. I mounted the SSC-32 upside down to make the wiring cleaner, it really helped to do it this way. The xbee radio is also attached above the servo sequencer; I used jumper wires to make the necessary connections between the boards. This way it is easier to change things later on without having all the connections be permanent.
The layout of things is not set in stone you can deviate from what I have done. If you have a different look in mind you can change the layout just keep in mind that you will need space for your battery. In my case the battery and UBEC are installed inside of the body. That is also why I installed most of my electronics on top; so I could easily access the battery.
I suggest removing the battery while charging; if something went wrong things could melt or worse. I used Velcro tape to secure my battery to the robot.
Step 9: Assemble Remote Control
This is how I decided to layout my remote you can change it if you want it to look different. At some point I will change the joysticks used on this remote with ones with potentiometers at the top. The plan would be to used the extra potentiometer to adjust the height of the robot. I will have to create a schematic for the remote; although for the most part it is pretty basic.
I got a plastic enclosure box from Frys electronics here in Austin to install the electronics in. To make everything stay in place I have installed a sock behind the board that keeps everything in place. There is a USB cord that connects to the li-po charger and fits through an opening in the back of the plastic box.
Step 10: Upload Source Code
The code for the robot & remote are available through github at the following URL:
https://github.com/davidhend/Qaudruped
63 Comments
7 years ago
Sir I have completed my quadruped and I have successfully modified your code to control it via ps3 controller but the problem is I couldn't find the proper supply for powering my towerpro mg946r servos..here in India I am not able to find the specified ubec so can u help me drive me out of this problem ....any suggestions Will be helpful to me
Reply 7 years ago
bro....can u send me the arduino code for its four direction motion ??
Reply 5 years ago
have he sent you the code ?
Reply 5 years ago
if yes, please send to me this is my email "suheil.hassonah@hotmail.com"
Reply 7 years ago
Congratulations, that's awesome! I would think you could get away with using 6V NiMh batteries. The biggest concern is getting enough current to each motor/control board. It might take a little bit of experimentation but you could try powering things with a similar battery to this:
http://www.hobbyking.com/hobbyking/store/__25030__...
Weight is also a big deal, so you will want the most current with the least amount of weight. Good luck & let me know if anything else comes up.
6 years ago
Hi David,
The query of the SSC-32 finally results in "GP"
if ((cbRead > 3) && (abVer[cbRead-3]=='G) && (abVer[cbRead-2]=='P') && (abVer[cbRead-1]==13))
The new SSC-32U has a different ending, can it be that I therefore have no sensible leg movement?
What type of extension do I need to enter?
Thank you
Sorry for my english
Juka
7 years ago
miaw so expensive
Reply 7 years ago
50$ TUTORIAL PLSSS
7 years ago
Hi David,
Are you able to explain the logic for the radToServo function in the quadraped repository under nuke.ino? This doesnt not seem to return a servo offset for a Hitec Motor, i would expect (-pi/2,pi/2) to map to (500,2500) (or +/- 1000 because you add the offset to 1500 when calling make_command)?
I tried uploading the code to my own quadraped and set it to the walking mode with a hard coded Xspeed of 10; the femur and tibia seem to move correctly, but the coxa never move. If i inspect the serial commands, i can see the coxa IK changes but not sufficiently to move more than an integer degree?
I happen to have the same dimensions as your quad defined in one of the header files.
Reply 7 years ago
To be honest I never got that robot to walk; at the time I was convinced that the motors were not strong enough for a quadruped. With body balancing they might have been up for the job, but I didn’t know how to implement that.
The original code was written for robots using "Dynamixel" servos, it could be part of the reason that you aren’t getting the range of motion you expect. I had to make a change to the leg lift height for example.
Ultimately, I used the parts from this robot to create a hexapod and swapped over to the "phoenix" code base.
At any rate, I found this, maybe it will help you:
http://forums.trossenrobotics.com/showthread.php?7...
Let me know if you have any other questions, I will do my best to answer them.
Reply 7 years ago
Thanks for getting back to me. I'll take a look at the post thanks.
I've got slightly more powerful motors myself (HS-485HB), however mine are slightly oversized which is why I ended up getting the same tibias you have since they only attach the the front of a servo instead of both sides.
I think my servos are strong enough, however I think i've been going about how to balance this thing in the wrong way... I think I need it to shift its weight onto its hind legs while one of the front is extended. Exactly like you are doing at 0:52 and 0:58 in your video when you have it standing on 3 legs. I've been trying to make it stand while keeping 3 of the legs perfectly centred,which is not ideal mechanically, but it would have looked pretty cool.
I had mine balancing on 3 legs using the SSC32-u servo sequencer application: http://www.robotshop.com/ca/en/ssc-32-servo-sequen... Currently trying to get it to walk with no load, trying to simply my problem by removing the weight of my heavy 6v battery. I forgot to save the inputs I gave it, so I'm currently trying to recover that.
Thanks again
7 years ago
amazing, can u send me the arduino code for its four direction motion ?? my email : mahader.sob@gmail.com
7 years ago
amazing, can u send me the arduino code for its four direction motion ?? my email : mahader.sob@gmail.com
7 years ago
Have you added a body shifting table ?
https://www.youtube.com/watch?v=S8yEUYmBucc
7 years ago
Hi there, i love what you have done here and am trying to make it. However i have afew questions i am hoping you can answer.
I would be doing this with a Uno instead of a mega, with the ssc-32 taking the tx/rx pins, i do not have any other tx/rx pins for the XBee.
Another question is how do you power your servos from the UBEC, i am guessing you had one common live and ground and connected the servos and arduino and ssc-32 parallel to it? I would be great if you have a wiring diagram.
Also in the future i would like to expand it into a hexapod which means 18 servos, a 15A UBEC may not be able to power all of them, did you use two of the UBECs for your hexapod?
Thank you and i love your pink tracking video!
Reply 7 years ago
Thanks for the kind words; I appreciate it.
In regards to your serial connection question, you could try
using the software serial library that comes with the Arduino IDE to talk to
the XBee.This works by taking two pins
on the Arduino and using them as a serial communication.Typically the speeds are slower on software
serial and would only recommend using a lower baud rate, something like 9600-19200
baud would most likely work good.
With the UBEC, I connect a Li-Po batter to the UBEC which
will provide either 5v or 6v depending on the switch position.I connect the 5V and GND from the output of
the UBEC to the Arduino.Between the
Arduino and the SSC-32 I connect a Serial data line and a GND connection.Your exactly right about the wiring diagram,
maybe someday soon I will put something together.
With my hexapod, I use a second UBEC to power the Servo’s, mainly
because the servo’s generate “electrical noise” when they are moving, which can
cause problems with the XBee/PlayStation remote receiver.It is a good general rule to keep the power
to the servo’s and logic controller separate.
7 years ago
sir as i am not using ssc 32 board and just running the quadruped with arduino mega so how will i modify the code for it .i have noticed that nuke.ino contains some code like make command() and execute commands() which will effect the code for use in my way please help..
Reply 7 years ago
The SSC32 is very efficient at what it does, it also allows the Arduino mega to concentrate on the calculations vs. moving the joints. The make_command(), execute_command() send serial sentences to the SSC32 servo sequencer. These sentences contain all the servo moments and the amount of time for each movement. I have never tried to integrate both the calculations and servo movements onto one micro-controller. I am not sure if the micro-controller will be able to do both, it might make the movements erratic and less smooth; however, if you felt like trying maybe it will be do-able.
Ideally you would want a dedicated servo controller, either made or purchased. I really think that is the best way forward, although I understand cost and accessibility issues.
Reply 7 years ago
So will I able to do if I arduino nano for primary calculation and mega for servo movement if so please give me just help for doing that
7 years ago
hello david sir .......can u please help me to modify your code to control my quadruped using ir tv remote i am a first year engineering student and i did not know much about programming