V-REP : balance behavior

A first test with a balance behavior using an IMU with V-REP. Not totally efficient, but could be a starting point.
http://nbviewer.ipython.org/github/jjehl/poppy_balance/blob/master/test_balance_2.ipynb

All comments are welcome.

2 Likes

Really nice work!

Iā€™ve tried your code on my machine (where v-rep is relatively fast) and itā€™s quite working! If I understand your code correctly, you are trying to do a sort of a PID controller on the abs motors depending on the movement of the head. Is it correct?

Will you try to add other motors for the balance? For instance, I guess the arm could be really useful.

Iā€™m just thinking, but it would be really nice to setup a v-rep scene where we can easily tune random perturbation and use it as a bench for balance behaviour test! I know you can define ā€œimaginaryā€ force in v-rep, that could be a nice way to better tune the perturbations.

Hi Pierre,

Thank you.

Yes, it is the idea

The method can be adapt to other motors easily

The difficulty is to know what is expected. In the example, the expected bahavior is that there isnā€™t any move, so it is easy to correct with a reference. But for more complex behavior, you can have movement so you have to compare the real movement with the expected movement to make pid correction. And to know the expected movement can be a little bit difficult (for walking on a soft ground for exampleā€¦) but not impossible !

Sure, ramdom perturbation can be an interesting way. At the moment I have ever problems with the speed of V-REP on my computer, so I think I will spend some time to reduce the mesh of poppy model in V-REP (like explained in your [CFC])

Have a nice day, see you soon.

1 Like

Random force apply on the chest with a lua script :
random_force _lua.txt (771 Bytes)

Now, Iā€™m going to work on a method using the arms to restore the balance.

1 Like

A new test with the arms to balance the movement in a V-rep tunned scene with a random force on poppyā€™s chest.

The code here and the v-rep tuned scene poppy-humanoid_add_force.ttt.

1 Like

Thatā€™s really nice work @juju ! Iā€™ll definitely try to run some experiments using your setup. See if explauto and curiosity driven learning can come with interesting solutions!

Just 2 comments:

  • First, it would be great to be able to pragmatically trigger the random force (and why not have an argument to specify their amplitude). Iā€™ll try to look into that when I have time.
  • Second, you can specify a specific v-rep scene at instantiation and thus have multiple scenes available. All you need to do is something like:

poppy = PoppyHumanoid(simulator=ā€˜vrepā€™, scene=ā€˜pat_to_my_other_scene.tttā€™)

Yes, it is possible with the function simxgetfloatsignal or something like that, I gonna look for.

Right, I have to change thatā€¦

I have just add methods to my code to take in account the position and the acceleration and it is not easy to calibrate the system ! Another things I noticed, looking at poppy falling down, is that when moving the arms two forces are in action : the gravity and an inertial force created by the movement and the problem is that these two forces act in opposite direction.
I mean at very early stage, moving the arms in the opposite direction of the fall create an inertial force which increase the fall even if the gravity center is deplaced to balance the fallā€¦

Explauto seems to be very interesting. Before to dive into, I just would like to test another method to balance poppy using the present_load of differents motors. I wonder if this present_load could be a useful sensor to calibrate balance behavior.

Sorry, there was a mistake with rotation matrix which made some results very strange. It is now corrected.

Static movement :

Movements with balance correction :


Lots of things could be improve, like the correction that is proportionnal, maybe exponential could be better, and the calibration between acceleration, speed and position is choose only with few testā€¦

Hi Pierre,

What level of control on the force do you want ? Different things can be done like to choose :
_ The amplitude in each direction
_ The position where the force act on the shape
_ The shape where the force is apply

For me the position on the shape not really usefull but amplitude and shape could be great.

The API function simaddforce have no equivalent in the remote API but it is possible to send parameters to a child script to tune the force. For this, the remote api function simxsettringsignal have to be implemented in pypot. I think it is not. So I think it is possible to implemented the function at robot level (like simxgetobjectorientation for exemple).

For example, the code to send values to child script is :

force = [50,50,50]
packedData=vrep.simxPackFloats(force)
raw_bytes = (ctypes.c_ubyte * len(packedData)).from_buffer_copy(packedData)   
returnCode=vrep.simxSetStringSignal(clientID, "force", raw_bytes, vrep.simx_opmode_oneshot)

Thatā€™s sounds good. Can you also control the direction ?

You can have a look at the get_simulation_current_time method to see how you can do that. In this case itā€™s a get float, but I guess the set should be rather similar.

Hello,

I added a function set_VREP_force to tunned the force (pull request opened). You can choose the shape and a force vector (x,y,z) that means direction and power.
Example of utilisation here.

I added also a new VREP scene poppy_humanoid_add_force.ttt which is needed to receive the signal from set_VREP_force (pull request on branche simplify_meshes of poppy_humanoid)

Have a good sunny day :sunny:

A new test on a balance behavior in V-REP using the value of motor register : present_load.
This short test show that the present_load could be a good sensor for balancing poppy. Another advantage is that you can have the present_load for all the motors, so a lot of sensor values !

In this test, poppy is bending his knee and keep the balance with his ankle. Very hard to do for a real human :smile:

The code here, any suggestion or remark is welcome.

See you.

2 Likes

Really interesting! However, this will hardly be transposable to the real robot. The present_load value on the robotis motors is extremely noisy :frowning:

The present_load is also noisy in V-REP :

But with a filter, it is possible to extract interesting informations. Is it totally unusable on a real motor ?
Anyway, something like a force sensor on each articulation could be really useful to keep the balance, especially for the leg.

Actually, is there a way to know the torque apply to a motor ?

The use of present_load on four motors : ankle and hip to balance a knee movement : balance flexion (code here)

The balance of poppy is very sensitive to the position of ankle, because poppy is relatively tall in regards of his feet size !
I think a good torque control on motors could be a way to balance poppy.

Here the monitoring of the filtered present_load during the movement :

The behavior is also dependant of the PID parameter you choose for the correction. Another try changing the PID correction (large increase of Integrated correction).

3 Likes

A new way to move the leg with calcul of angle. Thanks to this forum, now I know that this is called inverse kinematics. This means : you set the high and the foot gap of poppy and the class calcul the angle of ankle, knee and hip. High (%) ā†’ angles (degrees). For example the next sequence in video :

time.sleep(1)
leg.speed=3
leg.high_percent=50
leg.r_foot_gap_percent=20
leg.l_foot_gap_percent=-20
leg.start()
time.sleep(3)
leg.high_percent=100
leg.r_foot_gap_percent=-1
leg.l_foot_gap_percent=-1
leg.start()
time.sleep(3)
leg.high_percent=0
leg.start()
time.sleep(3)
leg.high_percent=80
leg.r_foot_gap_percent=-20
leg.l_foot_gap_percent=20
leg.start()
time.sleep(3)
leg.r_foot_gap_percent=-1
leg.l_foot_gap_percent=-1
leg.high_percent=0
leg.start()
time.sleep(3)
leg.high_percent=100
leg.r_foot_gap_percent=0
leg.l_foot_gap_percent=0
leg.start()
time.sleep(3)

As Manon could says, it is mainly a pedagogical example because it works only on a flat and horizontal floor : code
But, it could be used to teach trigonometry.

Enjoy your day.

3 Likes