Skip to content

Commit 2695b9a

Browse files
authored
Define torque abs value only once (#361)
To make it easier to change the example for manual testing, let's define the target torque's absolute value in one place only.
1 parent 804e75a commit 2695b9a

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

examples/torque_control.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,11 +78,12 @@ int main(int argc, char* argv[])
7878
}
7979
// --------------- INITIALIZATION END -------------------
8080

81-
double cmd_torque = 2.0; // Target torque [Nm] for joint 6
81+
const double torque_abs = 2.5;
82+
double cmd_torque = torque_abs; // Target torque [Nm] for joint 6
8283
bool passed_negative_part = false;
8384
bool passed_positive_part = false;
8485
URCL_LOG_INFO("Start moving the robot");
85-
urcl::vector6d_t target_torques = { 2.0, 0, 0, 0, 0, 0 };
86+
urcl::vector6d_t target_torques = { 0, 0, 0, 0, 0, 0 };
8687

8788
// Once RTDE communication is started, we have to make sure to read from the interface buffer, as
8889
// otherwise we will get pipeline overflows. Therefor, do this directly before starting your main
@@ -114,14 +115,14 @@ int main(int argc, char* argv[])
114115
if (g_joint_positions[JOINT_INDEX] >= 2)
115116
{
116117
passed_positive_part = true;
117-
cmd_torque = -2.0;
118+
cmd_torque = -torque_abs;
118119
}
119120
}
120121
else if (passed_negative_part == false)
121122
{
122123
if (g_joint_positions[JOINT_INDEX] <= 0)
123124
{
124-
cmd_torque = 2.0;
125+
cmd_torque = torque_abs;
125126
passed_negative_part = true;
126127
}
127128
}

0 commit comments

Comments
 (0)