E.R.I.C. Hind Leg Turning

So now I have a walking algorithm that allows E.R.I.C. to take a step forward I need to figure out a way to allow E.R.I.C. to turn. without this searching for a ball or moving around the room will be pretty impossible!

Will This Work?

Well I face two main issues here. The first one is that I only have the two hind legs to work with at the minute (the front legs are a few weeks away), so this page will only be an exploration rather than a final solution. Secondly while E.R.I.C. has 3 D.O.F. per leg none of them allow for twisting.

If you imagine how you turn on the spot it will involve your leg twisting at the hip, knee and ankle. If you don't believe me then try to turn on the spot while keeping both feet absolutely parallel and perpendicular to your hips, it's impossible.

So How Will You do It?

What I plan to try is to keep the feet the same distance apart while moving them through a circular motion in opposite directions. I think that this will effectively attempt to spin the earth round under E.R.I.C.'s feet - which of course is impossible so the torque reaction should spin E.R.I.C. instead!

That's the theory anyway.

The Algorithm

The algorithm is heavily based on the walking algorithm derived earlier. The difference is that instead of manipulating the foot position in the Y and Z axis the X and Y axis are changed instead. Also the calculation is based on a circle rather than and ellipse. Other than that they are pretty much the same.

The Code

The code for this function is shown below and rotates E.R.I.C. in a clockwise direction.

#include "ERIC.h"

void Turn(int rotation) {
    Timer t;                                // Used to control the movement

    float RHS_X, RHS_Y;                     // Variables for the right leg
    float LHS_X, LHS_Y;                     // Variables for the left leg
    float time = 0;                         // Variable to hold the timer value.
    float turn_time = rotation * PI / 180;  // Turn time to achieve the required rotation
       
    // Create local variables to hold the joint angles & current set points
    Joint_Angles LHS, RHS;                  // Variables for joint angles

    t.start();                              // Start the timer

    while (t < turn_time) {
        time = t.read();                    // Read the timer

        // For the right leg...
        RHS_X = cos(time);                  // Calculate the X position
        RHS_X = RHS_X * 70;
        RHS_Y = sin(time);                  // Calculate the Y position
        RHS_Y = RHS_Y * 70;

        // For the left leg...
        LHS_X = cos(time);                  // Calculate the X position
        LHS_X = LHS_X * -70;
        LHS_Y = sin(time);                  // Calculate the Y position
        LHS_Y = LHS_Y * -70;

        // Calculate the required joint angles...
        RHS = IK_Engine(RHS_X,RHS_Y,-180);
        LHS = IK_Engine(LHS_X,LHS_Y,-180);
        
        // Translate the joint angles into Servo Angles
        RHS.lateral = 165 - RHS.lateral;
        RHS.hip = 340 - RHS.hip;
        RHS.knee = 320 - RHS.knee;
        LHS.lateral = LHS.lateral + 135;
        LHS.hip = LHS.hip - 40;
        LHS.knee = LHS.knee - 20;

        // And finally move the leg to the current set point
        Right_Hip_Lateral.SetGoal((int)RHS.lateral);
        Right_Hip.SetGoal((int)RHS.hip);
        Right_Knee.SetGoal((int)RHS.knee);
        Left_Hip_Lateral.SetGoal((int)LHS.lateral);
        Left_Hip.SetGoal((int)LHS.hip);
        Left_Knee.SetGoal((int)LHS.knee);     
    }
}

Testing

The code was complied and tested and while it does turn E.R.I.C. the required angle there is some problem with the following movement (I kind of need to do a couple of half steps to bring the legs back to a neutral standing position).

I'm not too worried about this at the minute as I know when I get all four legs working I will need to change this algorithm anyway so I'll sort it out then.

Other Worries

also what is a bit worrying is the servos themselves seem to be cutting out from time to time I guess due to torque demand and them stalling. This is also down to the transitions and the frame that is having to be lugged around with E.R.I.C.

Hopefully these issues can be addressed also when all four legs are working. Worst case however is that I have made a poor choice with the servos and need more powerful ones. Much more likely however is that I can overcome it with a few minor tweaks!


Please log in to post comments.