sensor_msgs::Imu.h causes ROS version mismatch in rosserial_arduino
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
Try with a lower delay time. A second is a bit much.
@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.