ROS 2 Lyrical lab 02 ยท 35 min

Create the robotics workspace

Build a clean colcon overlay at ~/robot_ws and understand each generated directory.

Before you start

  • ROS 2 Lyrical sourced
  • colcon installed

Files you will touch

  • ~/robot_ws/src/
  • ~/robot_ws/build/
  • ~/robot_ws/install/
  • ~/robot_ws/log/

Step 1

Set up

source /opt/ros/lyrical/setup.bash
mkdir -p ~/robot_ws/src
cd ~/robot_ws
colcon build --symlink-install

Step 2

Create the file

# Source the overlay after every successful build.
source ~/robot_ws/install/setup.bash
printenv AMENT_PREFIX_PATH

Step 3

Build, run and inspect

cd ~/robot_ws
colcon list
colcon build --symlink-install
source install/setup.bash

Proof that it works

  • The build finishes without failed packages
  • install/setup.bash exists
  • The workspace path appears before /opt/ros/lyrical in AMENT_PREFIX_PATH

Recovery notes

  • Remove build, install and log only when a clean rebuild is necessary; never remove src.
  • Build one package with --packages-select PACKAGE_NAME to isolate errors.
ROS 2 colcon tutorial