Unit 06 · lesson

Underlays, Overlays, and Why Workspaces Exist

Your installed Jazzy system already contains packages.

You do not want every experiment to modify /opt/ros/jazzy.

ROS 2 workspaces let you layer development packages on top of an existing environment.

Diagram showing the ROS 2 Jazzy underlay beneath a local ros2_ws overlay with src, build, install, and log spaces.
Diagram showing the ROS 2 Jazzy underlay beneath a local ros2_ws overlay with src, build, install, and log spaces.

Diagrams open at a readable shape-aware scale. Zoom or expand when you need more detail.

Concept flow

A sourced overlay extends an existing ROS 2 environment

Workspaces isolate project packages from the base Jazzy installation while still depending on it.

  1. UNDERLAY/opt/ros/jazzy provides the base environment
    source
  2. WORKSPACE SRClocal packages live in ros2_ws/src
    build
  3. COLCONproduces build, install, and log outputs
    source
  4. OVERLAYinstall/local_setup extends the shell environment
    discover
  5. LOCAL PACKAGESros2 tools can now find the project

Underlay

For this course:

/opt/ros/jazzy

is the main underlay.

It contains the ROS 2 installation your local work depends on.

Overlay

A workspace you create and build can be sourced afterward as an overlay.

The official tutorial explains that packages in an overlay can take precedence over packages in the underlay.

source /opt/ros/jazzy/setup.bash

source ~/ros2_ws/install/local_setup.bash

current shell sees Jazzy + local overlay packages

Why this is useful

  • experiment without rebuilding ROS 2 itself;
  • keep project packages together;
  • build only the packages you are changing;
  • switch between workspaces by changing what the shell sources.

Checkpoint

Explain why this is safer than editing files inside /opt/ros/jazzy directly.