Hello!,
I'm working with arduino and ros and i'm reading a value of a sensor and, that value is publish in a topic, i'm trying to create a Subscriber who heard the message that the topic is sending, actully i wrote a .cpp file:
#include "ros/ros.h"
#include "std_msgs/String.h"
void chatterCallback(const std_msgs::String::ConstPtr& msg)
{
ROS_INFO("I heard: [%s]", msg->data.c_str());
}
int main(int argc, char **argv)
{
ros::init(argc, argv, "listener");
ros::NodeHandle n;
ros::Subscriber sub = n.subscribe("chatter", 500, chatterCallback);
ros::spin();
return 0;
}
but the problem is that the value that i'm reading from the topic of arduino is a float32 value and my listener reads only string values, i try to change the code but when i do make it gives me an error.... If i change the value that the topic gives to me to an string value the listener works ok.
someone could help me???
Originally posted by joseescobar60 on ROS Answers with karma: 172 on 2012-11-13
Post score: 0
Original comments
Comment by Lorenz on 2012-11-13:
Please make sure you read http://ros.org/wiki/Support If you are getting errors, please put the corresponding code and complete error output in your question.