Drive the robot and check sensor data
Drive the robot for a while, then check three things for each sensor topic: has data, correct frequency, correct source. These three steps repeat before every measurement in the course.
The robot runs on the hill according to the key you press, the point cloud in RViz changes accordingly. And a table of measurements of your own machine:
| Topic | Nominal | Dev measuring device (terrain, no Gazebo window) |
|---|---|---|
/velodyne_points | 10 Hz | 9.4 Hz, 1 publisher |
/imu/data | 200 Hz | 192 Hz, 1 publisher |
| RTF | 1.0 | 0.97 |
1. Drive with keyboard
Terminal 1
ros2 launch atlas3d_bringup bringup.launch.py
Terminal 2
ros2 run teleop_twist_keyboard teleop_twist_keyboard
Keep the cursor in Terminal 2 (the teleop only reads the key when its window is selected):
| Keys | Effect |
|---|---|
i / , | Forward/reverse |
j / l | Rotate left/right in place |
u o m . | Walk and turn |
k | Stop |
q / z | Speed up/down 10 % |
Teleop starts at 0.5 m/s and 1.0 rad/s. The robot's controller is limited to 1.0 m/s and 1.2 rad/s, pressing q beyond that will not make the robot faster.
Robot starts on the roundabout, heading east. Press i to go along the road, try turning up the hill next to see the robot tilting along the ground. In RViz, the cloud follows the robot and the Wheel Odometry arrow extends behind it.
Teleop sends velocity command to topic /cmd_vel. The controller stops the robot if there is no new command within 0.5 seconds, so release the key for a while and the robot stops automatically.
2. Is there any data
Terminal 3
ros2 topic list
In the list there must be sensor topics: /velodyne_points, /imu/data, /imu/data_raw, /odom, /ground_truth/odom, /camera/color/image_raw, /camera/depth/image_raw. Quickly view a LiDAR message, removing the data array:
ros2 topic echo --once --no-arr /velodyne_points
header:
stamp:
sec: 9
nanosec: 100000000
frame_id: velodyne_link
height: 16
width: 1800
...
point_step: 32
row_step: 57600
data: '<sequence type: uint8, length: 921600>'
is_dense: false
16 rows × 1 800 columns, exactly 16 beams × 1 800 samples per round. Each point takes up 32 bytes, a scan weighs 921 600 bytes, almost 1 MB, 10 times per second. is_dense: false because some beams hit nothing (infinite values), as you saw in lesson 0. M04 reads this message byte by byte.
3. Correct frequency no
ros2 topic hz /velodyne_points
average rate: 9.540
min: 0.086s max: 0.201s std dev: 0.01231s window: 90
average rate: 9.439
min: 0.086s max: 0.201s std dev: 0.01520s window: 99
max: 0.201s means that there were times when the two scans were twice as far apart as usual: one scan was late or was missed while the machine was busy. Once in a while is okay; If std dev becomes larger, the machine is overloaded.
Press Ctrl+C after a few seconds. Do the same with /imu/data. Measure one topic at a time: running multiple commands ros2 topic hz at the same time makes the machine busier, RTF decreases and all numbers drop. On the dev machine, measuring 7 topics at the same time gives /velodyne_points 9.2 Hz, separately measuring 9.4 Hz.
Read RTF now from Gazebo:
ign topic -e -t /stats -n 1 | grep real_time_factor
real_time_factor: 1
That's the result in world warehouse, lightweight so it runs in real time. At terrain this number is less than 1 and fluctuates from moment to moment. Taking the measured frequency divided by RTF, it should be close to the nominal frequency: 9.4 / 0.97 ≈ 9.7 Hz, close to 10 Hz.
Why does IMU have two topics?
IMU in the Gazebo measures 1 000 times per second and broadcasts /imu/data_raw. Node imu_filter_node filters out the oscillations faster than 50 Hz and then keeps only 1 of the 5 samples, resulting in /imu/data 200 Hz. SLAM only uses /imu/data.
Reason: when the robot is stationary, the physics simulator still produces very rapid vibrations where the wheel touches the ground. If a straight 200 Hz sample is taken, that vibration "folds" down into noise more than a hundred times larger than the IMU's parameters. How to detect and fix this error is in M03.
4. Exactly one source
ros2 topic info /velodyne_points
ros2 topic info /imu/data
Type: sensor_msgs/msg/PointCloud2
Publisher count: 1
Subscription count: 0
Type: sensor_msgs/msg/Imu
Publisher count: 1
Subscription count: 0
Publisher count must be true 1. The subscription number changes depending on what is open: the above result is when running rviz:=false, opening RViz, /velodyne_points has 1 more.
SLAM is wrong by several meters because the data is duplicated
During construction of the project, a series of SLAM measurements gave results that were off by several meters for unknown reasons. Cause: after each time the simulation is turned off, the script stops filtering out the wrong process name, then forgets imu_filter_node. The old nodes are still alive and continue to broadcast. When opening a new simulation, the cloud and IMU are transmitted 2 to 8 times for each real measurement, SLAM receives looping and drifting data.
The entire series of measurements had to be discarded and re-measured. From there, the course rule is before measuring, check each sensor topic has exactly 1 publisher, and turn off simulation with tools/sim_test/stop_sim.sh when in doubt.
5. Turn off
Ctrl+C in Terminal 2 (teleop) then Terminal 1 (bringup). Check cleanly as in lesson 3:
bash tools/sim_test/stop_sim.sh
còn 0 tiến trình
Common errors
activated diff_drive_controller.ros2 topic hz prints nothingTerminal has no source workspace, or simulation is paused (▶ button in the bottom corner of Gazebo).headless:=true or smaller world.