Skip to content

Commit e1dd6f0

Browse files
committed
Add function to check / specify version requirements for a script command
1 parent 087c461 commit e1dd6f0

File tree

2 files changed

+36
-1
lines changed

2 files changed

+36
-1
lines changed

include/ur_client_library/control/script_command_interface.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131

3232
#include "ur_client_library/control/reverse_interface.h"
3333
#include "ur_client_library/ur/tool_communication.h"
34+
#include "ur_client_library/ur/version_information.h"
3435

3536
namespace urcl
3637
{
@@ -235,6 +236,25 @@ class ScriptCommandInterface : public ReverseInterface
235236
SET_MAX_JOINT_TORQUES = 9, ///< Set max joint torques
236237
};
237238

239+
/*!
240+
* \brief Checks if the robot version is higher than the minimum required version for Polyscope 5
241+
* or Polyscope X.
242+
*
243+
* If the robot version is lower than the minimum required version, this function
244+
* will log a warning message.
245+
* In case of a PolyScope 5 robot, the robot's software version will be checked against \p
246+
* min_polyscope5, and in case of a PolyScope X robot, it will be checked against \p
247+
* min_polyscopeX.
248+
*
249+
* \param min_polyscope5 Minimum required version for PolyScope 5
250+
* \param min_polyscopeX Minimum required version for PolyScope X
251+
* \param command_name Name of the command being checked, used for logging
252+
*
253+
* \returns True if the robot version is higher than the versions provided, false otherwise.
254+
*/
255+
bool robotVersionSupportsCommandOrWarn(const VersionInformation& min_polyscope5,
256+
const VersionInformation& min_polyscopeX, const std::string& command_name);
257+
238258
bool client_connected_;
239259
static const int MAX_MESSAGE_LENGTH = 28;
240260

src/control/script_command_interface.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,6 +356,21 @@ void ScriptCommandInterface::messageCallback(const socket_t filedescriptor, char
356356
nbytesrecv);
357357
}
358358
}
359+
bool ScriptCommandInterface::robotVersionSupportsCommandOrWarn(const VersionInformation& min_polyscope5,
360+
const VersionInformation& min_polyscopeX,
361+
const std::string& command_name)
362+
{
363+
if (robot_software_version_ < min_polyscope5 ||
364+
(robot_software_version_.major > 5 && robot_software_version_ < min_polyscopeX))
365+
{
366+
URCL_LOG_WARN("%s is only available for robots with PolyScope %s / %s or "
367+
"later. This robot's version is %s. This command will have no effect.",
368+
command_name.c_str(), min_polyscope5.toString().c_str(), min_polyscopeX.toString().c_str(),
369+
robot_software_version_.toString().c_str());
370+
return false;
371+
}
372+
return true;
373+
}
359374

360375
} // namespace control
361-
} // namespace urcl
376+
} // namespace urcl

0 commit comments

Comments
 (0)