ros::NodeHandle::advertise<<expression error>>
I am reading book(Robot Operating System for Absolute Beginners Robotics Programming Made Easy) and do it in unbuntu 20.04. In Chapter 5 programming with ROS Creating a ROS C++ Node in which i am getting error ros::Publisher chatter_pub = n.advertise<std_msgs::string>("chatter", 1000);
/catkin_ws/src/hello_world/src/talker.cpp:12:43: error: ‘std_’ was not declared in this scope; did you mean ‘std’? ros::Publisher chatter_pub = n.advertise<std_< p="">
/catkin_ws/src/hello_world/src/talker.cpp:12:33: error: parse error in template argument list ros::Publisher chatter_pub = n.advertise<std_msgs::string>("chatter", 1000);
/catkin_ws/src/hello_world/src/talker.cpp:13:31: error: no matching function for call to ‘ros::NodeHandle::advertise<<expression error=""> >(const char [8], int)’
msgs::String>("chatter", 1000);
In file included from /opt/ros/noetic/include/ros/ros.h:45,
from /catkin_ws/src/hello_world/src/talker.cpp:1:
/opt/ros/noetic/include/ros/node_handle.h:249:15: note: candidate: ‘template<class m=""> ros::Publisher ros::NodeHandle::advertise(const string&, uint32_t, bool)’
Hi @Raiz Ahmed,
Can you post the code here? It may be the data type you used. Remember that you need the proper headers:
#include "std_msgs/String.h"
and declarationros::Publisher chatter_pub = n.advertise<std_msgs::String>("chatter", 1000);
Note the capitalize data type String.Nevertheless, I will recommend you the following tutorial for your particular problem: ROS C++ publisher.
Hi @Weasfas, Thank you for your reply ..i am resolved this issue.
Great!
If you do not mind, can you post your solution as answer to let others with the same problem know how you solved it?
Thanks =)