From ed66a7a7d57a20d34a837d8a47b6b7a455fbaadb Mon Sep 17 00:00:00 2001 From: Felix Exner Date: Wed, 16 Jul 2025 09:10:03 +0200 Subject: [PATCH 1/4] Rename torque_command to direct_torque The script command has been renamed in the controller. --- resources/external_control.urscript | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/external_control.urscript b/resources/external_control.urscript index 7b56390c..099894cb 100644 --- a/resources/external_control.urscript +++ b/resources/external_control.urscript @@ -272,9 +272,9 @@ thread torqueThread(): torque = cmd_torque {% if ROBOT_SOFTWARE_VERSION >= v5.22.0 %} # ToDo: Increase to 5.23.0 once released {% if ROBOT_SOFTWARE_VERSION < v6.0.0 %} - torque_command(torque, friction_comp=friction_compensation_enabled) + direct_torque(torque, friction_comp=friction_compensation_enabled) {% elif ROBOT_SOFTWARE_VERSION >= v10.10.0 %} - torque_command(torque, friction_comp=friction_compensation_enabled) + direct_torque(torque, friction_comp=friction_compensation_enabled) {% else %} popup("Torque control is only supported from software 10.10.0 and upwards.", error=True, blocking=True) {% endif %} @@ -692,11 +692,11 @@ thread PDControlThread(): {% if ROBOT_SOFTWARE_VERSION < v6.0.0 %} local tau = pd_controller_gains.kp * q_err - pd_controller_gains.kd * get_actual_joint_speeds() tau = clamp_array(tau, max_joint_torques) - torque_command(tau, friction_comp=friction_compensation_enabled) + direct_torque(tau, friction_comp=friction_compensation_enabled) {% elif ROBOT_SOFTWARE_VERSION >= v10.10.0 %} local tau = pd_controller_gains.kp * q_err - pd_controller_gains.kd * get_actual_joint_speeds() tau = clamp_array(tau, max_joint_torques) - torque_command(tau, friction_comp=friction_compensation_enabled) + direct_torque(tau, friction_comp=friction_compensation_enabled) {% else %} popup("Torque control is only supported from software 10.10.0 and upwards.", error=True, blocking=True) {% endif %} From e571c4d49d28bdc327c164dbe079d2a5abbab6e0 Mon Sep 17 00:00:00 2001 From: Felix Exner Date: Tue, 2 Sep 2025 13:51:35 +0200 Subject: [PATCH 2/4] increase PolyScopeX required version to 10.11 direct_torque is only available from 10.11 on. --- resources/external_control.urscript | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/resources/external_control.urscript b/resources/external_control.urscript index 099894cb..f84defd0 100644 --- a/resources/external_control.urscript +++ b/resources/external_control.urscript @@ -273,10 +273,10 @@ thread torqueThread(): {% if ROBOT_SOFTWARE_VERSION >= v5.22.0 %} # ToDo: Increase to 5.23.0 once released {% if ROBOT_SOFTWARE_VERSION < v6.0.0 %} direct_torque(torque, friction_comp=friction_compensation_enabled) - {% elif ROBOT_SOFTWARE_VERSION >= v10.10.0 %} + {% elif ROBOT_SOFTWARE_VERSION >= v10.11.0 %} direct_torque(torque, friction_comp=friction_compensation_enabled) {% else %} - popup("Torque control is only supported from software 10.10.0 and upwards.", error=True, blocking=True) + popup("Torque control is only supported from software 10.11.0 and upwards.", error=True, blocking=True) {% endif %} {% else %} popup("Torque control is only supported from software 5.23.0 and upwards.", error=True, blocking=True) @@ -693,12 +693,12 @@ thread PDControlThread(): local tau = pd_controller_gains.kp * q_err - pd_controller_gains.kd * get_actual_joint_speeds() tau = clamp_array(tau, max_joint_torques) direct_torque(tau, friction_comp=friction_compensation_enabled) - {% elif ROBOT_SOFTWARE_VERSION >= v10.10.0 %} + {% elif ROBOT_SOFTWARE_VERSION >= v10.11.0 %} local tau = pd_controller_gains.kp * q_err - pd_controller_gains.kd * get_actual_joint_speeds() tau = clamp_array(tau, max_joint_torques) direct_torque(tau, friction_comp=friction_compensation_enabled) {% else %} - popup("Torque control is only supported from software 10.10.0 and upwards.", error=True, blocking=True) + popup("Torque control is only supported from software 10.11.0 and upwards.", error=True, blocking=True) {% endif %} {% else %} popup("Torque control is only supported from software 5.23.0 and upwards.", error=True, blocking=True) From 650c636b1845210491e783e2daff8cec0e75ebe5 Mon Sep 17 00:00:00 2001 From: Felix Exner Date: Wed, 3 Sep 2025 10:06:00 +0200 Subject: [PATCH 3/4] Stop torque_control example after timeout On a simulated robot, torque_control commands don't have any effect. As a result, the torque_control example runs forever when being run on a simulated robot. This commit makes it use the second argument as a timeout after which the example is stopped. If the timeout is hit, it will print a warning stating that this is expected on a simulated robot. This should make the behavior similar to the other examples and make the CI run with that example. --- examples/torque_control.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/examples/torque_control.cpp b/examples/torque_control.cpp index ae885b0b..f8c789e9 100644 --- a/examples/torque_control.cpp +++ b/examples/torque_control.cpp @@ -54,6 +54,13 @@ int main(int argc, char* argv[]) robot_ip = std::string(argv[1]); } + // Parse how many seconds to run + auto second_to_run = std::chrono::seconds(0); + if (argc > 2) + { + second_to_run = std::chrono::seconds(std::stoi(argv[2])); + } + bool headless_mode = true; g_my_robot = std::make_unique(robot_ip, OUTPUT_RECIPE, INPUT_RECIPE, headless_mode, "external_control.urp"); @@ -89,6 +96,7 @@ int main(int argc, char* argv[]) // otherwise we will get pipeline overflows. Therefor, do this directly before starting your main // loop. g_my_robot->getUrDriver()->startRTDECommunication(); + auto start_time = std::chrono::system_clock::now(); while (!(passed_positive_part && passed_negative_part)) { // Read latest RTDE package. This will block for a hard-coded timeout (see UrDriver), so the @@ -140,6 +148,12 @@ int main(int argc, char* argv[]) return 1; } URCL_LOG_DEBUG("data_pkg:\n%s", data_pkg->toString().c_str()); + if (second_to_run.count() > 0 && (std::chrono::system_clock::now() - start_time) > second_to_run) + { + URCL_LOG_WARN("Time limit reached, stopping movement. This is expected on a simualted robot, as it doesn't move " + "to torque commands."); + break; + } } g_my_robot->getUrDriver()->stopControl(); URCL_LOG_INFO("Movement done"); From 0f2424a902d83b4a0fadd684331f2d5ce16d3938 Mon Sep 17 00:00:00 2001 From: Felix Exner Date: Wed, 3 Sep 2025 10:10:54 +0200 Subject: [PATCH 4/4] Increase required PolyScope 5 version to 5.23.0 Now that 5.23.0 is released, we can increase the version requirement properly. --- resources/external_control.urscript | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/external_control.urscript b/resources/external_control.urscript index f84defd0..91070203 100644 --- a/resources/external_control.urscript +++ b/resources/external_control.urscript @@ -270,7 +270,7 @@ thread torqueThread(): textmsg("ExternalControl: Starting torque thread") while control_mode == MODE_TORQUE: torque = cmd_torque - {% if ROBOT_SOFTWARE_VERSION >= v5.22.0 %} # ToDo: Increase to 5.23.0 once released + {% if ROBOT_SOFTWARE_VERSION >= v5.23.0 %} {% if ROBOT_SOFTWARE_VERSION < v6.0.0 %} direct_torque(torque, friction_comp=friction_compensation_enabled) {% elif ROBOT_SOFTWARE_VERSION >= v10.11.0 %} @@ -688,7 +688,7 @@ end thread PDControlThread(): while control_mode == MODE_PD_CONTROLLER_JOINT or control_mode == MODE_PD_CONTROLLER_TASK: local q_err = cmd_servo_q - get_actual_joint_positions() - {% if ROBOT_SOFTWARE_VERSION >= v5.22.0 %} # ToDo: Increase to 5.23.0 once released + {% if ROBOT_SOFTWARE_VERSION >= v5.23.0 %} {% if ROBOT_SOFTWARE_VERSION < v6.0.0 %} local tau = pd_controller_gains.kp * q_err - pd_controller_gains.kd * get_actual_joint_speeds() tau = clamp_array(tau, max_joint_torques)