9. RViz

RViz shows you what the robot thinks is happening.

Important

RViz shows what the robot believes, not what is true.

If RViz draws the robot in the middle of the aisle while the real robot is against the wall, RViz is not broken — the robot is wrong. That is extremely useful information.

Remember this; newcomers tend to treat RViz as a security camera.

Open it

rviz2

Fixed Frame — set this before anything else

The first field under Global Options, top left, is the frame RViz anchors everything to.

Danger

🔴 Get it wrong and you see nothing, with no explanation.

The default is map, which only works once SLAM or AMCL is running. Without it you get a red Fixed Frame [map] does not exist and an empty screen.

Situation

Set it to

Testing sensors, no map yet

base_link

Odometry running, watching motion

odom

Map and AMCL running

map

The displays you will use

Click Add at the bottom left.

Display

Shows

Topic

RobotModel

The robot shape from the URDF

—

TF

Every frame as coloured axes

—

LaserScan

What the LiDAR sees

/scan

Map

The map

/map

Path

The planned route

/plan

Costmap

Areas that are off-limits

/global_costmap/costmap

Tip

Add one at a time and confirm it appears before adding the next.

Add everything at once and get a blank screen, and you will not know which one is at fault. Usually it is the Fixed Frame, or a topic with no data.

The TF display — the best debugging tool here

Enable TF and you see three coloured axes for every frame (red = x, green = y, blue = z).

Three things you can check at a glance:

  1. Is the LiDAR in the right place? The laser_front axes should sit where it physically is on the robot

  2. Is it facing the right way? Red should point towards the front

  3. How far apart are map and odom? The bigger the gap, the more odometry drift has accumulated

Checking the LiDAR by eye

Enable LaserScan, set Fixed Frame to base_link, and push the robot near a wall.

What you should see — a straight line of points along the wall, at the distance you can measure.

What you see

Means

The wall looks tilted when it is straight

The mounting angle in the URDF is wrong

The wall is at the wrong distance

The LiDAR position in the URDF is wrong

A ring of points around the robot

The LiDAR is seeing the robot’s own chassis

No points at all

Wrong topic, or a QoS mismatch (see topic 10)

Note

“Seeing its own chassis” happens a lot on robots with two LiDARs. The system believes there is a permanent obstacle attached to the robot and refuses to move.

Fix it by masking the angular range that sees the chassis, not by cutting a minimum distance — cutting by distance also blinds you to genuinely close obstacles.

Save your configuration

Once the displays are set up, File → Save Config As to a .rviz file.

Reopen with:

rviz2 -d ~/ros2_ws/src/my_robot/rviz/robot.rviz

Tip

Commit the .rviz file — it is part of the work, not a personal preference. The team then looks at the same picture when discussing a problem.

Sending goals from RViz

Once Nav2 is running, the toolbar buttons command the robot.

  • 2D Pose Estimate — tell the robot where it currently is on the map (used at startup)

  • 2D Goal Pose — send it there

Danger

2D Goal Pose moves a real robot immediately. There is no confirmation dialog. A misclick sends it driving — be sure nobody is in the way before you click.


Previous: 8. tf2 · Next: 10. QoS