Page 1 of 1

Hexapod Orientation

Posted: 06 Dec 2016, 08:58
by w720

I'm using reinforcement learning to teach Lyal Randell's hexapod model to walk. I'm using a single threaded script, with no Non-threaded script (this is different from Randell).

The feet use inverse kinematics to move with the function:
simMoveToPosition(whichLeg, -1 , FormerPosition + DisplacementVector, {0,0,0},vel, accel)

To shift the base to the center of the legs, I use:
simMoveToPosition(legBase,antBase,A_Displacement_Vector, {0,0,0},vel,accel)

However, after I run the simulation for a little while, the hexapod base always gets more and more angled ( I don't call any function that should affect the angle of the base -- for each step all I do is have a foot tip lift up and go back down to 0 height but with a different x and y location. Then I move the base center to the average of the leg positions. It has something to do with orientation, because if I print out the legBase and antBase orientation, the numbers move more and more away from zero as the robot keeps taking steps, until the robot collapses.

I don't understand how the orientation aspect of simMoveToPostion works. I've tried using -1 instead of antBase, and testing out calls to this function with test values, and it seems to act strange and non-predictable. I don't quite understand how the base, legBase, or antBase move when using simMoveToPosition. Is the orientation a displacement vector or is it absolute orientation? Is there anyway I could reorient the base to make it parallel to the floor? That's really all I need is a function to correct for the angle and just set the base orientation to be parallel with the floor. Then I would just call it after each foot step.

I saw in the forums that maybe I should try to change the IK constraints for each foot target dummy to alpha and beta in addition to the x,y,z but that didn't help.

This bug is killing me, since the reinforcement learning seems to be doing great if it weren't for this one bug.

Thanks so much for listening, Hope someone has an idea what this is.

Re: Hexapod Orientation

Posted: 07 Dec 2016, 12:32
by coppelia

can you post the scene? This way it will be easier for us to find your bug.


Re: Hexapod Orientation

Posted: 08 Dec 2016, 13:05
by w720

It would be difficult to follow along the whole code because it's so long. The only part that is changing the position of the base is when I call "simMoveToPosition(legBase, antBase, {some vector}, {0,0,0}, vel, accel)".

If I wanted to move the hexapod's base up maybe .05 without moving the legs, would I call "simMoveToPosition(legBase, antBase,{0,0,.05}, {0,0,0}, vel, accel)" ? What if I wanted to rotate the base around the z-axis without the legs moving? And does moving antBase with respect to the world do anything? I'm just confused about the whole relation between antBase and legBase in this CAD model, and how moving one controls the hexapod base's position and orientation. I've been experimenting with these function calls, and haven't had much success figuring it out.

I would greatly appreciate it if you would be able to explain a little how it works.

Thank you so much,

Re: Hexapod Orientation

Posted: 10 Dec 2016, 15:29
by coppelia

in the case of that model (take the hexapod1.ttm model file) the robot base (or center platform) is only indirectly moved via the leg's movement. So if you wanted to rotate the center platform around its own axes, then you would have to rotate the 6 IK foot targets around a vertical axis. This is difficult to describe with words. The best would be to disabled the code in that attached child script from line 97 down, just after walkingVel=0.9.

Now the robot will simply stay immobile.

Now select the dummy hexa_legBase and rotate it around its own Z-axis: the robot's center platform will rotate (while the 3 legs keep the same contact points).
Now select the dummy hexa_legBase and shift it around: the robot's center platform will be shifted (while the 3 legs keep the same contact points).

The walking motion is very similar, with the difference that all 6 legs will go through a movement sequence one after the other. But when trying to control the hexpod robot, just think in terms of moving the hexa_legBase dummy (the contact points of the legs to the floor will stay same), or moving the various hexa_footTarget dummies around.