# Turning

A project log for Pengu Q1 quadruped

A low budget quadruped with dynamically generated free gait

Pengu MC 12/22/2014 at 21:266 Comments

I made some functions to allow a statically stable turning motion of the robot around its own center. Stability is preserved by moving the robot's body into a position that allows stable lifting of a foot before each transfer.

The resting positions for all feet are known. They are chosen for their high kinematic margins in all directions.
(i.e. all servos set to their middle angle to allow for the most room for movement).

The turning motion is then generated with the following cycle:

1. Find the resting positions for each foot when the body would be turned by x radians
2. Look at the legs that have not been transferred yet
3. Move to a position to allow any of those legs to be lifted with stability
4. Lift the leg and transfer it to its new resting position
5. Turn the body by x/4 radians
6. Repeat steps 2 through 6 until all legs are transferred and the body has turned x radians
7. Move the body back to the center

The result can be seen in the following video, where x = 0.3

With a few modifications this cycle might be used to reset all legs to their resting positions by simply doing a turning motion for 0 radians. More on that later...

## Discussions

de∫hipu wrote 01/02/2015 at 18:06 point

Would't it make sense to use the same technique as for walking? That is, use the body IK to turn the body to the desired position, and while doing that, move the legs that are the furthest away from their home positions?

This way you could also turn while walking...

Are you sure? yes | no

Pengu MC wrote 01/02/2015 at 19:18 point

Yes. And it's something that's basically already there and available.
The difficulty in moving forward however, is that there needs to be
some guarantee that the body can be moved into a desirable position to
allow stable leg-lifting (in order to continue motion). This becomes
less likely when leg movements are larger. (the legs can't reach far
enough)

I always find it fairly hard to visualize this so I made a javascript thingie for it:

I'll add a small readme to the repo. But basically you can pick up and drop
the squares, which represent the feet and the center of mass.

Are you sure? yes | no

de∫hipu wrote 01/03/2015 at 10:35 point

Wait a minute. Rotating the body (twisting) along the Z axis doesn't move the center of mass in the horizontal plane, and it doesn't change the support area, since you are not raising the legs. So all you have to be careful about is to not twist too much -- that is, pause and move the feet when you are near your limit.

Are you sure? yes | no

Pengu MC wrote 01/03/2015 at 11:10 point

You're right, it doesn't change the position of the center of mass, but it does change the position of the points where the legs attach to the body (i.e. the corners of the body).

-

Imagine a pie shaped area on the ground for each foot with the pie center at the point where a leg attaches to the body. This area is where the foot can be placed / the leg can reach. When you turn the body, the foot's relative position in this area changes. For example the amount of room left to move in positive x-direction is reduced while the amount left in the opposite direction is increased (aka: the kinematic margin in x-direction is reduced).

-

Now imagine the body, and its four corner points where the legs attach, turning. All of the feet effectively change their relative position in their respective reachable areas. The changes for each foot are different because their legs are attached to different corners of the body. (it's not actually the feet that move but rather the reachable areas that move)

-

We're still intending to move forward (x-direction), so we like to have a lot of room to place feet in the forward direction. But because we turned, at least some of the feet will (likely) have their margins in that direction reduced.

-

Some reduction in the margins is tolerable, but how much is not really a known quantity. And trying to describe that quantity requires looking into the future to ensure that other feet maintain enough margin when the body is moving. This is where more math comes into play, and the actual gaitgeneration starts.

-

Maybe you can describe the movements that you want in steps of moving/rotating the body and moving feet in x,y,z. And I can make post some visualization of what happens

Are you sure? yes | no

de∫hipu wrote 01/03/2015 at 11:45 point

Well, if the maneuver that you need to perform requires larger margins than what you have in the current stance, you need to pause and rearrange the legs anyways. The only problem is when you can't shift your body enough to be able to raise a given leg, because the center of gravity would fall outside of the support area -- but that's not an issue with just rotation.

I just tested in on my quadruped, and you are right. While there is no problem rotating in place, doing it while walking may result in instability. Even shifting the body right after rotating without first rearranging the legs may be dangerous.

I wonder if it would be possible to calculate the maximum "safe" range of a leg -- one that always gives you enough margin to raise it. But that would probably make the steps very small and thus the robot quite slow. I guess it's easier to just pause and rearrange the other legs.

Are you sure? yes | no

Pengu MC wrote 01/03/2015 at 16:03 point

There a quite a few papers and even a book on calculating everything you need:

-