rosserial tf and publisher issues

asked 2016-01-23 12:59:26 -0600

AgentNoise gravatar image

When using rosserial tf and just a regular publisher I get the error: "Serial Port read returned short (expected 78 bytes, received 15 instead). [WARN] [WallTime: 1453575297.279503] Serial Port read failure"

If I remove the nh.advertise(pun_range) from the code below it works just fine. Is it not possible to use both at the same time? I would like to be able to publish data from the sensor on a tf topic and a different topic for a non tf node.

/* 
 * rosserial Time and TF Example
 * Publishes a transform at current time
 */

#include <ros.h>
#include <ros/time.h>
#include <tf/transform_broadcaster.h>
#include <sensor_msgs/Range.h>

ros::NodeHandle  nh;

sensor_msgs::Range range_msg;
geometry_msgs::TransformStamped t;
tf::TransformBroadcaster broadcaster;
ros::Publisher pub_range( "/ultrasound", &range_msg);

char base_link[] = "/base_link";
char odom[] = "/odom";

void setup()
{
  nh.initNode();
  nh.advertise(pub_range);
  broadcaster.init(nh);
}

void loop()
{  
  t.header.frame_id = odom;
  t.child_frame_id = base_link;
  t.transform.translation.x = 1.0; 
  t.transform.rotation.x = 0.0;
  t.transform.rotation.y = 0.0; 
  t.transform.rotation.z = 0.0; 
  t.transform.rotation.w = 1.0;  
  t.header.stamp = nh.now();
  broadcaster.sendTransform(t);
  nh.spinOnce();
  delay(10);
}
edit retag flag offensive close merge delete