ROS2 Tools, Launch, and Visualization

RViz2 Use

What RViz2 is for

RViz2 is the main visualization tool in ROS 2. It helps inspect:

  • Robot model and TF frames
  • Sensor streams (LaserScan, PointCloud2, Image)
  • Navigation data (map, path, costmap)

Quick start

bash
rviz2

Recommended first setup:

  1. Set Fixed Frame correctly (for example map or base_link).
  2. Add TF display.
  3. Add required sensor displays.

Common troubleshooting

  • “No transform” errors: check TF publishers.
  • Empty displays: verify topic name and message type.
  • Flicker or delay: check QoS compatibility.

rqt Toolbox

rqt is a plugin-based GUI toolkit for ROS 2.

Useful plugins:

  • rqt_graph: node/topic graph
  • rqt_plot: plot numeric fields
  • rqt_console: log inspection

Start:

bash
rqt

Launch Configuration

Why launch files

Launch files start multiple nodes with one command and centralize arguments, parameters, remaps, and namespaces.

Minimal Python launch file

demo.launch.py:

python
from launch import LaunchDescription
from launch_ros.actions import Node


def generate_launch_description():
    return LaunchDescription([
        Node(package='turtlesim', executable='turtlesim_node', name='sim'),
        Node(package='turtlesim', executable='turtle_teleop_key', name='teleop'),
    ])

Run:

bash
ros2 launch my_pkg demo.launch.py

Common launch patterns

  • DeclareLaunchArgument for configurable startup
  • IncludeLaunchDescription for composition
  • Namespaces for multi-robot isolation

Record and Playback

rosbag2 basics

Record topics:

bash
ros2 bag record /topic_a /topic_b

Record all topics:

bash
ros2 bag record -a

Playback:

bash
ros2 bag play <bag_folder>

Practical tips

  • Use --clock and use_sim_time for reproducible replay.
  • Keep bag files and metadata together.
  • Record only needed topics to reduce storage.

URDF Model

URDF describes robot links, joints, and basic visuals/collisions.

Typical workflow:

  1. Write robot URDF/Xacro.
  2. Publish robot description.
  3. Visualize in RViz2.

Core command (example):

bash
ros2 run robot_state_publisher robot_state_publisher

Gazebo Simulation

Gazebo provides physics simulation for ROS 2 testing.

Typical usage:

  1. Launch Gazebo world.
  2. Spawn robot model.
  3. Attach controllers/sensors.
  4. Validate navigation or perception pipeline.

Check real-time factor and sensor rates to avoid misleading results.


Camera Preview

Use camera drivers to publish image streams, then verify with tools:

bash
ros2 topic list
ros2 topic echo /camera/camera_info

Visual preview options:

  • RViz2 Image display
  • rqt_image_view

Camera Calibration

Camera calibration computes intrinsic parameters and distortion coefficients.

General process:

  1. Print calibration board.
  2. Capture multiple viewpoints.
  3. Run calibration tool.
  4. Save and reuse calibration YAML.

Calibration quality directly affects 3D perception and localization.


AR Visual

AR visualization overlays virtual markers or models on camera images.

Common prerequisites:

  • Calibrated camera
  • Stable TF chain
  • Reliable marker detection

AR is useful for demo, debugging, and human-robot interaction validation.