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

Revision history [back]

I have run into a similar problem where the rosserial node is unable to process the sensor_msgs/Imu messages. Here is the original arduino code.

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

ros::NodeHandle  nh;
sensor_msgs::Imu imu_msg;
sensor_msgs::Range range_msg;
ros::Publisher pub_imu( "/imu/data", &imu_msg);
ros::Publisher pub_ran( "/range/test", &range_msg);

void setup()
{ 
  //Serial.begin(9600);
  nh.initNode();
  nh.advertise(pub_imu);
  nh.advertise(pub_ran);
}
void loop()
{
   imu_msg.header.frame_id =  "/imu";
   imu_msg.header.stamp = nh.now();

  pub_imu.publish(&imu_msg);
  pub_ran.publish(&range_msg);
  nh.spinOnce();    

}

Before the node crashes I am able to see an out put via rostopic echo for the test range message, but for the imu/data message just hangs.

fsros@rossvr1:~/sketchbook/libraries/ros_lib$ rosrun rosserial_python serial_node.py /dev/ttyACM0
[INFO] [WallTime: 1344267287.400171] ROS Serial Python Node
[INFO] [WallTime: 1344267287.402094] Connected on /dev/ttyACM0 at 57600 baud
[INFO] [WallTime: 1344267290.351637] Note: publish buffer size is 512 bytes
[INFO] [WallTime: 1344267290.351881] Setup publisher on /imu/data [sensor_msgs/Imu]
[INFO] [WallTime: 1344267290.354571] Setup publisher on /range/test [sensor_msgs/Range]
[INFO] [WallTime: 1344267468.723670] Packet Failed :  Failed to read msg data
Traceback (most recent call last):
  File "/home/fsros/ros_workspace/rosserial/rosserial_python/nodes/serial_node.py", line 58, in <module>
    client.run()
  File "/home/fsros/ros_workspace/rosserial/rosserial_python/src/rosserial_python/SerialClient.py", line 284, in run
    self.callbacks[topic_id](msg)
  File "/home/fsros/ros_workspace/rosserial/rosserial_python/src/rosserial_python/SerialClient.py", line 95, in handlePacket
    m.deserialize(data)
  File "/opt/ros/electric/stacks/common_msgs/sensor_msgs/src/sensor_msgs/msg/_Imu.py", line 190, in deserialize
    raise roslib.message.DeserializationError(e) #most likely buffer underfill
roslib.message.DeserializationError: unpack requires a string argument of length 72