Gait Designer

http://webbot.org.uk/iPoint/44.pagegaitRunnerSetDelta() adds an offset rather than a scale - ie it could be used to modify the ankle joint to keep the robot upright when on a slope.

If you just want to scale the output amount then cant you just multiply the resultant DRIVE_SPEED by a scale factor? Or are you trying to scale 'time' as well?

How does it work? Haha - you are asking me to give away my trade secrets...........

The gait runner uses Bezier curves. Each curve has a start point, and end point and two control points that effect the curve. In Gait Designer you can change the view so that these control points are displayed. Assume the points are called 's' (start), 'e' (end), 'c1' (control point 1) and 'c2' (control point 2). To calculate a point along the curve at time 't' (where t is a value between 0 and 1) then the equation is:

(t*t*t)*(3*(c1 - c2) + e - s) + (t*t)*(3*(s-2*c1+c2)) + t*3*(c1 - s) + s

so: if t=0 then the answer is 's' (the start). if t=1 then the answer is 'e' (the end)

If you split the above equation at the '+' signs then you will see that first part is based on time cubed, then time squared, then time and finally it just offsets by the start point. Hence the names - 'cube', 'square', 'time' and start.

Next you will notice that the first 3 parts have values based on the points and are therefore constant. So Gait Designer pre-calculates these and stores them in the MAKE_G8_LIMB_POSITION data.

Finally: you will notice that this limb position only stores the Y value of the start point and not the X value. Why? Well the X value is given by (ie 'is the same as') the start time of the curve stored elsewhere. No point storing in twice.

The next problem is that 't' above represents the time (between 0 and 1) spent travelling along the curve. But in our case the x axis represents elapsed time (ie time since power turned on). So we know what 'x' is - its the time since this curve started - but we don't know what 't' on the curve is. You will therefore see an iterative loop: that keeps guessing 't' until the solved equation gives the correct 'x' value. Now we have got 't' we can solve for 'y' (the amount of limb movement).

In reality each animation is made by stitching several curves together. So given an 'x' value it first has to work out which curve has: curveStartX<= x <=curveEndX. Now it knows which curve - it can use the iterative approach mentioned above to solve for 'y'.