mirror of
https://gitlab.com/obbart/universal_robots_ros_driver.git
synced 2026-04-10 01:50:46 +02:00
throw exception when tool communication is requested for CB3
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#define UR_RTDE_DRIVER_EXCEPTIONS_H_INCLUDED
|
||||
|
||||
#include <stdexcept>
|
||||
#include <sstream>
|
||||
|
||||
namespace ur_driver
|
||||
{
|
||||
@@ -40,5 +41,33 @@ public:
|
||||
private:
|
||||
/* data */
|
||||
};
|
||||
|
||||
class VersionMismatch : public UrException
|
||||
{
|
||||
public:
|
||||
explicit VersionMismatch() : VersionMismatch("", 0, 0)
|
||||
{
|
||||
}
|
||||
explicit VersionMismatch(const std::string& text, const uint32_t version_req, const uint32_t version_actual)
|
||||
: std::runtime_error(text)
|
||||
{
|
||||
version_required_ = version_req;
|
||||
version_actual_ = version_actual;
|
||||
std::stringstream ss;
|
||||
ss << text << "(Required version: " << version_required_ << ", actual version: " << version_actual_ << ")";
|
||||
text_ = ss.str();
|
||||
}
|
||||
virtual ~VersionMismatch() = default;
|
||||
|
||||
virtual const char* what() const noexcept override
|
||||
{
|
||||
return text_.c_str();
|
||||
}
|
||||
|
||||
private:
|
||||
uint32_t version_required_;
|
||||
uint32_t version_actual_;
|
||||
std::string text_;
|
||||
};
|
||||
} // namespace ur_driver
|
||||
#endif // ifndef UR_RTDE_DRIVER_EXCEPTIONS_H_INCLUDED
|
||||
|
||||
@@ -82,9 +82,16 @@ ur_driver::UrDriver::UrDriver(const std::string& robot_ip, const std::string& sc
|
||||
prog.replace(prog.find(SERVER_IP_REPLACE), SERVER_IP_REPLACE.length(), local_ip);
|
||||
prog.replace(prog.find(SERVER_PORT_REPLACE), SERVER_PORT_REPLACE.length(), std::to_string(reverse_port));
|
||||
|
||||
auto urcontrol_version = rtde_client_->getVersion();
|
||||
|
||||
std::stringstream begin_replace;
|
||||
if (tool_comm_setup != nullptr)
|
||||
{
|
||||
if (urcontrol_version.major < 5)
|
||||
{
|
||||
throw VersionMismatch("This robot version does not support using the tool communication interface.", 5,
|
||||
urcontrol_version.major);
|
||||
}
|
||||
begin_replace << "set_tool_voltage("
|
||||
<< static_cast<std::underlying_type<ToolVoltage>::type>(tool_comm_setup->getToolVoltage()) << ")\n";
|
||||
begin_replace << "set_tool_communication("
|
||||
|
||||
Reference in New Issue
Block a user