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

Revision history [back]

The issue is that the three fields you are trying to print are defines as uint8 in C++, those are of type uint8_t... The output operator (<<)is treating this type like a char.

Does the following fix your issue?

ROS_INFO_STREAM(std::setprecision ( 0 ) << " color=(" << +msg.r << " , " << +msg.b << " , " << +msg.g << " ) ");

Read more here:

  • http://wiki.ros.org/msg
  • https://stackoverflow.com/questions/19562103/uint8-t-cant-be-printed-with-cout

The issue is that the three fields you are trying to print are defines defined as uint8 in the message. In C++, those are of type uint8_t... The , and the output operator (<<)is ) is treating this type like a char.

Does the following fix your issue?

ROS_INFO_STREAM(std::setprecision ( 0 ) << " color=(" << +msg.r << " , " << +msg.b << " , " << +msg.g << " ) ");

Read more here:

  • http://wiki.ros.org/msg
  • https://stackoverflow.com/questions/19562103/uint8-t-cant-be-printed-with-cout