I wanted to do a walking four legged robot, more in a "mammal" style than the normal "spider" or "insect." The inspiration comes from the well known Boston Dynamics robots and other four legged research robots. Making a robot like this is quite challenging since it quite easily tips over due to a high center of gravity and the feet under the body instead of spreading out to the corners.
The aim was to build a cheap robot, using Arduino and low cost micro servos. This solution of course has it's limitations. One can not expect it to be perfect but I have manage to build a few robots now that can perform the walking behavior as described in this film. And doing the best one can on a very small budget is a challenge by itself and maybe something guys on heavily funded research projects never have to face . :)
It was early identified that a study of inverted kinematics (IK) was needed in order to get it right. The code has a set of equations to calculate joint angles based on desired foot movements. These can be further used in functions for some recurring tasks like doing a body movement (moving all fours feet in the opposite direction) and making a complete foot movement (lifting upwards moving in a specified direction and putting it down again).
The next challenge is to do gait studies, i.e. to define how the robot should walk and turn in terms of body and foot movements. My robot uses statically stable gaits all the time. One foot at the time is lifted and put into a new position. The body rests on the other three feet and in order to not tip over the center of gravity must remain within the tripod that these feet form. I developed four standard gaits - forward, reverse, left and right. This in turn utilizes the foot and body movement functions to be combined into a full sequence.
I also designed a function for synchronous servo movements. In some cases several servos are making different strokes during a set time. This must be synchronized in order to achieve smooth movements.
Last but not least i use a completely unprotected LiPo battery. This can be risky, the major hazards is to dis-charge it to fast or too deeply. The first hazard is avoided as long as it isn't accidentally short-circuited. A normal R/C battery has a discharge rate of 25 C which in this case allow for 12 A. The UBEC will prevent it from being higher than 2 A in any circumstances. The second hazard is prevented by a surveillance function in the software. The voltage is measured on one of the analog pins and if gets lower than 7.0 V the robot is put to rest.
And finally I must stress that the batteries should be charged with a purpose built charger and handled with usual care, never leave charging unattended. The battery should detached from the robot (use velcro to mount it) and charged inside a fire proof bag or at least with a safe distance from flammable materials so a fire can be contained and not spread. Also store your batteries safely.
If you are not familiar with LiPo batteries consult a local R/C hobby store and buy batteries together with a suitable charger and possibly a fire proof bag/container for charging and storage. These items are often full of warning signs. Reda them and use your own good judgement. :)
Building the robotPrint the parts according to the supplied files. Take som time to look at the pictures and figure out how to assemble the parts before starting. I am Scandinavian but this instruction is far from the level of an IKEA or LEGO instruction :)
The hip joint should be assembled first. I used double sided tape of good quality to join the parts. They could be glued also but in case there would be a need to repair a broken part they are impossible to disassemble, one broken servo leads to a replacement of the complete joint.
Put the servo support on the bottom of one servo, in line with the actuation axis. Then join another servo with it's axis perpendicular. The picture below shows the hip joint for the front-right and rear-left. For the two other corners mirrored joints should be made.
Before proceeding it is good idea to make sure that all 12 servos are centered. The best way is to assemble the PCB (or breadboard, see below), connect all servos and the load the code. When the Arduino is started up all servos will center (command signal 90 degree). There will be need to fine tune the center positions later once the robot is assembled.
The next step is to attach the part called thigh, the "upper limb" of a leg assembly. This part has recesses that fit together with the servo horns that normally is delivered together with the servo. Glue horns into the recesses. Make sure to use a glue that works for joining the 3D printed material and the nylon plastic that the horn is made of. The glue gun I used worked fine, I have had some mixed success with CA glue though (some brands work, other not).
The thigh is joined to the hip joint at a 60 degree angle. Try to find a position that comes as close as possible to this angle when the servos have been centered. Secure the horn onto the servo spline with the supplied screw (often the shorter of three that are delivered with a servo). Below are two pictures of assembled thigh and hip, servo horn not included for clarity (or never modelled out of laziness from my side) .
The lower part of the leg should also be assembled. In this case a servo is attached to the leg part using screws. There are screws supplied with the servo (often two longer "wood" screws).
Now the legs can be assembled onto the body. There are two parts I called "bumper" that are on the front and rear of the robot (like the bumpers on a car). They have recesses for servo horns just like the thigh part. Glue horns into them. Then slide the servo support of an upper leg into the corresponding hole in the body. When this is done on both sides, the assembly can be secured by the bumper. Allow the legs to point out at about 12 degrees (a 20 mm toe-out of the leg). The bumper is secured to the body by using left-over (longer) servo screws.
At last the lower legs of the robot can be attached. They should be angled in the opposite direction of the thigh, making the tip of the foot being right under the hip joint of each leg assembly.
By this the robot is assembled. It should look like on the picture below. Note that the design of the robot has changed slightly compared to the top image and the film clip. The body has been redesigned to simplify and make a more robust design. The servo support and horn for the hip joint have swapped places. So assemble according to the 3D images and avoid being confused by the photos and film clips.
Of course the angles of each joint cannot be exactly at the angles required, the number of splines on a SG-90 servo is 21, leading to an angle of 17 degree between two positions. You can at best assemble the robot within 10-20 degrees, the remaining error must be adjusted by changing the neutral position in the code, see further down in this instruction. It might be a good idea to once again connect all servos and fire up the Arduino and check the neutral positions and if needed do some mechanical adjustments (moving a joint a spline or two). One tend to accidentally turn the servos when working with them.
There are two options, have everything on one breadboard or to produce a PCB with the supplied Fritzing file. You might run into some problems with voltage in the breadboard if you don't take care when connecting all power and ground lines to the servos. In extreme cases one servo can consume 600 mA and poor connections lead to erratic behavior. The PCB have very broad copper traces for the power lines so if you just solder properly it will work fine.
There is no power switch in my design. The robot is simply turned on and off by connecting the battery. If you want to add one it should be after the battery connector, cutting of the 7.4 V supply to both the Arduino and the UBEC.
Breadboard version
It is possible to have the Pro Mini, connectors for the servos and most of the other electronics on one half-size breadboard. I draw the schematics in the picture below. Make sure to use short jumper wires, especially for the 5 V power and ground connections to the servos. The servo connectors are simply extra long male headers that are cut in pieces of three and pressed into the breadboard.
What is not shown in the picture is the battery and the UBEC. There might be some soldering to fix this in order to attach a connector fitting to the battery. From the connector two jumper wires should be connected to the lower "power rail" of the breadboard in order to feed the Pro Mini (connected to RAW and GND). Also connect two resistors from the 7.4 V supply to the A0 pin. 2.2k goes from the positive side and 1k from the ground. This will divide the voltage, which is more than 8 V on a full battery, to a value below 5 V which can be measured by the analog pin.
The output side of the UBEC has a servo connector. It is quite convenient to add a two male header on the upper "power rail". Put it somewhere in the middle like in the picture to assure that the power distribution to the servos is as balanced as possible.
The IR receiver should be connected to A1 and have 5V supply. The pins on the receiver are long enough to be fitted into holes directly on the breadboard.
There is a schematic below and a picture on how the finished breadboard might look. Note that the picture shows an older version of the robot with different pinouts and connections. It still gives an idea on how to connect jumper wires and servo connectors.
The breadboard is attached to the body with its self-adhesive backside. Orient it so that the corner with the servos connected to the pins D3, D4 and D5 (upper right in the schematic) is on the front/left corner of the robot and make sure that the board is centered on the body (correct center of gravity is vital).
PCB version
I added a Fritzing file below. This can be used to produce a PCB, either by ordering from the service available at Fritzing or by exporting files for PCB manufacturing. I did a serie of pictures to show the assembly below. The PCB is custom made for this robot with connectors to all servos, IR and voltage measurement. But there are also connectors broken out from the remaining pins. These can be used to connect other equipment if you want to expand the robot in the future.
There are small "pads" on the body the fits to the corners of the PCB. Also here the corner with the D3 to D5 connector should be on front/left. There are mounting holes on the PCB but I only used a piece of double sided tape on the body to attach it. It will stay on place.
Battery
The battery is attached to the underside with velcro. There is flat surface dedicated for this on the body. A 7.4V/500mAh LiPo battery normally has the form factor of about 55x30x10 mm (give or take of few mm) and it fits quite well into this place.
Finally the robot can be "touched up" by strapping the servo wires into nice bundles so it isn't tripped by them while walking. It also gives the robot a nice look of actually being a four legged creature walking around and not a heap of servo wires. :)
Before using the robots the center positions should be fine tuned. This is done by editing the array servodeg0 in the code:
const float servodeg0[12] = {90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90, 90};
The values are in order alfa, beta gamma and front/left, rear/left, front/right, rear/right. So beta on the front right is the eighth position in the array or servodeg0[7] (the numbering of the array starts with 0).
There is also an array called servodir that defines rotation direction of the servos.
const int servodir[12] = { +1, +1, -1, -1, -1, +1, -1, -1, -1, +1, +1, +1}; // Turning direction (positive is servo counter-clockwise)
The servos I used move from from 0 to 180 degrees in counter-clockwise direction. I have read somewhere that there are servos going in the other direction. In such case the array servodir must have their signs changed all along.
Start up the Arduino and check the angles on all servos. Make measures and look the everything looks straight and symmetric. Distances and angles should be according to the picture below.
It is difficult to be within exact millimeter on each measurement, to be within a cm is reasonable.See what changes that are needed and add/subtract them to the value in the array servodeg0. This will definitely require a few iterations before everything is correct. You will end with a servodeg0 array that looks something like this (an actual piece of code from one of my robots). And most important, you should in the end have a robot that rests on all four feet and stand straight.
const float servodeg0[12] = {80, 95, 100, 100, 110, 90, 100, 115, 100, 80, 80, 100};
Now everything is finished. Enjoy!
Just maybe a few tips on the way.
The servos might need re-calibrating after some while. The center position can drift over time. Just check if everything is aligned from time to time.
If you have made everything correct and still have a robot that will tip over, check the center of gravity. The battery can be moved to balance this, one good thing with using velcro.
And once again. Treat your LiPo batteries with care.
Further improvementsBy submitting my robot here I also invite people to refine the design, either adding more functions or to do a slightly different layout (bigger, smaller, cooler looking). The code should be possible to re-use on a robot of a slightly different layout or size. The sketch below show what the different constants in the code. All IK and movement functions should still work if a robot with different measures is made. It also show the coordinates are defined, x is pointing in the forward direction.
And of course it would be interesting if people added functions to the robot. There are several buttons on the remote that could be given functions (why not dance or do some other sequence of movements if a button is pressed).
I personally experiment with analog input. I have also worked with a "turning while walking" gait to be able to steer the robot to some extent, or to correct course deviations with help of gyro or compass. And I also added an ultrasonic sensor and autonomous behavior (avoiding obstacles). My current project is to combine analog control with autonomous and have everything controlled from a smartphone. This have forced me to learn about a lot of new things (Blynk, ESP6822, serial communication between deivices etc) and hopefully I can launch a refined version of the robot (or maybe someone with better skills beat me on that thing) :)
Comments
Please log in or sign up to comment.