From bd4ddd91e3612b201060c57e5ea36ec61d6879fc Mon Sep 17 00:00:00 2001 From: URJala Date: Wed, 10 Jul 2024 08:48:12 +0000 Subject: [PATCH] Made force_mode_example check for robot version And execute the appropriate startForceMode, depending on version. --- examples/force_mode_example.cpp | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/examples/force_mode_example.cpp b/examples/force_mode_example.cpp index 409ff590..fa3713bc 100644 --- a/examples/force_mode_example.cpp +++ b/examples/force_mode_example.cpp @@ -149,14 +149,25 @@ int main(int argc, char* argv[]) } // Task frame at the robot's base with limits being large enough to cover the whole workspace // Compliance in z axis and rotation around z axis - - bool success = g_my_driver->startForceMode({ 0, 0, 0, 0, 0, 0 }, // Task frame at the robot's base - { 0, 0, 1, 0, 0, 1 }, // Compliance in z axis and rotation around z axis - { 0, 0, 0, 0, 0, 0 }, // do not apply any active wrench - 2, // do not transform the force frame at all - { 0.1, 0.1, 1.5, 3.14, 3.14, 0.5 } // limits. See ScriptManual - , - 0.8, 0.8); // for details. + bool success; + if (g_my_driver->getVersion().major < 5) + success = g_my_driver->startForceMode({ 0, 0, 0, 0, 0, 0 }, // Task frame at the robot's base + { 0, 0, 1, 0, 0, 1 }, // Compliance in z axis and rotation around z axis + { 0, 0, 0, 0, 0, 0 }, // do not apply any active wrench + 2, // do not transform the force frame at all + { 0.1, 0.1, 1.5, 3.14, 3.14, 0.5 } // limits. See ScriptManual + , + 0.8); // for details. + else + { + success = g_my_driver->startForceMode({ 0, 0, 0, 0, 0, 0 }, // Task frame at the robot's base + { 0, 0, 1, 0, 0, 1 }, // Compliance in z axis and rotation around z axis + { 0, 0, 0, 0, 0, 0 }, // do not apply any active wrench + 2, // do not transform the force frame at all + { 0.1, 0.1, 1.5, 3.14, 3.14, 0.5 } // limits. See ScriptManual + , + 0.8, 0.8); // for details. + } if (!success) { URCL_LOG_ERROR("Failed to start force mode.");