CodeTheRobot

Ubuntu Linux for Robotics · Lesson 26 of 96

Installing ROS 2 dependencies: rosdep and vcstool

Resolving system dependencies from package.xml and cloning many repositories from a .repos file.

Estimated time · 45–60 min

Learning goals

What you will understand

  • Explain installing ros 2 dependencies: rosdep and vcstool in your own words
  • Use it in a small workstation example
  • Verify the result instead of assuming it worked

Understand the idea first

The mental model

Every ROS 2 package lists its dependencies in package.xml. rosdep reads them and installs the matching system packages with apt (or pip): run sudo rosdep init once, rosdep update as your user, then rosdep install --from-paths src --ignore-src -y inside the workspace.

vcstool (the vcs command) manages many Git repositories at once from a .repos YAML file: vcs import src < robots.repos clones them all, vcs pull updates them and vcs status shows changes. Together they make a workspace reproducible on a new machine in a few commands.

Guided lesson

Work through these steps

  1. 1.

    Open a terminal and record the current state before changing anything.

  2. 2.

    Read the installing ros 2 dependencies: rosdep and vcstool commands and predict what each one does.

  3. 3.

    Run the commands one at a time and compare each output with your prediction.

  4. 4.

    Write the commands that worked in a setup note you can repeat later.

Worked example

Read it before you run it

sudo apt install python3-rosdep python3-vcstool
# Install both tools.
sudo rosdep init
# One-time setup of the rosdep source list (needs sudo).
rosdep update
# Download the dependency database (as your normal user).
cd ~/robot_ws
# Go to the workspace root.
vcs import src < robot.repos
# Clone every repository listed in robot.repos into src.
rosdep install --from-paths src --ignore-src -r -y
# Install every dependency the packages need.

What the example is doing

  1. 1.Lines without sudo only inspect or change files you own; sudo authorizes a system-wide change.
  2. 2.Read command output before moving to the next line. Stop if names, versions, disks, or paths differ from the lesson.
  3. 3.Comments beginning with # explain safety checks and are not executed by the shell.

Watch it run · Build and run

See what this code does

The terminal types this lesson's practice solution and runs it. The scene shows the kind of robot behaviour that code drives. It plays by itself and loops.

sourcecompilerprogramBUILD AND RUN

Demo for Installing ROS 2 dependencies: rosdep and vcstool. Expected result: The dependencies of all packages in src are installed

Practice code

Now type it yourself

Open a terminal, run the starter line by line (or save it as practice.sh and run bash practice.sh), and replace every TODO with your own command.

cd ~/robot_ws
# TODO: install all dependencies of the packages in src (from-paths, ignore-src, yes to all)

Expected output

The dependencies of all packages in src are installed
Stuck? Show the full solution (try it yourself first)
cd ~/robot_ws
rosdep install --from-paths src --ignore-src -y

Expected result

How you know it worked

  • Each command completes without an unexplained error.
  • Your notes contain the command, the important output, and what it proves.

Practical exercise

Apply the lesson

Write a robot.repos file with two repositories, import it with vcs, run rosdep install, and build the workspace. Delete the workspace and reproduce it from those files alone.

Before you continue

  • You recorded the starting state
  • Every command and output is understood
  • The change can be repeated from your notes

If something goes wrong

A command says permission denied.

Check ownership and permissions first. Do not add sudo unless the command changes a documented system location.

A command or package is not found.

Check spelling, Ubuntu version, enabled repositories, and whether the previous installation command succeeded.