Welcome to RDK S600 Developer Kit repository
17.ROS2 rviz2 use
17. ROS2 Rviz2 Usage
Note: The accompanying reference video uses the ROS Humble version, for reference only
1. Rviz2 Overview
During robot development, for various functions, if we only analyze from the data level, it's difficult to quickly understand the effect of the data. For example, with robot models, we need to know what our designed model looks like, and where many coordinate systems inside the model are located during movement.
Another example is robotic arm motion planning and mobile robot autonomous navigation. We want to see the robot's surrounding environment, planned paths, and of course sensor information - cameras, 3D cameras, LiDAR, etc. Data is used for computation, but visualization effects are for people to see.
Therefore, data visualization can greatly improve development efficiency. Rviz2 is such a data visualization software in the robot development process. Robot models, sensor information, environmental information, etc., can all be handled here.
2. Prerequisites
If you have a physical robot, you can start rviz on the robot's main control terminal to practice the content of this section. If you don't have a physical robot, we can use Gazebo simulation to start a TurtleBot3 simulated robot to simulate LiDAR, camera, and other topics, facilitating the subsequent data visualization.
Note: The following installation steps are not mandatory. If you have a physical robot, after configuring multi-machine communication, you can directly use the robot's LiDAR information. You can choose to use physical or simulated robot LiDAR; the following content is for users without a physical robot.
This section uses a simulated robot as an example to teach Rviz2's visualization functions. Whether using a physical or simulated robot, the Rviz2 operation process is the same.
Install turtlebot3 simulator package:
sudo apt install ros-${ROS_DISTRO}-turtlebot3*Install ROS and Gazebo bridge tool:
xxxxxxxxxxsudo apt install ros-${ROS_DISTRO}-ros-gzSet turtlebot3 robot type environment variable:
xxxxxxxxxxexport TURTLEBOT3_MODEL=waffleStart Gazebo simulation environment:
xxxxxxxxxxsource /opt/tros/jazzy/setup.bashxxxxxxxxxxros2 launch turtlebot3_gazebo turtlebot3_world.launch.py

3. Starting Rviz2
Open a terminal and use the following command to start:
xxxxxxxxxxrviz2
If starting in Docker, make sure GUI display has been enabled.

4. Image Data Visualization
Click "Add" in the left Displays window, then click "By topic" and find the /camera/image_raw topic. After clicking OK, it will be added to the display list and you can successfully see the robot's camera image.

Set
Fixed Frametobase_footprintcoordinate system to avoid coordinate transform errorsSelect camera color image topic
/camera/image_rawAt this point, we can see the current simulated robot's perspective in the Camera window

5. LiDAR Data Visualization
Click "Add" in the left Displays window, then click "By topic" and configure the subscription topic name as /scan. At this point, you can see the laser points.

LaserScan'sTopicshould be set to/scanAt this point, we can see the LiDAR point cloud contour

6. Robot Model Visualization
Click "Add" in the left Displays window, then click "By topic" and select the topic /robot_description.

At this point, we can see the visualized robot model in Rviz2.

7. Other Data Visualization
The rivz_default_plugins lists many commonly used data visualization plugins. You can try them one by one.
