# Walking – gaits

Now that we can control the position of our feet and move them along a trajectory we can organise the leg movements into a walking gait.
To start with I’ll implement a static gait. In a static gait at any time during the walk cycle there will be at least tree legs in contact with the ground.  Contrast this with dynamics gaits like  trot or pace where two legs at a time are in contact with ground.

A static gait is defined by the order at which the legs are lifted during the walk cycle. In a crawling gait, for example, the legs are lifted in the following order:

1. front left leg
2. back right leg
3. back left leg
4. front right leg

To implement a static gait we can split our step trajectory: one segment will be the flight phase (the complete arc trajectory) and the ground phase trajectory will be divided into tree segments.

The start of each segment will be represented by a key position. We can the use this key positions to describe our gaits in a compact data structure. A crawling gait can be then represented as:

int[][] gait = {
{1,4,2,3},
{2,1,3,4},
{3,2,4,1},
{4,3,1,2}
}

Each row represents a step. The four numbers in the row represent the key position for the corresponding leg, starting with the back left leg and moving in clockwise direction.
If we take for example the first row (first step in the cycle), the key positions for the four legs are:

back left leg: 1. key position
front left leg: 4. key position
front right leg: 2. key position
back right leg: 3. key position

With this setup we can generate a trajectory for each leg between it’s current key position and the key position in the next step in the cycle. Then we move each leg through the generated trajectory points until we reach the next step and a new trajectory is generated.

You can download the Processing sketch that illustrates this approach from my repository:  https://github.com/Traverso/Felix/tree/master/Processing/Gait.

In this sketch you will find two different types of static gaits and their corresponding “backwards” versions. Just set the variable “CURRENT_GAIT” to 0,1,2 or 3 to test the different walk cycles.

## One thought on “Walking – gaits”

1. ator

Hi, Really nice processing animation! Where did you learn how to do it? if you maybe know any particular tutorial where is explained how its working?
I’d love to do similar animation but for bipedal walking cycle.