lucasw / simple_sim_ros

Minimally featured but fast ROS physics simulation wrapping bullet
GNU General Public License v3.0
43 stars 11 forks source link

support kinematic objects #23

Open lucasw opened 5 years ago

lucasw commented 5 years ago

mass is zero, but need to setCollisonFlags CF_KINEMATIC_OBJECT and setActivationState(DISABLE_DEACTIVATE)

lucasw commented 5 years ago

C) Kinematic objects, which are objects without mass, but the user can move them. There is on-way interaction, and Bullet calculates a velocity based on the timestep and previous and current world transform. Bullet automatically deactivates dynamic rigid bodies, when the velocity is below a threshold for a given time. Deactivated (sleeping) rigid bodies don't take any processing time, except a minor broadphase collision detection impact (to allow active objects to activate/wake up sleeping objects)

https://pybullet.org/Bullet/BulletFull/classbtRigidBody.html

This seems to be saying that setLinearVelocity won't work (but maybe it used to, searches are conflicting), and the position should be updated instead?

Others suggest a sub-classed motion state is required.

Simply setting a new transform every update seems too slow- that would happen at the slower external update rate, rather than the internal high speed physics update- so would an object be making abrupt jerks instead of moving smoothly, and interactions with contacting objects will be fouled up?

lucasw commented 5 years ago

It looks like the best method is to use the dynamics world setInternalTickCallback and have the callback loop through all the rigid bodies and update the world transforms of those that are kinematic. The dynamics will properly derive the velocity from these fine step position updates, getLinearVel will return the time as desired.

bulletphysics/bullet3#1204

lucasw commented 5 years ago

Next support angular velocities.

lucasw commented 5 years ago

Need to initialize the kinematic linear vel to 0 0 0

lucasw commented 5 years ago

Need a service to set the position of a kinematic object (works equally well for dynamic objects also?)- setWorldTransform on them.