Complete the code to create a ROS publisher that publishes messages on the 'chatter' topic.
ros::Publisher pub = nh.[1]<std_msgs::String>("chatter", 1000);
The advertise function creates a publisher for a topic in ROS.
Complete the code to subscribe to the 'chatter' topic with a callback function.
ros::Subscriber sub = nh.[1]("chatter", 1000, chatterCallback);
The subscribe function creates a subscriber to listen to messages on a topic.
Fix the error in the publisher loop to publish messages correctly.
std_msgs::String msg; msg.data = "hello world"; [1].publish(msg);
The publisher object is usually named pub and is used to send messages.
Fill both blanks to create a subscriber with a callback and queue size.
ros::Subscriber sub = nh.[1]("sensor_data", [2], sensorCallback);
Use subscribe to listen to a topic and set the queue size to 10 for buffering messages.
Fill all three blanks to create a publisher, publish a message, and spin the node.
ros::Publisher [1] = nh.[2]<std_msgs::String>("status", 1000); std_msgs::String msg; msg.data = "running"; [3].publish(msg); ros::spin();
We create a publisher named pub using advertise, then publish the message with pub.publish(msg).
