1
0
mirror of https://gitlab.com/obbart/universal_robots_ros_driver.git synced 2026-04-10 10:00:48 +02:00

Added exception for incorrectly parsed messages.

This commit is contained in:
Tristan Schnell
2019-09-19 13:48:18 +02:00
committed by Felix Mauch
parent 0519866bb4
commit 39afd72e6e

View File

@@ -31,6 +31,7 @@
#include <memory> #include <memory>
#include "ur_rtde_driver/log.h" #include "ur_rtde_driver/log.h"
#include "ur_rtde_driver/types.h" #include "ur_rtde_driver/types.h"
#include "ur_rtde_driver/exceptions.h"
namespace ur_driver namespace ur_driver
{ {
@@ -93,7 +94,10 @@ public:
template <typename T> template <typename T>
T peek() T peek()
{ {
assert(buf_pos_ + sizeof(T) <= buf_end_); if (buf_pos_ + sizeof(T) > buf_end_)
throw UrException("Could not parse received package. This can occur if the driver is started while the robot is "
"booting - please restart the driver once the robot has finished booting. "
"If the problem persists after the robot has booted, please contact the package maintainer.");
T val; T val;
std::memcpy(&val, buf_pos_, sizeof(T)); std::memcpy(&val, buf_pos_, sizeof(T));
return decode(val); return decode(val);