ROS 2 Learning Path  ยท  Visual Textbook

Chapter 6: RViz โ€” ROS 2's Visual Dashboard

The first time we actually see ARCHO
Prerequisite: Chapters 4 and 5
Running project: ARCHO robot
Tool: RViz2
Reading time: 60โ€“80 minutes
What's in this chapter 6.1What RViz is โ€” and isn't 6.2Anatomy of the RViz window 6.3Seeing ARCHO for the first time 6.4Key displays: Grid, RobotModel, TF, LaserScan 6.5Visual checkpoint 6.6Summary, glossary, and exercises

6.1What RViz is โ€” and isn't

So far ARCHO has existed only in XML files and terminal output. It's time to "see" him for the first time. RViz is a tool that does exactly that: it displays anything published on the ROS 2 network โ€” the robot model, the TF tree, LiDAR data, Nav2's planned path โ€” in a live 3D view.

๐Ÿ“– This chapter's golden sentence

RViz is the robot's information window; Gazebo (next chapter) is the robot's virtual lab. RViz doesn't simulate any physics โ€” if you place ARCHO a meter above the ground, in RViz he just stays there, floating in mid-air, because RViz only shows what it receives from the ROS network; it doesn't apply the laws of the real world.

๐Ÿง  Simple Analogy

If you want to design a car, a CAD drawing program only shows its appearance โ€” it won't tell you whether it rolls over or how it brakes. RViz plays exactly that role for a robot โ€” a window for seeing and debugging, not a physical laboratory.

6.2Anatomy of the RViz window

Before we open RViz, let's see what we'll find inside it:

RViz2 โ€” archo.rviz File Panels Help Displays โ˜‘ Grid โ˜‘ RobotModel โ˜‘ TF โ˜‘ LaserScan /scan โ˜ Odometry + Add Global Options Fixed Frame: base_footprint Views: Orbit 3D view โ€” grid + RobotModel + TF + LaserScan
Figure 6.1 โ€” Layout of the RViz2 window: the Displays panel on the right, the 3D view in the center with a ground grid, the ARCHO model, TF axes, and LaserScan points.
Window sectionRole
Displays panelLists every information layer you want to see; each can be toggled on/off with a checkbox
Add buttonAdds a new display (e.g. LaserScan, PointCloud, Path)
Fixed FrameThe reference frame everything is drawn relative to
3D viewThe main scene; can be rotated, zoomed, and panned with the mouse
ViewsCamera type (Orbit, Top Down, First Person, etc.)

6.3Seeing ARCHO for the first time

To display the model, we need a three-step chain, each link of which we already built in earlier chapters:

flowchart LR A["Xacro"] --> B["robot_description"] B --> C["robot_state_publisher"] C --> D["RViz2"] style D fill:#eef0ff,stroke:#3d4bf5,color:#211f1a,font-weight:bold

We create a launch file named display.launch.py in archo_description/launch:

from launch import LaunchDescription
from launch.substitutions import Command
from launch_ros.actions import Node
from launch_ros.parameter_descriptions import ParameterValue
from ament_index_python.packages import get_package_share_directory
import os


def generate_launch_description():
    package_path = get_package_share_directory('archo_description')
    xacro_file = os.path.join(package_path, 'urdf', 'archo.urdf.xacro')
    robot_description = ParameterValue(
        Command(['xacro ', xacro_file]), value_type=str)

    return LaunchDescription([
        Node(
            package='robot_state_publisher',
            executable='robot_state_publisher',
            parameters=[{'robot_description': robot_description}],
        ),
        Node(
            package='joint_state_publisher_gui',
            executable='joint_state_publisher_gui',
        ),
        Node(
            package='rviz2',
            executable='rviz2',
            output='screen',
        ),
    ])
๐Ÿ“– Why joint_state_publisher_gui?

We don't yet have a real controller or wheel simulation (that's next chapter's job). joint_state_publisher_gui opens a small window with a slider for every movable joint โ€” you can manually "spin" the left or right wheel and immediately see robot_state_publisher reflect that change in TF. A great tool for quick testing before moving on to full simulation.

dev@archo:~$ cd ~/archo_ws dev@archo:~/archo_ws$ colcon build --symlink-install dev@archo:~/archo_ws$ source install/setup.bash dev@archo:~/archo_ws$ ros2 launch archo_description display.launch.py [INFO] [robot_state_publisher]: got segment base_link [INFO] [robot_state_publisher]: got segment left_wheel_link [INFO] [robot_state_publisher]: got segment right_wheel_link [INFO] [rviz2]: RViz2 window opened

6.4Key displays: Grid, RobotModel, TF, LaserScan

When RViz opens for the first time, you'll usually see nothing โ€” because no displays have been added yet. Add these four with the Add button:

DisplayWhat it shows
GridA reference grid on the ground, purely for visual orientation
RobotModelARCHO's actual appearance โ€” exactly the Visual geometry we defined in Xacro back in Chapter 4
TFThe colored axes (red/green/blue) of every frame, so you can see whether last chapter's TF tree was actually built correctly
LaserScanLiDAR data points, once we enter Gazebo next chapter; its topic is usually /scan

And most importantly, set the Fixed Frame to base_footprint โ€” the same root we verified with check_urdf back in Chapter 4.

โš ๏ธ Common mistake

If you see nothing on screen after adding RobotModel, it's usually one of three things: the wrong Fixed Frame was selected, robot_state_publisher isn't running, or Xacro threw an error and robot_description was never published at all. The Displays panel usually shows a red icon next to the item that has a problem.

6.5Visual checkpoint

Unlike previous chapters, this chapter's checkpoint is "visual" โ€” you need to confirm the following by looking at RViz:

โœ… Chapter 6 checkpoint
  • ARCHO's body appears in the blue color we defined back in Chapter 4.
  • The two drive wheels sit exactly on either side of the body โ€” not inside it, not detached from it.
  • The LiDAR (small cylinder) sits on top of the body, near the front.
  • The TF axes are not red/broken or showing warnings.
  • The Displays panel's root frame equals base_footprint.
  • Using the joint_state_publisher_gui sliders, the wheels actually rotate in RViz.

6.6Chapter 6 summary

For the first time in this book, we saw ARCHO with our own eyes โ€” not as lines of XML, but as a live 3D model that makes Chapter 5's TF tree real. But remember: RViz is only an information window. Nothing actually "happens" inside it. For ARCHO to truly move, collide with gravity, and behave with real physics, we need to step into the next virtual lab.

๐ŸŒ Connection to the main project

ARCHO Project is now visible for the first time. The display.launch.py file we just built will be the foundation for every later launch file โ€” each time, we'll simply add one more layer on top (Gazebo, Nav2, SLAM).

What the next chapter adds

In Chapter 7, ARCHO enters Gazebo for the first time โ€” a place where he's no longer merely seen, but where gravity acts on him, he collides with the ground, and his LiDAR and IMU produce real (noisy) data.

Chapter 6 glossary

RViz2
ROS 2's visualization tool, which displays anything published on the network (robot model, TF, sensors) in 3D, without simulating physics.
Display
An addable information layer in RViz, such as Grid, RobotModel, TF, or LaserScan.
Fixed Frame
The reference frame that every other display in the scene is drawn relative to.
joint_state_publisher_gui
A tool with a slider for manually changing each joint's angle, without needing a real controller.

Chapter 6 common mistakes โ€” recap