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

Overload << operator for msg

asked 2015-06-15 01:29:00 -0500

HououinKyouma gravatar image


Simple and maybe stupid question, but is it possible to overload the << operator for ROS messages? When a message is generated this operator is automatically overloaded for them, but I would like to change the way they are printed for plotting purposes.


edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2015-06-15 01:49:38 -0500

ahendrix gravatar image

The C++ compiler only allows one operator overload for each method signature.

If you want to print your messages in a plot-friendly format, you can write a function that converts messages to custom formatted strings, and print those.

You should also investigate the -p option to rostopic echo, to see if it can do what you need: rostopic echo -p /my_topic

edit flag offensive delete link more


I see. I didn't know it was not possible to overload an operator again. The -p option seems useful, but I'm writing my results to a file so I can't use that now. I guess I'll just convert the messages using a function, thanks.

HououinKyouma gravatar image HououinKyouma  ( 2015-06-15 02:26:06 -0500 )edit

Question Tools

1 follower


Asked: 2015-06-15 01:29:00 -0500

Seen: 580 times

Last updated: Jun 15 '15