DIY Arduino Quadruped Robot With Inverse Kinematics
by ilhamdefra in Circuits > Robots
6993 Views, 10 Favorites, 0 Comments
DIY Arduino Quadruped Robot With Inverse Kinematics
Leg-based walking systems utilization has turned out to be very familiar with the robotics field. These systems present better adaptability over wheeled systems, particularly when dealing with irregular terrain.
Building a spider-like quadruped robot that at least capable walk straight forward, of course we have to arrange how each leg moves when it steps and when it pushes its body. In classical mechanics there is subfield, or branch, that study the motion of points, bodies (objects), and systems of bodies (groups of objects), its called Kinematics.
Quadruped robot in this project has 4 legs, and each leg has 3 joints which are driven by 3 servo motors, for a total of 12 joint driven by servo motors. Let say we write program for this robot at least just for walk straight forward, now what you thinking? if you already experienced in microcontroller programming, or software engineering, you'd should be thinking that programming this robot is by controlling those 12 servo motor rotation that drive the joint, because it is the key variable.
Then you probably wondering "why branch of mechanical study has something related to robot programming? isn't it electrical and software engineering field needed for the programming?" Okay, i'll explain why.
In robotics the edge of a robot that interacts with the environment or does work is called the End-effector, in quadruped robots this means the toe. For example, when the robot moves straight forward, the toe must stick to the surface and perform a straight backward motion to push its body forward. Path of motion (or trajectory) from the toe of this leg can be modeled with a 3-dimensional Cartesian coordinate system (x-axis, y-axis, z-axis), then we should think what method that can convert or calculate joint angle rotation from given coordinate position of the robot legs tip, or simply by inputting the position of {x, y, z} of the leg tip then the three joint on each legs will be calculated, this method is called Inverse Kinematics.
Why need to calculate joint angle? Arduino IDE already have servo.write() function to declare angular position (in degree) of a servo inside the parentheses, so calculating the angle is make sense right? because we need that to be written in the servo.write() parentheses. For example, servo.write(90); this mean command a servo motor to rotate to 90 degree position.
Supplies
Component used as shown in YouTube videos:
- Chassis made of sheet acrylic 3mm thickness, custom designed, fabricated with CNC laser cutting and few bending process. i'm not doing the fabrication process myself, i draw my own design then send it to local acrylic shop in my town. I'm not recommend you to use chassis design as shown on the YouTube video, i will recommend you to use this design instead.
- 12x TowerPro SG90 servo motor.
- An Arduino UNO board.
- "Sensor Shield V5", this is an expansion shield for Arduino UNO board.
- 3mm bolt and nut (M3 size), washer is optional.
- USB cable with each end port have Type A and 2.0B (when you buy arduino board usually these cable included)
Remember, this is as shown in YouTube videos, you can improvised your own, like using batteries instead of phone charger to supply power, etc.
Tools needed:
- CNC laser. You can download chassis design from link i give before, then you need little change to make it as STL file for cutting process. Cheaper suggestion is you don't really need to buy this machine, you can just send the design to your friend or local shop that has CNC laser machine for cutting sheet acrylic.
- Acrylic sheet bending machine. There's need few bending process for the acrylic after you cut the parts. There is cheap DIY 'technique' you can find on internet or YouTube to bend sheet acrylic instead of buy hundreds dollar machine.
- Screwdriver. I design the chassis to be assembled with bolt and nuts, so you need screwdriver.
- Computer or laptop, any OS.
- Arduino software. If you Windows 10 user you can search it on Microsoft Store, if you need link via web instead you can click here.
Walking Sequence
The gait of robot is two-phase discontinuous. With models such steps, at each point of the robot body is kept in balance by three legs on ground, making it very stable when moving robot. The body is propelled forward or backward with all of the feet securely placed on the ground and a leg is transferred with all other three legs and body halted. For every phase of robot body will propel forward once. As i said before, we want to make the robot legs tip, or toe, motion path (trajectories) modeled with cartesian coordinate system, by modeling the position of legs tip with cartesian coordinate system defining its trajectory is by defining value of the three axis (x, y, z). After modeling coordinate position of each legs tips the given value of x, y, z axis is then used to calculate how much angle each three joints in one leg should rotate in order to reach that desired x, y, z axis position.
The Inverse Kinematics
Now, lets model a leg tip of quadruped robot inside 3-dimensional cartesian coordinate, zero position for x and z axis is the coxa joint, zero position for y axis is the ground/surface. From the picture we want the leg tip is stride at a line along z axis with x position offset from its zero point, for the y axis of course when pushing/propelled robot body y axis position is 0, which mean stick to the ground. The inverse kinematics solution is easier if we split 3-dimensional point of view to 2-dimensional. First point of view is like we look at the robot legs from above, which represent x and z axis. In this viewpoint in order the leg tip reach, or move along designated coordinate it require coxa joint to rotate at certain value symbolized as (Theta 1), not only coxa joint rotation the legs also need to span in order its tip reach and move at designated coordinate, the value of leg span length symbolized as (D). Formula/equation to calculate Theta 1 and D is shown on the picture.
The second 2D viewpoint is to solve 2 other joint angle. This is where leg span length (D) data is needed, the simplest word to explain is like how much angle femur joint (Theta 2) and Tibia joint (Theta 3) needed to rotate in order to make the leg span as far as the length (D) which is calculated before. The formula to solve femur joint and tibia joint angle rotation is shown in the picture.
Now, by implementing these mathematics equation in the programming, define any where position of leg tip then the 3 joint is automatically calculated.
Electrical Component Connection
The expansion shield is attached on the top of the Arduino UNO board, then attach all 12 servos wire to the shield. Servo wire is attached to the pin on the shield that has number labels as shown in the picture.
- Pin 2 : Front left leg coxa joint servo.
- Pin 3 : Front left leg femur joint servo.
- Pin 4 : Front left leg tibia joint servo.
- Pin 5 : Rear left leg coxa joint servo.
- Pin 6 : Rear left leg femur joint servo.
- Pin 7 : Rear left leg tibia joint servo.
- Pin 8 : Front right leg coxa joint servo.
- Pin 9 : Front right leg femur joint servo.
- Pin 10 : Front right leg tibia joint servo.
- Pin 11 : Rear right leg coxa joint servo.
- Pin 12 : Rear right leg femur joint servo.
- Pin 13 : Rear right leg tibia joint servo
Pay attention to the color of the servo wire, the signal wire (usually colored yellow) is aligned with pin on the shield that labeled "S", the black/brown wire is negative terminal of servo is aligned with "G" label on the shield, and red wire is positive terminal of servo aligned with "V" label on the shield.
The Programs (Code)
Mathematical equation of Inverse Kinematics write in language that machine understand, in this project i used Arduino so the language is based on C++ language and written in Arduino IDE. Link to download Arduino IDE is on the introduction step. Uploading the code to the Arduino UNO board is by connecting it with USB cables. further basic for Arduino programs and uploading it you can find tutorial or guide on here or other various sources on internet.
This code is just walk straight forward. Pay attention code in void.loop() which is represent the walking sequence i explained on previous step. You can improvised the movement to backward, turning, or combination with sensor either automatically or with remote controlled based.
Hope this tutorial help, sorry can't give much guide to the chassis since i just send my drawing design to the local acrylic shop, so what i actually doing is just assemble it with bolt and nuts, also the design shown on YouTube videos is a bit not recommended, use designed that i give link on Introduction step instead.