The API function and joint dynamic properties of force control and position control for a primastic joint

The API function and joint dynamic properties of force control and position control for a primastic joint

Posted: 30 Jul 2018, 12:09

by biscuit122

Hi, can you help me to distinguish the difference between force control and position control for a primastic joint?
I calculate the force to control a primastic joint. Can I use sim.setJointTargetPosition in script? How should I set the joint dynamic properties?( including motor enabled, control properties and so on.)
Otherwise, if I calculate a displacement to control a primastic joint. Which API function I should use? How shoud I set the joint dynamic properties?

Re: The API function and joint dynamic properties of force control and position control for a primastic joint

Posted: 31 Jul 2018, 06:52

by coppelia

Hello,

if your joint is in force/torque mode, your motor enabled and the control loop disabled, then you can adjust your joint's behaviour with sim.setJointForce: the joint will apply the specified force/torque until the target velocity has been reached. You can adjust the target velocity with sim.setJointTargetVelocity. If you need your joint to apply the force/torque in opposite direction, you should inverse the joint's target velocity.

if your joint is in force/torque mode, your motor enabled and the control loop is enabled and Position control (PID) checked, then your can adjust your joint's position with sim.setJointTargetPosition. If you want to write your own joint controller (be it in position, force/torque, damping, etc.), then your joint should be configured that way. In addition, you will have to use a joint callback function: it will allow you to implement virtually any type of controller.

Cheers

Re: The API function and joint dynamic properties of force control and position control for a primastic joint

if your joint is in force/torque mode, your motor enabled and the control loop disabled, then you can adjust your joint's behaviour with sim.setJointForce: the joint will apply the specified force/torque until the target velocity has been reached. You can adjust the target velocity with sim.setJointTargetVelocity. If you need your joint to apply the force/torque in opposite direction, you should inverse the joint's target velocity.

if your joint is in force/torque mode, your motor enabled and the control loop is enabled and Position control (PID) checked, then your can adjust your joint's position with sim.setJointTargetPosition. If you want to write your own joint controller (be it in position, force/torque, damping, etc.), then your joint should be configured that way. In addition, you will have to use a joint callback function: it will allow you to implement virtually any type of controller.

Cheers

Thank you for your help. I want to control the primastic joint to move along a sin function including positive and negative diretion. How can I make a setting?

Re: The API function and joint dynamic properties of force control and position control for a primastic joint

Posted: 03 Aug 2018, 05:55

by coppelia

Here a very simple example:

set your joint in force/torque mode, enable the motor and the control loop.
Then attach a threaded child script to the joint with following code: