The hints under the heading Data for Excercice 2.2 is the best place to start! Here is summarizing what you need to do (and leaving you to do it ):
- You need to publish to another topic. The code was publishing to
/counter but now it needs to publish to
ros::Publisher pub = nh.advertise<std_msgs::Int32>("counter", 1000);
- You need to use a different message for the
/cmd_vel topic. As they say, different strokes for different folks…The challenge here is you need to (similar to what we have in the code block below):
- Figure out the kind of message
- Include it in place of
- Create and initialize a message of that type, setting the right parameters.
- Publish the message.
std_msgs::Int32 count; // Create a variable of type Int32
count.data = 0; // Initialize 'count' variable
while (ros::ok()) // Create a loop that will go until someone stops the program execution
pub.publish(count); // Publish the message within the 'count' variable
I hope this helps.
By the way, welcome to the Community!