# Designing a Quadruped Robot – Part 2

In this post I’m going to discuss the mathematics behind moving the legs of the robot correctly. But first, another quick video of the robot roaming free on battery power:

The key to getting a robot like this to move is finding a way to tell each foot exactly where you want it in 3D space. In order to do this, each joint in the leg needs to be rotated at exactly the right angle. The joint angles are calculated using inverse kinematics. In the case of this robot, each leg has three joints:

In order to simplify this from a 3D problem to a 2D problem, find the angle of the coxa joint first:

Find the distance from the femur joint to the foot, ignoring the coxa length. This gives the x position of the foot for the simplified 2DOF problem:

Find the length of the imaginary leg in the 2DOF problem:

Find the angle of the imaginary leg in the 2DOF problem:

Use the law of cosines to find the tibia joint angle:

Use the law of cosines to find the angle between the imaginary leg and the femur, and then subtract out the imaginary leg angle to get the femur joint angle:

Now we have the three joint angles for the leg: , , and . All that’s left to do is convert the angle to something the servo understands. Since the Dynamixel AX-12A servos accept a value from 0 to 1023 and have a range from 0 to 300 degrees, the following equation can be used to convert radians to a dynamixel value:

And that’s it for the leg IK equations. Simply plug the x, y, and z coordinate values into the above equations and solve. Plug the resulting angles into the last equation to get the position values for the servos, and the foot will move to the desired position.

Next time I’m going to explain how to use this to make the robot walk forward.

Posted on May 17, 2013, in Robotics. Bookmark the permalink. 4 Comments.

Hi,

I’m impressed by the work you had done on the quadruped.

I’m in dire need of your help to seek some valuable solutions.

I’ve been seeking solutions for the last 6 months to solve the kinematics of the hexapod with no positive results.. I managed to find equations for all of the servo angles with the body parallel to the floor, but unable to do so with the body tilted to one side. Appreciate if you would be able to help 🙂

Regards

Gary

Hello Gary, Thank you for taking a look and I’m sorry for the late reply. I plan to write about this in the next couple of weeks, but I’ll admit in advance that my solution isn’t perfect. Keep an eye out for a post on this soon.

Hey,

Good job with the kinematic !

I’m in a hurry to get to this point with my hexapod 😉

Maybe I will come back to one day for kinematic advice xD

Bye

Pingback: Designing a Quadruped Robot – Part 3 | Justin Woodman