RViz functions as the primary three-dimensional visualization enviroment within the ROS 2 ecosystem, enabling developers to render sensor data, robot models, and navigation states in real time.
Environment Setup and Execution
Before launching the application, ensure the ROS 2 environment is sourced correctly. For a standard Jazzy installation on Ubuntu:
. /opt/ros/jazzy/setup.sh
Execute the visualization node using the standard ROS 2 runner:
ros2 run rviz2 rviz2 -d /path/to/custom_config.rviz
Upon initialization, the interface presents a central 3D viewport, a left-hand panel for display management, and auxiliary panels on the right for views, tool properties, and time synchronization.
Managing Visualizations
Visual components, referred to as displays, render specific message types into the 3D scene. Each display operates independently with configurable parameters and status indicators.
Creating and Configuring Displays
Click the Add button at the bottom of the Displays panel to open the type selector. Choose a visualization plugin based on the incoming message type (e.g., sensor_msgs/msg/PointCloud2 for lidar data). Assign a distinct identifier to each instance, which is crucial when monitoring multiple identical sensors, such as front_lidar and rear_lidar.
Every display exposes a property tree for tuning rendering styles, topic subscriptions, decay times, and color mappings. The status indicator adjacent to each display name reflects its operational state:
OK: Data is streaming and rendering correctly.Warning: Partial data reception or minor configuration mismatches.Error: Missing transforms, invalid topic types, or malformed messages.Disabled: The visualization is manually toggled off.
Core Display Plugins
RViz includes a comprehensive suite of built-in renderers:
Axes/Grid: Reference geometry for spatial orientation.RobotModel/TF: Renders URDF meshes and visualizes thetf2transformation tree.LaserScan/PointCloud2: Renders 2D and 3D range data with configurable decay and styling.Map/GridCells/Path: Navigation stack outputs, including occupancy grids, costmap obstacles, and planned trajectories.Image/Camera: Projects 2D image streams, with the Camera type overlaying imagery onto a 3D frustum.Marker/MarkerArray/InteractiveMarker: Programmatic shape rendering and user-interactive 3D widgets.Pose/PoseArray/Odometry: Visualizes spatial coordinates and historical trajectory trails.Wrench/Twist/Effort: Represents physical forces, torques, and joint actuation states.
Workspace Configuration
Visualization setups are highly task-dependent. A configuration optimized for SLAM debugging differs significantly from one tailored for manipulator calibration. RViz persists the complete workspace state, including active displays, tool parameters, camera perspectives, and panel layouts, into .rviz YAML files. Use File -> Save Config to export your current setup, and load it later via command-line arguments or the GUI.
Camera Controllers and Perspectives
The Views panel dictates how the 3D scene is projected and navigated. Different controllers suit different debugging scenarios:
Orbit(Default): Rotates around a focal point. Left-drag rotates, middle-drag pans, right-drag/scroll zooms.FPS: First-person navigation. Mimics head movement. Left-drag looks around, middle-drag strafes, right-drag/scroll moves forward/backward.TopDownOrtho: Orthographic projection locked to the Z-axis. Ideal for 2D navigation debugging. Objects do not scale with distance.XYOrbit: Similar to Orbit but constrains the focal point to the Z=0 plane.ThirdPersonFollower: Locks the camera to a moving frame (e.g.,base_link), automatically adjusting yaw as the robot turns. Useful for corridor mapping or outdoor navigation.
Custom viewpoints can be bookmarked via the Views panel. These snapshots store the controller type, spatial coordinates, orientation, and target frame, allowing rapid switching between debugging angles. Bookmarks are stored per-user rather than in the global config file.
Reference Frames and Transforms
RViz relies heavily on the tf2 library to reconcile data from disparate coordinate systems into a unified spatial context. Two frame parameters are critical:
Fixed Frame: The global reference anchor (typicallymap,odom, orworld). All incoming data is transformed into this frame before rendering. It must represent a static or globally consistent referance. Changing this frame clears the current scene to prevent transform corruption.Target Frame: Defines the camera's relative reference. Setting this tomapshows the robot moving through the environment. Setting it tobase_linkkeeps the robot stationary while the world moves around it.
Interaction Tools and Shortcuts
The toolbar provides utilities for scene manipulation, data publishing, and measurement. Global keyboard shortcuts streamline workflow:
Tool Switching
M: Move CameraI: Interact (manipulate InteractiveMarkers)S: Select (click/drag to highlight objects,Fto focus)C: Focus Camera (reorients view toward a clicked point)N: Measure (calculates Euclidean distance between two clicked points on rendered geometry)P: 2D Pose Estimate (publishes to/initialposefor localization initialization)G: 2D Nav Goal (publishes to/goal_posefor navigation targets)U: Publish Point (streams clicked coordinates to/clicked_point)
Navigation Controls
Camera behavior adapts based on the active view controller. Standard mouse mappings apply across most controllers: left-button for rotation, middle/shift-left for panning, and right/scroll for zooming or forward movement. The Z key instantly resets the camera to the default origin.
Publishing Goals and Estimates
The navigation tools integrate directly with the Nav2 stack. Clicking and dragging on the ground plane defines both position and yaw orientation. Example log output when setting a localization prior:
[INFO] [rviz2_node]: Publishing initial pose -> Frame: odom, Pos: [1.45, -0.82, 0.0], Quat: [0.0, 0.0, 0.342, 0.939], Yaw: 0.70 rad
Example log output when sending a navigation target:
[INFO] [rviz2_node]: Dispatching goal pose -> Frame: map, Pos: [4.12, 2.05, 0.0], Quat: [0.0, 0.0, -0.198, 0.980], Yaw: -0.40 rad
Output topics and frame IDs can be remapped dynamically via the Tool Properties panel.
Time Synchronization Panel
The Time panel is essential when operating within simulated environments or playing back rosbag data. It displays the delta between simulated ROS time and system wall-clock time. The panel also provides a reset mechanism to flush internal transform buffers and clear decay-based displays, ensuring synchronization after simulation pauses or time jumps. When running on physical hardware with real-time clocks, this panel provides minimal utility and can be collapsed to maximize viewport space.