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
rviz2Recommended first setup:
- Set
Fixed Framecorrectly (for examplemaporbase_link). - Add
TFdisplay. - 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 graphrqt_plot: plot numeric fieldsrqt_console: log inspection
Start:
rqtLaunch 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:
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:
ros2 launch my_pkg demo.launch.pyCommon launch patterns
DeclareLaunchArgumentfor configurable startupIncludeLaunchDescriptionfor composition- Namespaces for multi-robot isolation
Record and Playback
rosbag2 basics
Record topics:
ros2 bag record /topic_a /topic_bRecord all topics:
ros2 bag record -aPlayback:
ros2 bag play <bag_folder>Practical tips
- Use
--clockanduse_sim_timefor 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:
- Write robot URDF/Xacro.
- Publish robot description.
- Visualize in RViz2.
Core command (example):
ros2 run robot_state_publisher robot_state_publisherGazebo Simulation
Gazebo provides physics simulation for ROS 2 testing.
Typical usage:
- Launch Gazebo world.
- Spawn robot model.
- Attach controllers/sensors.
- 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:
ros2 topic list
ros2 topic echo /camera/camera_infoVisual preview options:
- RViz2
Imagedisplay rqt_image_view
Camera Calibration
Camera calibration computes intrinsic parameters and distortion coefficients.
General process:
- Print calibration board.
- Capture multiple viewpoints.
- Run calibration tool.
- 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.