From e0201002f64db88581269fe105c710d7e0b22af7 Mon Sep 17 00:00:00 2001 From: Felix Mauch Date: Tue, 11 Jun 2019 17:52:58 +0200 Subject: [PATCH] introduced VersionInformation Use this as a data container to store version information in. --- .../rtde/get_urcontrol_version.h | 3 ++ .../include/ur_rtde_driver/rtde/rtde_client.h | 7 ++++ .../include/ur_rtde_driver/ur/ur_driver.h | 1 + .../ur_rtde_driver/ur/version_information.h | 36 +++++++++++++++++++ .../src/rtde/get_urcontrol_version.cpp | 8 ++--- ur_rtde_driver/src/rtde/rtde_client.cpp | 11 ++++-- 6 files changed, 60 insertions(+), 6 deletions(-) create mode 100644 ur_rtde_driver/include/ur_rtde_driver/ur/version_information.h diff --git a/ur_rtde_driver/include/ur_rtde_driver/rtde/get_urcontrol_version.h b/ur_rtde_driver/include/ur_rtde_driver/rtde/get_urcontrol_version.h index a562ce1..17e30d0 100644 --- a/ur_rtde_driver/include/ur_rtde_driver/rtde/get_urcontrol_version.h +++ b/ur_rtde_driver/include/ur_rtde_driver/rtde/get_urcontrol_version.h @@ -29,6 +29,7 @@ #define UR_RTDE_DRIVER_GET_URCONTROL_VERSION_H_INCLUDED #include "ur_rtde_driver/rtde/rtde_package.h" +#include "ur_rtde_driver/ur/version_information.h" namespace ur_driver { @@ -43,6 +44,8 @@ public: virtual bool parseWith(comm::BinParser& bp); virtual std::string toString() const; + VersionInformation version_information_; + uint32_t major_; uint32_t minor_; uint32_t bugfix_; diff --git a/ur_rtde_driver/include/ur_rtde_driver/rtde/rtde_client.h b/ur_rtde_driver/include/ur_rtde_driver/rtde/rtde_client.h index fda5956..f85be7b 100644 --- a/ur_rtde_driver/include/ur_rtde_driver/rtde/rtde_client.h +++ b/ur_rtde_driver/include/ur_rtde_driver/rtde/rtde_client.h @@ -62,6 +62,11 @@ public: return max_frequency_; } + VersionInformation getVersion() + { + return urcontrol_version_; + } + private: comm::URStream stream_; std::vector recipe_; @@ -69,6 +74,8 @@ private: comm::URProducer prod_; comm::Pipeline pipeline_; + VersionInformation urcontrol_version_; + double max_frequency_; constexpr static const double CB3_MAX_FREQUENCY = 125.0; diff --git a/ur_rtde_driver/include/ur_rtde_driver/ur/ur_driver.h b/ur_rtde_driver/include/ur_rtde_driver/ur/ur_driver.h index 6f63429..a376286 100644 --- a/ur_rtde_driver/include/ur_rtde_driver/ur/ur_driver.h +++ b/ur_rtde_driver/include/ur_rtde_driver/ur/ur_driver.h @@ -31,6 +31,7 @@ #include "ur_rtde_driver/comm/reverse_interface.h" #include "ur_rtde_driver/comm/script_sender.h" #include "ur_rtde_driver/ur/tool_communication.h" +#include "ur_rtde_driver/primary/robot_message/version_message.h" namespace ur_driver { diff --git a/ur_rtde_driver/include/ur_rtde_driver/ur/version_information.h b/ur_rtde_driver/include/ur_rtde_driver/ur/version_information.h new file mode 100644 index 0000000..88d74c9 --- /dev/null +++ b/ur_rtde_driver/include/ur_rtde_driver/ur/version_information.h @@ -0,0 +1,36 @@ +// this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- + +// -- BEGIN LICENSE BLOCK ---------------------------------------------- +// -- END LICENSE BLOCK ------------------------------------------------ + +//---------------------------------------------------------------------- +/*!\file + * + * \author Felix Mauch mauch@fzi.de + * \date 2019-06-11 + * + */ +//---------------------------------------------------------------------- + +#ifndef UR_RTDE_DRIVER_UR_VERSION_INFORMATION_H_INCLUDED +#define UR_RTDE_DRIVER_UR_VERSION_INFORMATION_H_INCLUDED + +namespace ur_driver +{ +struct VersionInformation +{ + VersionInformation() + { + major = 0; + minor = 0; + bugfix = 0; + build = 0; + } + uint32_t major; + uint32_t minor; + uint32_t bugfix; + uint32_t build; +}; +} // namespace ur_driver + +#endif // ifndef UR_RTDE_DRIVER_UR_VERSION_INFORMATION_H_INCLUDED diff --git a/ur_rtde_driver/src/rtde/get_urcontrol_version.cpp b/ur_rtde_driver/src/rtde/get_urcontrol_version.cpp index 586662f..5b4dfc7 100644 --- a/ur_rtde_driver/src/rtde/get_urcontrol_version.cpp +++ b/ur_rtde_driver/src/rtde/get_urcontrol_version.cpp @@ -33,10 +33,10 @@ namespace rtde_interface { bool GetUrcontrolVersion::parseWith(comm::BinParser& bp) { - bp.parse(major_); - bp.parse(minor_); - bp.parse(bugfix_); - bp.parse(build_); + bp.parse(version_information_.major); + bp.parse(version_information_.minor); + bp.parse(version_information_.bugfix); + bp.parse(version_information_.build); return true; } diff --git a/ur_rtde_driver/src/rtde/rtde_client.cpp b/ur_rtde_driver/src/rtde/rtde_client.cpp index fa64ceb..e8b1ea5 100644 --- a/ur_rtde_driver/src/rtde/rtde_client.cpp +++ b/ur_rtde_driver/src/rtde/rtde_client.cpp @@ -26,6 +26,7 @@ //---------------------------------------------------------------------- #include "ur_rtde_driver/rtde/rtde_client.h" +#include "ur_rtde_driver/exceptions.h" namespace ur_driver { @@ -73,9 +74,15 @@ bool RTDEClient::init() size = GetUrcontrolVersionRequest::generateSerializedRequest(buffer); stream_.write(buffer, size, written); pipeline_.getLatestProduct(package, std::chrono::milliseconds(1000)); - rtde_interface::GetUrcontrolVersion* tmp_control_version = + rtde_interface::GetUrcontrolVersion* tmp_urcontrol_version = dynamic_cast(package.get()); - if (tmp_control_version->major_ < 5) + + if (tmp_urcontrol_version == nullptr) + { + throw UrException("Could not get urcontrol version from robot. This should not happen!"); + } + urcontrol_version_ = tmp_urcontrol_version->version_information_; + if (urcontrol_version_.major < 5) { max_frequency_ = CB3_MAX_FREQUENCY; }