Skip to content

Commit 1ee3eab

Browse files
authored
Rename torque_command to direct_torque (#362)
The script command has been renamed in the controller.
1 parent b1036b5 commit 1ee3eab

File tree

2 files changed

+24
-10
lines changed

2 files changed

+24
-10
lines changed

examples/torque_control.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,13 @@ int main(int argc, char* argv[])
5454
robot_ip = std::string(argv[1]);
5555
}
5656

57+
// Parse how many seconds to run
58+
auto second_to_run = std::chrono::seconds(0);
59+
if (argc > 2)
60+
{
61+
second_to_run = std::chrono::seconds(std::stoi(argv[2]));
62+
}
63+
5764
bool headless_mode = true;
5865
g_my_robot = std::make_unique<urcl::ExampleRobotWrapper>(robot_ip, OUTPUT_RECIPE, INPUT_RECIPE, headless_mode,
5966
"external_control.urp");
@@ -89,6 +96,7 @@ int main(int argc, char* argv[])
8996
// otherwise we will get pipeline overflows. Therefor, do this directly before starting your main
9097
// loop.
9198
g_my_robot->getUrDriver()->startRTDECommunication();
99+
auto start_time = std::chrono::system_clock::now();
92100
while (!(passed_positive_part && passed_negative_part))
93101
{
94102
// 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[])
140148
return 1;
141149
}
142150
URCL_LOG_DEBUG("data_pkg:\n%s", data_pkg->toString().c_str());
151+
if (second_to_run.count() > 0 && (std::chrono::system_clock::now() - start_time) > second_to_run)
152+
{
153+
URCL_LOG_WARN("Time limit reached, stopping movement. This is expected on a simualted robot, as it doesn't move "
154+
"to torque commands.");
155+
break;
156+
}
143157
}
144158
g_my_robot->getUrDriver()->stopControl();
145159
URCL_LOG_INFO("Movement done");

resources/external_control.urscript

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -270,13 +270,13 @@ thread torqueThread():
270270
textmsg("ExternalControl: Starting torque thread")
271271
while control_mode == MODE_TORQUE:
272272
torque = cmd_torque
273-
{% if ROBOT_SOFTWARE_VERSION >= v5.22.0 %} # ToDo: Increase to 5.23.0 once released
273+
{% if ROBOT_SOFTWARE_VERSION >= v5.23.0 %}
274274
{% if ROBOT_SOFTWARE_VERSION < v6.0.0 %}
275-
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)
275+
direct_torque(torque, friction_comp=friction_compensation_enabled)
276+
{% elif ROBOT_SOFTWARE_VERSION >= v10.11.0 %}
277+
direct_torque(torque, friction_comp=friction_compensation_enabled)
278278
{% else %}
279-
popup("Torque control is only supported from software 10.10.0 and upwards.", error=True, blocking=True)
279+
popup("Torque control is only supported from software 10.11.0 and upwards.", error=True, blocking=True)
280280
{% endif %}
281281
{% else %}
282282
popup("Torque control is only supported from software 5.23.0 and upwards.", error=True, blocking=True)
@@ -688,17 +688,17 @@ end
688688
thread 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-
{% if ROBOT_SOFTWARE_VERSION >= v5.22.0 %} # ToDo: Increase to 5.23.0 once released
691+
{% if ROBOT_SOFTWARE_VERSION >= v5.23.0 %}
692692
{% if ROBOT_SOFTWARE_VERSION < v6.0.0 %}
693693
local tau = pd_controller_gains.kp * q_err - pd_controller_gains.kd * get_actual_joint_speeds()
694694
tau = clamp_array(tau, max_joint_torques)
695-
torque_command(tau, friction_comp=friction_compensation_enabled)
696-
{% elif ROBOT_SOFTWARE_VERSION >= v10.10.0 %}
695+
direct_torque(tau, friction_comp=friction_compensation_enabled)
696+
{% elif ROBOT_SOFTWARE_VERSION >= v10.11.0 %}
697697
local tau = pd_controller_gains.kp * q_err - pd_controller_gains.kd * get_actual_joint_speeds()
698698
tau = clamp_array(tau, max_joint_torques)
699-
torque_command(tau, friction_comp=friction_compensation_enabled)
699+
direct_torque(tau, friction_comp=friction_compensation_enabled)
700700
{% else %}
701-
popup("Torque control is only supported from software 10.10.0 and upwards.", error=True, blocking=True)
701+
popup("Torque control is only supported from software 10.11.0 and upwards.", error=True, blocking=True)
702702
{% endif %}
703703
{% else %}
704704
popup("Torque control is only supported from software 5.23.0 and upwards.", error=True, blocking=True)

0 commit comments

Comments
 (0)