ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
With a rosserial client, a ros std_msgs/String data
field is converted to a simple c char array. So my guess is that for you to use ==
, the correct syntax is:
toggle_msg.data[0] == 'M'
The single quotes are important - you are comparing a char, not a string. Also, to avoid a crash, you need to check the string length to make sure it is not 0.
2 | No.2 Revision |
With a rosserial client, a ros std_msgs/String data
field is converted to a simple c char array. So my guess is that for you to use ==
, the correct syntax is:
toggle_msg.data[0] == The single quotes are important - you are comparing a char, not a string. Also, to avoid a crash, you need to check the string length to make sure it is not 0.