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

Revision history [back]

For Q1, see #q205541 and the link to this page therein. In short: in msg/srv definition you need to use float64 as this is a "ROS built-in type". Those are used to autogenerate the code for different languages. In C++ use double.

Q2: this is expected behavior, as you are now using C++. This is, double is a C++ primitive type, whereas string is not. Use std::string instead. No fault with QTCreator there.

For Q1, see #q205541 and the link to this page therein. In short: in msg/srv definition you need to use float64 as this is a "ROS built-in type". Those are used to autogenerate the code for different languages. In C++ use double.

Q2: this is expected behavior, as you are now using C++. This is, double is a C++ primitive type, whereas string is not. Use std::string instead. No fault with QTCreator there.


Edit:

std::string is the C++ string type, whereas std_msgs::String is the C++ representation of a ROS standard message that only contains a string (ROS built-in type) / std::string (C++ type) as a field. Check the std_msgs/String message definition here.

I.e., manipulating the respective data field of the std_msgs::String with c_str() will work.

E.g. (using std::strings empty() method for sake of brevity)

std_msgs::String string_msg;
std::string cpp_string;
cpp_string.empty(); // compiles
string_msg.empty();  // does not compile
string_msg.data.empty(); // compiles