I am struggling with exercise 2.2. I am asked to modify the code from exercise 2.1 so that it now publishes data to the /cmd_vel topic. How would I go about starting this as I cant seem to make any progress with it. Sorry if this is quite simple!
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 /cmd_vel accepts.
Include it in place of <std_msgs/Int32.h>
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
// ...
}