I am attempting to simulate a gimbaled rocket nozzle using a ConeTwistConstraint. This is how I set it up:
self.cone = BulletConeTwistConstraint(self.rocketNP.node(), self.rocketNozzle.node(), frameA, frameB) self.cone.enableMotor(1) self.cone.setMaxMotorImpulse(1) self.cone.setDamping(100) self.cone.setDebugDrawSize(2.0) self.cone.setLimit(20, 20, 0, softness=0.1, bias=3.0, relaxation=8.0) self.world.attachConstraint(self.cone)
This is how I control the motor every frame:
force = Vec3(0, 0, 0) if inputState.isSet('forward'): force.setX(1) if inputState.isSet('reverse'): force.setX(-1) if inputState.isSet('left'): force.setY(-1) if inputState.isSet('right'): force.setY( 1) force *= -20.0/180.0*math.pi self.rocketNozzle.node().setActive(True) force = rot.from_euler('zyx',force).as_quat() self.cone.setMotorTarget(LQuaternionf(force,force,force,force))
Controlling the motor seems to work fine. However the nozzle quickly starts jittering around and won’t st, especially when trying to go back to the center position. I tried to smoothen the movement by adjusting the dampening, the max motor impulse and by adjusting the limit parameters, but I don’t really understand how they work. I imagine MaxMotorImpulse to define the strength of the motor and dampening to - well - dampen the movement of the joint but when playing with the values I cannot make out any changes in its behaviour.
And I couldn’t find any info on how softness, bias and relaxation work, I don’t quite understand them from palying around either. It would be nice if you could tell me more
Thanks in advance!