ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

sensor_msgs::Imu.h causes ROS version mismatch in rosserial_arduino

asked 2020-03-07 23:12:25 -0500

aytimothy gravatar image

updated 2020-03-08 18:36:35 -0500

I've been following the Simple Subscriber and am wanting to send IMU data over rosserial. I'm using an Arduino UNO.

So starting with the base code they gave, I started with:

// #define USE_USBCON

#include <ros.h>
#include <std_msgs/String.h>

ros::NodeHandle nh;

std_msgs::String str_msg;
ros::Publisher chatter("chatter", &str_msg);

void setup() {
  nh.initNode();
  nh.advertise(chatter);
}

void loop() {
  str_msg.data = hello;
  chatter.publish(&str_msg);
  nh.spinOnce();
  delay(1000);
}

This worked as-is. However, I want to send IMU messages instead. This was when I got this:

So instead of std_msgs::String str_msg;, it was sensor_msgs::Imu imu_msg;.

[ERROR] [xxxx]: Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino

So, I un-commented #define USE_USBCON. This spewed errors like iostream not existing. Turns out that #define USE_USBCON has to go after <ros/ros.h>. This still resulted in the above message, but now I'm getting:

[ERROR] [xxxx] Message from device dropped: message larger than buffer.

At this point, I referred to this question and:

  • #define BUFFER_SIZE
  • Changing the byte values in ros.h/ros/node_handle.h

However, now I'm just getting:

[ERROR] [xxxx]: Unable to sync with device; possible link problem or link software version mismatch such as hydro rosserial_python with groovy Arduino

The code at this point, just looks like:

#define USE_USBCON

#include <ros.h>
#include <sensor_msgs/Imu.h>

ros::NodeHandle nh;

sensor_msgs::Imu imu_msg;
ros::Publisher chatter("chatter", &imu_msg);

void setup() {
  nh.initNode();
  nh.advertise(chatter);
}

void loop() {
  imu_msg.orientation.x = 0;
  imu_msg.orientation.y = 0;
  imu_msg.orientation.z = 0;
  imu_msg.angular_velocity.x = 0;
  imu_msg.angular_velocity.y = 0;
  imu_msg.angular_velocity.z = 0;
  imu_msg.linear_acceleration.x = 0;
  imu_msg.linear_acceleration.y = 0;
  imu_msg.linear_acceleration.z = 0;  
  chatter.publish(&imu_msg);
  nh.spinOnce();
  delay(1000);
}

It's also worth noting that sometimes it does:

[INFO] [xxxx] wrong checksum for topic id and msg
edit retag flag offensive close merge delete

Comments

1

Try with a lower delay time. A second is a bit much.

gvdhoorn gravatar image gvdhoorn  ( 2020-03-08 06:39:48 -0500 )edit

@gvdhoom Doesn't make any difference in terms of whether it works or not; tried it without any delay. This is just test code anyway. Thanks for the suggestion, even though I've already tried it.

aytimothy gravatar image aytimothy  ( 2020-03-08 07:05:18 -0500 )edit

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-03-08 16:06:06 -0500

I changed the buffer values in ros.h to

#elif defined(__AVR_ATmega328P__)

  typedef NodeHandle_<ArduinoHardware, 25, 25, 10, 550, FlashReadOutBuffer_> NodeHandle;

so that there is enough buffer to send the message.

To get the ide to recompile so it uses those values (it doesn't always recognise a change in the library) I change the name of a variable in the main code to trigger a recompile, and then it works.

The code you have posted also does not compile for me:

sensor_msgs/Imu.h imu_msg;

needs to be

sensor_msgs::Imu imu_msg;

and I removed the USBCON define

edit flag offensive delete link more

Comments

Whoops, thanks for spotting my mistake.. Must've been a copy error with the class definition. Unfortunately increasing that buffer size still results in the mismatch error. Could it be something wrong with the libraries? (Even though I've already remade the libraries several times)

aytimothy gravatar image aytimothy  ( 2020-03-09 04:00:19 -0500 )edit

have you changed the values in ros.h, not in node_handle.h, and remove or comment out the USBCON line at the top ?

What version of ROS are you using, and which Arduino library and version.

I would try removing the Arduino library and reinstalling it, to put the files back in a known state, which should get you back to the buffer size issue, then try a single change in ros.h to the buffer sizes.

nickw gravatar image nickw  ( 2020-03-10 04:59:18 -0500 )edit

Sorry for taking a long time to reply - Was busy with a lot of other things. So I'm using Kinetic (see tags), and I've reinstalled the library several times. I've already double-checked and the changes are in ros.h, not node_handle.h, which haven't touched at all.

aytimothy gravatar image aytimothy  ( 2020-03-12 19:42:31 -0500 )edit

Question Tools

Stats

Asked: 2020-03-07 22:48:43 -0500

Seen: 320 times

Last updated: Mar 08 '20