Accessing the 'Control Policy' in Reachy

Hello. I’ve been trying to access the underlying ‘control policy’ for the reachy. Essentially, I’ve been trying to implement gravity compensation for the PID controller. However, I cannot see where the ‘torque’ commands are being generated for the controller. I need help understanding how the joint PID gains are being utilized. Are they being used to directly modify the motor PID gains, or are they used to generate torque values? I’d be grateful for any help in this matter.

Hello @danyalsaqib !

To clarify how the control policy and PID gains are utilized in Reachy’s motor control:

  1. Torque Generation and Control:
    Direct torque control is not feasible with Reachy’s default setup. The torque limit can be adjusted, but controlling the motors in torque mode is not supported out of the box.

  2. Utilizing PID Gains for Motor Control:
    The joint PID gains are primarily used to adjust the behavior of the PID controller associated with each motor. By default, Reachy sets a proportional gain (P) for each joint. For instance, the default PID tuple for each joint is (32.0, 0.0, 0.0), where only the proportional gain (P) is configured.

  3. Modifying PID Settings:
    You can experiment with modifying the PID settings using the Python SDK. For example, you can set a new PID tuple such as (64.0, 32.0, 0.0) for specific joints like r_elbow_pitch. However, it’s recommended to be cautious when adjusting these parameters:

    • Increase PID values gradually to avoid introducing oscillations or instability.
    • Avoid setting a non-zero derivative gain (D) unless necessary, as it can lead to motor oscillations.
  4. Setting PID Values:
    Note that the PID values are written into the RAM of the motor. Therefore, if you turn off the motors, you’ll need to reset the PID values each time you restart Reachy.

  5. Documentation and Further Resources:
    Here is a link to the documentation of the motors used with Reachy, which might provide additional insights : Motor Documentation

Experimenting with different PID configurations can help fine-tune Reachy’s control behavior according to your specific requirements.

Best of luck with your implementation, and let me know if there’s anything else I can assist you with!