Programmatic Set Point for free joint

Discussion in 'Modeling' started by Florian, Oct 6, 2017.

  1. Is there a way to programatically change the spring damper reference frame of a free joint, online during simulation ?

    The documentation states the following:

    Spring reference pose
    This is the pose in which all joint and tendon springs achieve their restring length. Spring forces are generated when the joint configuration deviates from the spring reference pose, and are linear in the amount of deviation. The spring reference pose is saved in mjModel.qpos_spring. For slide and hinge joints, the spring reference is specified with the attribute springref. For ball and free joints, the spring reference corresponds to the initial model configuration.,
    My interpretation of this is that what I aim to do, cannot be done?
     
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    You can change the elements of qpos0 corresponding to a free or ball joint in mjModel at runtime. The documentation is talking about what you can do via the XML model. But there is much more you can do at runtime by writing code. Just be careful when you are changing quaternion quantities: they need to be unit quaternions.
     
  3. I am currently trying to realize a cartesian impedance controller, which realizes the behaviour of a 6-Dof Spring between a virtual set-point and a point attached to a physical object. I have tried to realize this using the control callback in combination with d->xfrc_applied (applying a wrench based on the spring damper offset). Unfortunately I was unable to get a stable behavior for my spring damper system. Another apporach I am thinking of is to modify qpos0 of a free-joint spring damper at runtime. However the control callback protects the model m (const) from modifications.

    I would appreciate any hints torwards being able to realize this kind of behavior.
    Kind regards!