Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to initialize the ROS node for teleoperation.
ROS
ros::init(argc, argv, [1]);Attempts:
3 left
💡 Hint
Common Mistakes
Using a node name unrelated to teleoperation.
Forgetting to put the node name in quotes.
✗ Incorrect
The ROS node must be initialized with the name "teleop_node" to identify the teleoperation control node.
2fill in blank
mediumComplete the code to create a ROS publisher for velocity commands.
ROS
ros::Publisher vel_pub = nh.advertise<geometry_msgs::Twist>([1], 10);
Attempts:
3 left
💡 Hint
Common Mistakes
Using a non-standard topic name that the robot does not subscribe to.
Omitting the leading slash in the topic name.
✗ Incorrect
The standard topic for velocity commands in ROS teleoperation is "/cmd_vel".
3fill in blank
hardFix the error in the teleoperation loop to publish velocity commands correctly.
ROS
while (ros::ok()) { geometry_msgs::Twist vel_msg; vel_msg.linear.x = [1]; vel_pub.publish(vel_msg); ros::spinOnce(); loop_rate.sleep(); }
Attempts:
3 left
💡 Hint
Common Mistakes
Using the topic name or message type as a variable.
Using undefined variable names.
✗ Incorrect
The variable 'speed' holds the linear velocity value to assign to vel_msg.linear.x.
4fill in blank
hardFill both blanks to subscribe to joystick input and update velocity commands.
ROS
ros::Subscriber joy_sub = nh.subscribe([1], 10, [2]);
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect topic names that do not publish joystick data.
Using callback functions unrelated to joystick input.
✗ Incorrect
The joystick input topic is "/joy" and the callback function handling input is 'joyCallback'.
5fill in blank
hardFill all three blanks to create a dictionary mapping joystick axes to velocity commands.
ROS
std::map<std::string, double> axis_map = {{
{"linear_x", [1],
{"angular_z", [2],
{"linear_y", [3]
}};Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up axis indices for linear and angular movements.
Using axes indices that do not exist or are incorrect.
✗ Incorrect
Axis 1 controls linear_x, axis 0 controls angular_z, and axis 3 controls linear_y in joystick mapping.
