# Stumped by Servos

I was hoping that someone could give me some guidance with the Minie New6Dof servo motor. I’ve looked at the examples given for regular motors, but unfortunately I still can’t get the servo to work. It is reported as being enabled, but no movement occurs and the joints are still completely loose.

Here’s some example code:

``````for (PhysicsJoint j : physics.getPhysicsSpace().getJointList()) {
if (j instanceof New6Dof){
((New6Dof) j).set(MotorParam.TargetVelocity,4,0.4f);
((New6Dof) j).set(MotorParam.MaxMotorForce,4,2000);
((New6Dof) j).getRotationMotor(1).setServoEnabled(true);

//Outputs true
System.out.println(((New6Dof) j).isServoEnabled(4));
}
}
``````

I assume ServoTarget is an angle expressed in Radians. I’ve messed around with various values for Target velocity and MaxMotorForce (including omitting the lines entirely) as I have no idea what the correct units are. I’m not even sure that they are used in the context of the servo.

By way of background, I’ve modelled a hexapod robot from a collection of RigidBodyControls connected with New6Dofs. After a bit of work, I’ve finally got to the stage of having a working rag doll, with the correct ranges of movement etc and was feeling pretty chuffed!

Would really appreciate any advice, since I can’t find much information on this, other than what’s in the Minie documentation. It would be brilliant if I could get it working though, as it seems to do exactly what I need it to.

1 Like

There’s a servo example here:

I encourage you to experiment with it. Hack away!

1. Yes, all physics-joint rotations are in radians.
2. Max motor force is very important. Start high (like `9e9f`).
3. Target velocity is also important. For rotations, I believe the units are radians per second.
1 Like

Sorry, not sure how I managed to miss this, but it’s exactly what I needed - thanks! Will hack away and see how I get on.

1 Like

Just in case anyone else has the same problem, it looks like setMotorEnabled(true) needs to be called in addition to setServoEnabled in order for the joint to work.

So now I have movement, now I just need to get the movement I want

1 Like