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

I can't subscribe to /clock topic in C++

asked 2022-08-01 02:44:28 -0600

Baguviks gravatar image

Hello everyone. I need to subscribe to /clock topic to stop my robot when /cmd_vel doesn't receive any message but receive error when i try to do that. Here is my code:

clock_sub_ = nh_.subscribe<rosgraph_msgs::Clock>("clock", &RobotTeleop::clockCallback,this );

And my error is:

error: no matching function for call to ‘ros::NodeHandle::subscribe<rosgraph_msgs::Clock>(const char [6], void (RobotTeleop::*)(), RobotTeleop*)’
   25 | graph_msgs::Clock>("clock", &RobotTeleop::clockCallback,this )
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
1

answered 2022-08-01 07:12:29 -0600

Mike Scheutzow gravatar image

subscribe() takes 4 arguments; you have left out queue_size.

edit flag offensive delete link more

Comments

thank you so much

Baguviks gravatar image Baguviks  ( 2022-08-04 02:58:37 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2022-08-01 02:44:28 -0600

Seen: 177 times

Last updated: Aug 01 '22