ros::NodeHandle::advertise<<expression error>>

asked 2020-07-14 12:20:37 -0500

Raiz Ahmed gravatar image

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)’

edit retag flag offensive close merge delete

Comments

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 declaration ros::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.

Weasfas gravatar image Weasfas  ( 2020-07-14 13:18:58 -0500 )edit

Hi @Weasfas, Thank you for your reply ..i am resolved this issue.

Raiz Ahmed gravatar image Raiz Ahmed  ( 2020-07-16 07:04:33 -0500 )edit

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 =)

Weasfas gravatar image Weasfas  ( 2020-07-16 12:24:02 -0500 )edit