morse-simulator / morse

The Modular OpenRobots Simulation Engine
http://morse-simulator.github.io/
Other
356 stars 156 forks source link

Force/Torque sensors for for armatures #445

Open kargm opened 11 years ago

kargm commented 11 years ago

This is a meta-issue to investigate the possibility of having force/torque sensors for armatures. This could e.g. be useful to measure physical forces on robot arms when pushing boxes when collisions occur.

flixr commented 11 years ago

Not only for armatures, it would already be nice to have a force sensor which you could attach to body/robot with rigid body dynamics. It is possible to get the force from the Bullet physics engine, however it seems the python API does currently not allow reading it: http://www.blender.org/documentation/blender_python_api_2_69_0/bge.types.KX_GameObject.html?highlight=getreactionforce#bge.types.KX_GameObject.getReactionForce

flixr commented 11 years ago

In my naivety I first thought that quickly implementing getReactionForce by simply calling getTotalForce from Bullet would be sufficient.

Of course it's not that simple... All that getTotalForce does, is give you the sum of the forces you applied in this step so far (e.g. reading it after using the MORSE force actuators will give you the summed up forces). Reading it before you applied any forces returns zero (as of course makes sense in hindsight). Also applying impulses (or you have collisions) directly modifies the linear/angular velocity of the physics object and it is not reflected in the getTotalForce.

Hence this is not really useful, especially for MORSE sensors since they are executed before the actuators -> you will always read zero there.

What should probably be done instead (in Blender):

However I'm a bit at a loss on where to implement this in Blender... still trying to figure out how/when the Physics engine get's updated so that the appropriate states can be saved at the right time for the calculation of getReactionForce later...

severin-lemaignan commented 11 years ago

Probably irrelevant, but did you check occurences' of Bullet's getAppliedImpulse method? grep getAppliedImpulse in Blender source has a few hits (including Python interface).

flixr commented 11 years ago

Looks to me that you can only use getAppliedImpulse on physics constraints. While this might be useful for armatures (never used/needed them), I'm currently looking for a force "feedback" for rigid body objects.