Skip to content

Commit beabfc9

Browse files
authored
Capitalize constexpr variables in direct torque example (UniversalRobots#481)
To satisfy clang-tidy. ROS Industrial CI fails because of this.
1 parent 343e5ca commit beabfc9

2 files changed

Lines changed: 8 additions & 8 deletions

File tree

doc/examples/direct_torque_control.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ The target torque for the controlled joint is computed as a sinusoidal function
9696
:linenos:
9797
:lineno-match:
9898
:start-at: // Open loop control
99-
:end-at: target_torques[JOINT_INDEX] = amplitude * std::sin(omega * time);
99+
:end-at: target_torques[JOINT_INDEX] = AMPLITUDE * std::sin(OMEGA * time);
100100

101101
To send the control command, the robot's :ref:`reverse_interface` is used via the
102102
``writeJointCommand()`` function:

examples/direct_torque_control.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,10 @@ const std::string INPUT_RECIPE = "examples/resources/rtde_input_recipe.txt";
4646
const size_t JOINT_INDEX = 5; // Joint index to control, in this case joint 6 (index 5)
4747

4848
// This example will apply a sinusoidal torque to JOINT_INDEX, while the other joints are kept at 0.0.
49-
constexpr double frequency = 0.2; // [Hz]
50-
constexpr double amplitude = 2.5; // [Nm]
51-
constexpr double omega = 2 * M_PI * frequency;
52-
constexpr double start_position = 0.0; // [rad]
49+
constexpr double FREQUENCY = 0.2; // [Hz]
50+
constexpr double AMPLITUDE = 2.5; // [Nm]
51+
constexpr double OMEGA = 2 * M_PI * FREQUENCY;
52+
constexpr double START_POSITION = 0.0; // [rad]
5353

5454
std::unique_ptr<urcl::ExampleRobotWrapper> g_my_robot;
5555
urcl::vector6d_t g_joint_positions;
@@ -130,7 +130,7 @@ int main(int argc, char* argv[])
130130
throw std::runtime_error(error_msg);
131131
}
132132
// Use motion primitives to move JOINT_INDEX to start position
133-
g_joint_positions[JOINT_INDEX] = start_position;
133+
g_joint_positions[JOINT_INDEX] = START_POSITION;
134134
auto instruction_executor = std::make_shared<urcl::InstructionExecutor>(g_my_robot->getUrDriver());
135135
instruction_executor->optimoveJ(g_joint_positions);
136136

@@ -139,7 +139,7 @@ int main(int argc, char* argv[])
139139
double time = 0.0;
140140

141141
// Run 10 periods of the sinusoidal
142-
while (time < 10 * 2 * M_PI / omega)
142+
while (time < 10 * 2 * M_PI / OMEGA)
143143
{
144144
time += timestep;
145145
// Read latest RTDE package. This will block for a hard-coded timeout (see UrDriver), so the
@@ -160,7 +160,7 @@ int main(int argc, char* argv[])
160160
}
161161

162162
// Open loop control. The target is incremented with a constant each control loop
163-
target_torques[JOINT_INDEX] = amplitude * std::sin(omega * time);
163+
target_torques[JOINT_INDEX] = AMPLITUDE * std::sin(OMEGA * time);
164164

165165
// Setting the RobotReceiveTimeout time is for example purposes only. This will make the example running more
166166
// reliable on non-realtime systems. Use with caution in productive applications. Having it

0 commit comments

Comments
 (0)