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

Added verification of RT message length for firmware versions 1.6 to 3.2

This commit is contained in:
Thomas Timm Andersen
2015-12-03 11:29:21 +01:00
parent 3402db3348
commit a3e174626c
2 changed files with 24 additions and 13 deletions

View File

@@ -60,7 +60,6 @@ RobotStateRT::~RobotStateRT() {
pMsg_cond_->notify_all(); pMsg_cond_->notify_all();
} }
void RobotStateRT::setDataPublished() { void RobotStateRT::setDataPublished() {
data_published_ = false; data_published_ = false;
} }
@@ -75,7 +74,6 @@ bool RobotStateRT::getControllerUpdated() {
return controller_updated_; return controller_updated_;
} }
double RobotStateRT::ntohd(uint64_t nf) { double RobotStateRT::ntohd(uint64_t nf) {
double x; double x;
nf = be64toh(nf); nf = be64toh(nf);
@@ -321,16 +319,28 @@ void RobotStateRT::unpack(uint8_t * buf) {
offset += sizeof(len); offset += sizeof(len);
len = ntohl(len); len = ntohl(len);
if (version_ > 3. & version_ < 3.1 & len != 1044) {
//In 3.0, every 4th? package is malformed...? //Check the correct message length is received
//printf("Len: %i\n", len); bool len_good = true;
val_lock_.unlock(); if (version_ >= 1.6 && version_ < 1.7) { //v1.6
return; if (len != 756)
len_good = false;
} else if (version_ >= 1.7 && version_ < 1.8) { //v1.7
if (len != 764)
len_good = false;
} else if (version_ >= 1.8 && version_ < 1.9) { //v1.8
if (len != 812)
len_good = false;
} else if (version_ >= 3.0 && version_ < 3.2) { //v3.0 & v3.1
if (len != 1044)
len_good = false;
} else if (version_ >= 3.2 && version_ < 3.3) { //v3.2
if (len != 1060)
len_good = false;
} }
if (version_ > 1.8 & version_ < 1.9 & len != 812) { if (!len_good) {
// In 1.8.14035, every 17th and 18th package is 560 and 9 bytes long/malformed. printf("Wrong length of message on RT interface: %i\n", len);
//printf("Len: %i\n", len);
val_lock_.unlock(); val_lock_.unlock();
return; return;
} }

View File

@@ -30,6 +30,7 @@ UrDriver::UrDriver(std::condition_variable& rt_msg_cond,
struct sockaddr_in serv_addr; struct sockaddr_in serv_addr;
int n, flag; int n, flag;
firmware_version_ = 0;
reverse_connected_ = false; reverse_connected_ = false;
executing_traj_ = false; executing_traj_ = false;
rt_interface_ = new UrRealtimeCommunication(rt_msg_cond, host, rt_interface_ = new UrRealtimeCommunication(rt_msg_cond, host,