@@ -688,12 +688,14 @@ end
688688thread PDControlThread():
689689 while control_mode == MODE_PD_CONTROLLER_JOINT or control_mode == MODE_PD_CONTROLLER_TASK:
690690 local q_err = cmd_servo_q - get_actual_joint_positions()
691- local tau = pd_controller_gains.kp * q_err - pd_controller_gains.kd * get_actual_joint_speeds()
692- tau = clamp_array(tau, max_joint_torques)
693691 {% if ROBOT_SOFTWARE_VERSION >= v5.23.0 %}
694692 {% if ROBOT_SOFTWARE_VERSION < v6.0.0 %}
693+ local tau = pd_controller_gains.kp * q_err - pd_controller_gains.kd * get_actual_joint_speeds()
694+ tau = clamp_array(tau, max_joint_torques)
695695 torque_command(tau, friction_comp=friction_compensation_enabled)
696696 {% elif ROBOT_SOFTWARE_VERSION >= v10.10.0 %}
697+ local tau = pd_controller_gains.kp * q_err - pd_controller_gains.kd * get_actual_joint_speeds()
698+ tau = clamp_array(tau, max_joint_torques)
697699 torque_command(tau, friction_comp=friction_compensation_enabled)
698700 {% else %}
699701 popup("Torque control is only supported from software 10.10.0 and upwards.", error=True, blocking=True)
@@ -780,8 +782,10 @@ thread script_commands():
780782 friction_compensation_enabled = True
781783 end
782784 elif command == SET_PD_CONTROLLER_GAINS:
785+ {% if ROBOT_SOFTWARE_VERSION > v5.10.0 %}
783786 pd_controller_gains.kp = [raw_command[2] / MULT_jointstate, raw_command[3] / MULT_jointstate, raw_command[4] / MULT_jointstate, raw_command[5] / MULT_jointstate, raw_command[6] / MULT_jointstate, raw_command[7] / MULT_jointstate]
784787 pd_controller_gains.kd = [raw_command[8] / MULT_jointstate, raw_command[9] / MULT_jointstate, raw_command[10] / MULT_jointstate, raw_command[11] / MULT_jointstate, raw_command[12] / MULT_jointstate, raw_command[13] / MULT_jointstate]
788+ {% endif %}
785789 elif command == SET_MAX_JOINT_TORQUES:
786790 max_joint_torques = [raw_command[2] / MULT_jointstate, raw_command[3] / MULT_jointstate, raw_command[4] / MULT_jointstate, raw_command[5] / MULT_jointstate, raw_command[6] / MULT_jointstate, raw_command[7] / MULT_jointstate]
787791 end
0 commit comments