How does ctrlrange work with position actuators?

Discussion in 'Priority support' started by Ethan Brooks, Jun 7, 2018.

  1. Since position actuators specify positions on a joint, I would assume that the range of legal values, and therefore an appropriate ctrlrange, would be the range of the joint. However, when I clamp the ctrlrange to the same values as the joint range, the joint barely moves at all. So what would be a good value to use to determine the range of inputs to the position actuator?
     
    Kyokushin likes this.
  2. Emo Todorov

    Emo Todorov Administrator Staff Member

    ctrlrange always specifies the allowed range of ctrl, regardless of the actuator type. It would make sense to define it to be equal to the joint range, but this is up to you, it is not done automatically.

    Note also that joint ranges are converted to radians after compilation, while ctrl and ctrlrange specify raw values and are not converted. So if the model uses degrees and the joint range is (0, 180), the joint range after compilation would be (0, pi) and so the corresponding ctrlrange should be defined as (0, pi).

    The above assumes that the gear ratio is 1. If you change it, then it affects the computation as follows. The actuator length is the joint angle times the gear ratio. For a position actuator, ctrl specifies the reference position for the actuator length (and not directly for the joint angle). So if you prefer position actuators to work in degrees, set gear="57.29577951". Now your ctrl and ctrlrange have the meaning of degrees.
     
    Kyokushin likes this.
  3. Emo,
    Thank you for the response. That really helps and appears to work well for hinge joints. For some reason, I am getting strange results with slide joints: using the joints limits as the ctrlrange restricts movement too much. Do slide joints work differently?

    Here are the xml files, in case you want to look.
     

    Attached Files:

  4. Emo Todorov

    Emo Todorov Administrator Staff Member

    For slide joints, the joint range is in meters - both in the definition of the joint, and for ctrlrange for position actuators attached to the joint. The values you entered are quite small, which is why the range is limited.