Skip to content

Commit bd4ddd9

Browse files
committed
Made force_mode_example check for robot version
And execute the appropriate startForceMode, depending on version.
1 parent 62bf4d3 commit bd4ddd9

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

examples/force_mode_example.cpp

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -149,14 +149,25 @@ int main(int argc, char* argv[])
149149
}
150150
// Task frame at the robot's base with limits being large enough to cover the whole workspace
151151
// Compliance in z axis and rotation around z axis
152-
153-
bool success = g_my_driver->startForceMode({ 0, 0, 0, 0, 0, 0 }, // Task frame at the robot's base
154-
{ 0, 0, 1, 0, 0, 1 }, // Compliance in z axis and rotation around z axis
155-
{ 0, 0, 0, 0, 0, 0 }, // do not apply any active wrench
156-
2, // do not transform the force frame at all
157-
{ 0.1, 0.1, 1.5, 3.14, 3.14, 0.5 } // limits. See ScriptManual
158-
,
159-
0.8, 0.8); // for details.
152+
bool success;
153+
if (g_my_driver->getVersion().major < 5)
154+
success = g_my_driver->startForceMode({ 0, 0, 0, 0, 0, 0 }, // Task frame at the robot's base
155+
{ 0, 0, 1, 0, 0, 1 }, // Compliance in z axis and rotation around z axis
156+
{ 0, 0, 0, 0, 0, 0 }, // do not apply any active wrench
157+
2, // do not transform the force frame at all
158+
{ 0.1, 0.1, 1.5, 3.14, 3.14, 0.5 } // limits. See ScriptManual
159+
,
160+
0.8); // for details.
161+
else
162+
{
163+
success = g_my_driver->startForceMode({ 0, 0, 0, 0, 0, 0 }, // Task frame at the robot's base
164+
{ 0, 0, 1, 0, 0, 1 }, // Compliance in z axis and rotation around z axis
165+
{ 0, 0, 0, 0, 0, 0 }, // do not apply any active wrench
166+
2, // do not transform the force frame at all
167+
{ 0.1, 0.1, 1.5, 3.14, 3.14, 0.5 } // limits. See ScriptManual
168+
,
169+
0.8, 0.8); // for details.
170+
}
160171
if (!success)
161172
{
162173
URCL_LOG_ERROR("Failed to start force mode.");

0 commit comments

Comments
 (0)