Complete the code to start a ROS node named 'robot_controller'.
ros::init(argc, argv, [1]);The ros::init function initializes the ROS node with the given name. Here, the node is named 'robot_controller'.
Complete the code to create a ROS publisher for the topic '/cmd_vel'.
ros::Publisher pub = nh.advertise<geometry_msgs::Twist>([1], 10);
The publisher is created for the '/cmd_vel' topic, which is commonly used to send velocity commands to a robot.
Fix the error in the ROS spin loop to keep the node alive.
while (ros::ok()) { [1]; }
The ros::spinOnce() function processes incoming messages and callbacks, keeping the node responsive.
Fill both blanks to create a ROS subscriber that listens to '/scan' topic and uses 'scanCallback' function.
ros::Subscriber sub = nh.subscribe([1], 1000, [2]);
The subscriber listens to the '/scan' topic and calls the 'scanCallback' function when messages arrive.
Fill all three blanks to create a dictionary comprehension that maps sensor names to their data length if length is greater than 5.
auto sensor_lengths = [1] [3]: [2].size() for auto& [3] : sensors if [2].size() > 5 [4];
The dictionary comprehension starts with '{', uses 'sensor_name' as key, 'sensor' to get size, iterates over 'sensor_name' in sensors, and ends with '}'.
