@@ -270,7 +270,17 @@ thread torqueThread():
270270 textmsg("ExternalControl: Starting torque thread")
271271 while control_mode == MODE_TORQUE:
272272 torque = cmd_torque
273+ {% if ROBOT_SOFTWARE_VERSION >= v5.23.0 %}
274+ {% if ROBOT_SOFTWARE_VERSION < v6.0.0 %}
273275 torque_command(torque, friction_comp=friction_compensation_enabled)
276+ {% elif ROBOT_SOFTWARE_VERSION >= v10.10.0 %}
277+ torque_command(torque, friction_comp=friction_compensation_enabled)
278+ {% else %}
279+ popup("Torque control is only supported from software 10.10.0 and upwards.", error=True, blocking=True)
280+ {% endif %}
281+ {% else %}
282+ popup("Torque control is only supported from software 5.23.0 and upwards.", error=True, blocking=True)
283+ {% endif %}
274284 end
275285 textmsg("ExternalControl: torque thread ended")
276286 stopj(STOPJ_ACCELERATION)
678688thread PDControlThread():
679689 while control_mode == MODE_PD_CONTROLLER_JOINT or control_mode == MODE_PD_CONTROLLER_TASK:
680690 local q_err = cmd_servo_q - get_actual_joint_positions()
691+ {% if ROBOT_SOFTWARE_VERSION >= v5.23.0 %}
692+ {% 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)
695+ torque_command(tau, friction_comp=friction_compensation_enabled)
696+ {% elif ROBOT_SOFTWARE_VERSION >= v10.10.0 %}
681697 local tau = pd_controller_gains.kp * q_err - pd_controller_gains.kd * get_actual_joint_speeds()
682698 tau = clamp_array(tau, max_joint_torques)
683699 torque_command(tau, friction_comp=friction_compensation_enabled)
700+ {% else %}
701+ popup("Torque control is only supported from software 10.10.0 and upwards.", error=True, blocking=True)
702+ {% endif %}
703+ {% else %}
704+ popup("Torque control is only supported from software 5.23.0 and upwards.", error=True, blocking=True)
705+ {% endif %}
684706 end
685707 textmsg("PD Control thread ended")
686708 stopj(STOPJ_ACCELERATION)
@@ -760,8 +782,10 @@ thread script_commands():
760782 friction_compensation_enabled = True
761783 end
762784 elif command == SET_PD_CONTROLLER_GAINS:
785+ {% if ROBOT_SOFTWARE_VERSION > v5.10.0 %}
763786 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]
764787 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 %}
765789 elif command == SET_MAX_JOINT_TORQUES:
766790 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]
767791 end
0 commit comments