Complete the code to initialize a ROS node named 'robot_controller'.
ros::init(argc, argv, [1]);The ros::init function requires the node name as a string literal, so it must be in quotes.
Complete the code to create a ROS publisher for topic 'chatter' with message type std_msgs::String.
ros::Publisher pub = nh.advertise<std_msgs::String>([1], 1000);
The topic name must be a string literal, so it needs quotes around it.
Fix the error in the ROS subscriber callback signature to accept a shared pointer to the message.
void chatterCallback(const std_msgs::String::ConstPtr& [1]) {The conventional variable name for the message pointer in ROS callbacks is msg.
Fill both blanks to create a ROS service server named 'add_two_ints' with callback function 'add'.
ros::ServiceServer service = nh.advertiseService([1], [2]);
The service name must be a string literal, and the callback is the function name without quotes.
Fill all three blanks to create a ROS node that publishes 'Hello ROS' every second.
ros::NodeHandle nh; ros::Publisher pub = nh.advertise<std_msgs::String>([1], 10); ros::Rate loop_rate([2]); while (ros::ok()) { std_msgs::String msg; msg.data = [3]; pub.publish(msg); ros::spinOnce(); loop_rate.sleep(); }
The topic name is 'chatter' as a string, the loop rate is 1 Hz, and the message data is the string 'Hello ROS'.
