Rubber band constraints

Post Reply
alex2
Posts: 3
Joined: Sun Jul 20, 2014 12:19 pm

Rubber band constraints

Post by alex2 »

Hello all

I am currently porting the simulation module of a visualization application from PhysX to Bullet. All in all I'm pretty happy with the results so far, but I hit a roadblock with constraints.

I am trying to implement a user interaction mode where the user can 'pick up' an object and move it around, as if it was attached with an invisible rubber band to the mouse pointer. I'm doing the usual raycasting to find the impact point on the dynamic rigid body, I am creating a second (invisible) kinematic body which is locked to the mouse pointer (projected on the current manipulation plane) and finally I create a constraint between both. And I am tearing my hairs out here. I have a hard time getting the effect I'm looking for. The fact that btGeneric6DofSpringConstraint is practically undocumented doesn't really help either. And the trial'n'error is really painful.

So I have a btGeneric6DofSpringConstraint between body A (the picked up object) at the point the user picked it (in A's local ref frame) and body B (the kinematic attach point) at its local origin. Body A should be able to move freely on all 6 dof (so all are unlocked and without limits). All linear limits are removed as well (by specifying a very large interval to setLinearLowerLimit/setLinearUpperLimit) as I don't want any artificial linear limits either. The only limit should be the spring pulling A towards B, stronger as the distance between A and B increases. Finally I enable the springs on index 0 to 2, with a trial'n'error'ed stiffness set at 1.

While it 'kind-of' works, Body A is very unstable while being dragged around. It rotates erratically and often takes a long time to stabilize. I am also unable to correctly specify the stiffness of the rubber-spring (only stiffness values around 1 seem to work, lower or higher tend to make the simulation behave very weird). Spring damping value seem to have absolutely zero effect. enabling angular springs on indices 3 to 5 seem to make it even worse.

Any ideas ?

Thanks !

- Alex
alex2
Posts: 3
Joined: Sun Jul 20, 2014 12:19 pm

Re: Rubber band constraints

Post by alex2 »

After some more tinkering around, it looks like the linear components behave correctly, but the rotational components are completely off. Is it possible to apply a stronger damping on the angular components of the underlying 6dof joint, without having angular springs enabled ? The values internally set by setDamping() are only used when the corresponding spring is actually enabled.
alex2
Posts: 3
Joined: Sun Jul 20, 2014 12:19 pm

Re: Rubber band constraints

Post by alex2 »

Alright, I managed to work around the issue by modifying the rotational damping settings in the rigid body itself while it is being interacted with (and restoring the original settings later). Thanks for reading.

As much as Bullet looks great from the limited experience I currently have with it, some more documentation would be incredibly helpful.

Alex
kingchurch
Posts: 28
Joined: Sun May 13, 2012 7:14 am

Re: Rubber band constraints

Post by kingchurch »

The 6DOF spring joint is a soft-constraint based 6DOF constraint to my understanding (see other thread in the forum on the joint limits of this joint). What you need is a point-to-point spring between the cursor and the body under manipulation. You can implement a p2p spring in different ways. For examples:

a. Configure the 6DOF spring joint to lock down all translational DOF and only leave the 3 rotational DOF. Then adjust the relaxation parameters so that the soft ball constraint can give you some elastic lee way.

b. Just implement a spring force element and update the force every step yourself with f = kx
Post Reply