This is what I've got from the manual so far:
- Check 'motor enabled' in the motor properties.
- Set the desired target velocity. When the joint has its motor enabled and the control loop is disabled, then it acts in velocity control. If we don't have any target velocity then this should be set to a reasonably large value.
- Control the motor force/torque through sim.setJointForce.
In my case, I want to control the motor in both directions. However, I've troubles to overcome the velocity control.
One workaround is based on the fact that even if the velocity has a sign, the maximum force/torque is an absolute value. So my guess is that I could do something like:
Is my guess correct? Is this the right thing to do or there is a better way?
Code: Select all
# max_velocity is a fixed positive value # desired_forceis a variable that could be positive or negative if desired_force < 0: jointTargetVelocity <- -max_velocity jointForce <- -desired_force else jointTargetVelocity <- max_velocity jointForce <- desired_force endif