bulletphysics / bullet3

Bullet Physics SDK: real-time collision detection and multi-physics simulation for VR, games, visual effects, robotics, machine learning etc.
http://bulletphysics.org
Other
12.62k stars 2.88k forks source link

pybullet resetJointState jitters and disables collision #1746

Closed bzroom closed 5 years ago

bzroom commented 6 years ago

I know it's not ideal to call resetJointState every frame, but i dont know another way.

I'm trying to simulate my robot with urdf multibody. The robot has position sensors on the joints. I'd like to read the joint sensors and then update the multibody representation in bullet.

When i call resetJointState, the joint starts to jitter and it no longer has collision response. I tried to look through the code where this happens but i dont see any reason why it would stop responding to collision. It seems to just do an FK pass and then update the collision world transform. I dont see anywhere that would cause it to clear contacts or something.

Is there any way to override the joint positions in multibody and still have it treat the whole robot with proper dynamics and collision?

To be specific, the root link is not fixed, like the minitar. If you call resetJointState on the minitaur legs i suspect he will fall through the floor.

I thought maybe I could drive the links to positions with torques, but i dont want to apply torque to the system, i just want to "warp" the joints into position with as minimal impact on the chain as possible, creating a sort of hybrid "kinematic/dynamic" body.

I thought it would be ok to use resetJointState because I see it recommended here: https://github.com/bulletphysics/bullet3/blob/master/examples/pybullet/examples/inverse_kinematics_husky_kuka.py#L71

By the way, i'm a long time fan of bullet. :)

Thank you!

erwincoumans commented 5 years ago

You are supposed to use motors (setJointMotorControl2) in position mode. Alternative, pd control. Don't use reset joints, except for when starting/resetting your program.