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

Revision history [back]

You could definitely decompose the sting messages with regular expressions.

Or, you could use a different message data type that has a float container.

Or, you could write your own message type.

Or, you could use the float message.

http://ros.org/doc/api/sensor_msgs/html/msg/ChannelFloat32.html

You could definitely decompose the sting messages with regular expressions.

Or, you could use a different message data type that has a float container.

Or, you could write your own message type.

Or, you could use the float message.

http://ros.org/doc/api/sensor_msgs/html/msg/ChannelFloat32.html


Have you done the ROS tutorials? If not, I recommend you do so. ROS is a complicated system, and you need to really grasp the concepts before you attempt coding. It is very important you understand what a Message is, and how to use them.

However, to answer your question, it depends on how you are modifying it. For the float message, you will need to add to the top of your code the following line.

#include <sensor_msgs/ChannelFloat32>

Now, you can change the function to read

void floatCallback(const sensor_msgs::ChannelFloat32::ConstPtr& float_msg)

and that should work.