How I built a hexapod robot

Aditya Srinivas Manohar
6 min readAug 2, 2020

--

Being an undergraduate student with an intense passion for robotics, I wanted to build a unique project during my summer vacation. Highly inspired by the advanced legged robots by Boston Dynamics, I wanted to build something very similar. Upon further research and watching loads of videos on youtube I decided to build a hexapod walking robot. In this article, I give a detailed overview of my thought process and experience along with a rough build guide on this project.

Why Hexapod?

Well, there are many different kinds of legged robots that can be built: 1-legged, 2-legged, 4-legged, 6-legged and 8-legged. While deciding which one I wanted to build I took into consideration the following factors

  1. I was not an expert in building legged robots, and never built a legged robot before
  2. I had a certain budget constraint and did not wont to spend a whole lot of money on this project
  3. Though I knew quite a lot of inverse kinematics and had a decent bit of coding experience I had no clue about motion planning and path planning algorithms
  4. I have had no experience with ROS (Robot Operating System) and do not intend to use it in this project either

Keeping these points in mind I wanted to build a simple walking robot. This led me to build a hexapod robot. I did this because -

  1. Hexapod robots are six-legged, so they have high intrinsic balance.
  2. While walking, hexapods usually employ the tripod gait i.e, a set of 3 legs are alternatively used to make each step. This allows me to not worry about the balance of the robot while walking, since 3 legs are always grounded on the floor.
  3. Each leg accommodates 3 motors which results in a total of 18 motors for all the 6 legs of the hexapod. This falls under my budget constraints.
  4. Assuming that I can solve the inverse kinematic equations I can just hard-code a set of motions onto the robot to make it walk and move appropriately thus eliminating the need of motion planning and path planning.

Taking the above points as granted I finally set out on my journey to build a hexapod robot!!

The Hardware

Before creating the CAD models and starting with the design I had to decide which motors and controller to use for this robot. I had heard a lot about the AX-series from dynamixel and ended up going with the AX-12A servos from dynamixel. Firstly these motors are really smart and provide a lot of control and flexibility to the users. They have many features including position feedback, temperature feedback, load feedback, high precision position control and much more. Secondly these motors support daisy chain communication, reducing the amount of wire clutter dramatically. I already had a LiPo battery and decided to 3D print the rest of the robot structure. The only other piece of electronics that I used was a power distribution hub by dynamixel to distribute the power effectively to all the 18 motors. I also, eliminated the need of any micro-controller by directly controlling the motor from my laptop. For this I used the usb2dynamixel adapter.

COMPONENTS USED

Since I could 3D print the structure, I had the freedom to build anything that I imagined and the design of the rest of the parts were up to me to decide. Initially, I made CAD models of a few of my design ideas. Being a mechanical engineer I was able to identify the ones which were mechanically unstable and scrapped those. I finalized on one of the design and got it 3D printed. On introspection I realized that hexapods were classified on the basis of body shape into regular, rectangular,elliptical etc.

The configuration that I had printed was elliptical. Further I realized that I had forgotten to provide space for fitting the battery in. To make the control algorithm simple, I decided to change the base of the hexapod to a regular hexagon while keeping the same design for the legs. Thus I had to reprint only the base of the hexagon.

Elliptical vs regular hexapod

Inverse Kinematic Equations

Before we move onto the inverse kinematics of the hexapod, it is important to realize the different movements that a hexapod can perform. Generally there are 4 types of movements in a hexapod robot -
1. Roll
2. Pitch
3. Yaw
4. Translate (move along the X,Y plane)

To control these movements dynamically we need to solve the Inverse kinematic equations. Each motor needs to move to a certain angle for the leg to reach the desired coordinate. This mapping from leg coordinates to motor angles is what is termed as inverse kinematics (IK).

From my previous projects I had an idea on how to solve this problem and worked on it for a week to derive the equations for the inverse kinematics. What I basically did is keeping the body center as origin, I derived equations to obtain the leg coordinates (depending on the orientation and position of the body, the leg coordinates for each leg changes). Then we apply inverse kinematics to find the motor angles for each leg. The equations can be derived by simple trigonometry and basic mathematics. Below I have given the inverse kinematic equations for a leg of the hexapod. These set of equations are universal for all hexapods with a similar leg configuration.

INVERSE KINEMATICS EQUATIONS

The Software

To control the robot I used python along with the pypot library for controlling the motors. I translated my inverse kinematic equations to a python script. It consists of an inverse kinematic function having 6 primary variables (X,Y,Z,RotX,RotY,RotZ), changing these variables would accordingly move the hexapod to the desired location. One thing to keep in mind is that the inverse kinematic equations are solved such that the base alone moves to the desired location keeping the legs grounded at the same coordinate.

To make the hexapod move, I decided to employ the tripod gait. It involves moving 3 legs at a time, while keeping the other 3 legs grounded. I modified the inverse kinematic function for 3 legs and accordingly used these functions appropriately to make the robot walk.

Finally to make the controls easy to use I mapped all the movements to specific buttons on a wii remote and nunchuk. To do this I used the cwiid python library.

The Final Product

On assembling the parts, wiring up all the motors (daisy chaining a set of 3 motors which form a leg and connecting it to a port on the power hub) and after a lot of software development (~1.5K+ lines of code) I had built a successfully walking hexapod robot!! Though the movements can be refined and made more elegant, I am happy with what I have done up to this point. Below is a video of the hexapod.

What else can be done?

I plan on Exploring the below features as add ons to the existing hardware.

  1. The current version of the hexapod is wired to the laptop, to make it wireless I will have to add an onboard micro-controller.
  2. Adapt and implement various other gaits such as wave and ripple gait for walking
  3. Would love to learn ROS and implement motion planning and path planning algorithms.
  4. Add camera/LIDAR to make the robot spatially aware of its surroundings
  5. Make the robot compliant by tinkering with the compliance settings of the motor

--

--