Quantcast
Channel: ROS Answers: Open Source Q&A Forum - RSS feed
Viewing all articles
Browse latest Browse all 417

Why can't I send a string message through my program?

$
0
0
Currently I am trying to build a simple node where I send a `string` using the `std_msgs::String.h` message class. What I do understand is, why I get these particular errors. ##Code ## **Includes:** // NORMAL INCLUDES #include #include #include // ROS INCLUDES #include #include **Declaration:** ros::Publisher command; command = node.advertise("/command", 1); **While loop:** while (ros::ok()) { std::cout << std::endl << std::endl; std::cout << "Type your Command Below:" << std::endl << std::endl; getline(std::cin, input); command.publish(input); } ##Errors ## In file included from /opt/ros/kinetic/include/ros/serialization.h:37:0, from /opt/ros/kinetic/include/ros/publisher.h:34, from /opt/ros/kinetic/include/ros/node_handle.h:32, from /opt/ros/kinetic/include/ros/ros.h:45, from /home/sharan/catkin_ws/src/zlab_drone/src/demo_usr_input.cpp:9: /opt/ros/kinetic/include/ros/message_traits.h: In instantiation of ‘static const char* ros::message_traits::MD5Sum::value(const M&) [with M = std::__cxx11::basic_string]’: /opt/ros/kinetic/include/ros/message_traits.h:255:102: required from ‘const char* ros::message_traits::md5sum(const M&) [with M = std::__cxx11::basic_string]’ /opt/ros/kinetic/include/ros/publisher.h:112:7: required from ‘void ros::Publisher::publish(const M&) const [with M = std::__cxx11::basic_string]’ /home/sharan/catkin_ws/src/zlab_drone/src/demo_usr_input.cpp:45:30: required from here /opt/ros/kinetic/include/ros/message_traits.h:126:34: error: ‘const class std::__cxx11::basic_string’ has no member named ‘__getMD5Sum’ return m.__getMD5Sum().c_str(); ^ /opt/ros/kinetic/include/ros/message_traits.h: In instantiation of ‘static const char* ros::message_traits::DataType::value(const M&) [with M = std::__cxx11::basic_string]’: /opt/ros/kinetic/include/ros/message_traits.h:264:104: required from ‘const char* ros::message_traits::datatype(const M&) [with M = std::__cxx11::basic_string]’ /opt/ros/kinetic/include/ros/publisher.h:112:7: required from ‘void ros::Publisher::publish(const M&) const [with M = std::__cxx11::basic_string]’ /home/sharan/catkin_ws/src/zlab_drone/src/demo_usr_input.cpp:45:30: required from here /opt/ros/kinetic/include/ros/message_traits.h:143:36: error: ‘const class std::__cxx11::basic_string’ has no member named ‘__getDataType’ return m.__getDataType().c_str(); ^ ## String,msg ## [Link is here](http://docs.ros.org/kinetic/api/std_msgs/html/msg/String.html) string data Since they are the same type looking at `String.h`, I do not understand why I am getting this error.

Viewing all articles
Browse latest Browse all 417

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>