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.49k stars 2.87k forks source link

Why URDFRevoluteJoint has no btMultiBodyJointLimitConstraint in createMultiBody mode in URDF2Bullet.cpp #539

Closed mirsking closed 3 years ago

mirsking commented 8 years ago

Hi, I'm now working on grasp physics simulation using the kinova kg3 gripper.(This gripper has 6 dof, 2 in each finger.) I import the gripper's urdf into bullet ExampleBrower by URDF2Bullet.cpp. Howerer, the simulation is just doesn't make sense. I got things like this. crazy

Then I find in URDF2Bullet.cpp file, URDFRevoluteJoint just doesn't have btMultiBodyJointLimitConstraint, which can have lower and upper limit of joint value.

When I add the constraint in the same way as that in URDFPrismaticJoint, the problem doesn't happy. I don't whether this is a bug.

However, when I add torque into each finger joint by m_multiBody->addJointTorque(joint, force); in stepSimulation. The joint only move a little, while there still are torque add to every joint. The scene is like result And the torque is still not zero like this

current 0 pos: -0.053124
add 0 joint torque: 85.312431
current 1 pos: 0.416667
add 1 joint torque: 38.333332
current 2 pos: -0.000000
add 2 joint torque: 80.000015
current 3 pos: -0.066577
add 3 joint torque: 86.657715
current 4 pos: -0.053124
add 4 joint torque: 85.312431
current 5 pos: 0.416667
add 5 joint torque: 38.333332

Thank you for your help.

erwincoumans commented 8 years ago

Can you fork the latest bullet3 repo and modify/add a demo with your grasp sim + URDF file, and provide a link? Please make it build out-of-the-box similar to the existing Bullet demos, using either premake or cmake. Thanks!

mirsking commented 8 years ago

Hi, I've push my codes here https://github.com/mirsking/bullet3/tree/graspit_demo and there are two commits. The first one is without btMultiBodyJointLimitConstraint in URDFRevoluteJoint, and I've modify URDF2Bullet.cpp to add btMultiBodyJointLimitConstraint for URDFRevoluteJoint in the other commit. Thank you for your help!

erwincoumans commented 8 years ago

I had a look at your example, thanks for sharing. There are many issues, here are a couple: 1) First of all, the collision meshes are way too detailed, and should be simplified a lot (don't reuse visual mesh for collision mesh) 2) You should disable self-collision for the btMultiBody (this could be one of the reasons for torque) 3) It is best to not rely on constraint limits until grasping works well. Just use 'continuous' joints without limits (one more reason to get undesired torques). Use motors instead. 4) It is best to use joint motors to drive the fingers, at least in the beginning. See ImportURDF demo how to do this. Once that works nicely, then consider using other control methods (computed torque + inverse dynamics, or PID control etc) 5) The masses and inertias are extremely small and this will lead to instability. It is best to use larger masses/inertias first, until the grasp works nicely. Once grasping an object works well, then you can adjust to more realistic masses, use double precision, better constraint solver etc.

What is the license of the grasp example and the URDF file? Can it be added to Bullet? I consider creating a working grasp demo, and this seems a nice starting point.

mirsking commented 8 years ago

Thank you for your help. And I'll try with these instructions. I have not decided the license right now. But it can be used freely and in any way you like, and also can be added into Bullet.

benelot commented 8 years ago

Mirsking: Does your gripper work now? In case it is working, we could make an example from it and make a pull request to include it into the Bullet Example Browser. Just tell us when you are ready.

mirsking commented 8 years ago

Sorry, it's not ready yet. since I'm now using baxter gripper for the simulation, I'm not focusing on this gripper. But I think I will try this gripper later, and when it's ok, I will reply here. Thanks for the attentation.