Create ROS Workspace¶
In this exercise, we will create and build an empty ROS workspace.
Any ROS project begins with making a workspace. In this workspace, you will put all the things related to this particular project. In this module we will create the workspace where we will build the components of our Scan-N-Plan application.
Further Information and Resources¶
Additional details on what a ROS environment consists of and some basic checks you can run: Configuring a ROS2 Environment
Scan-N-Plan Application: Problem Statement¶
We have a good installation of ROS, and we need to take the first step to setting up our particular application. Your goal is to create a workspace for your application and its supplements.
Scan-N-Plan Application: Guidance¶
Create a Workspace¶
Close any open terminal windows. Open a new terminal and source the “foxy” distribution.
Create the root workspace directory. Note that the required structure is a top-level directory and a
src/directory one level down. The directory name is a completely free choice. We will use
ros2_wsthroughout these tutorials.
cd ~/ mkdir --parents ros2_ws/src cd ros2_ws ls
Build the workspace from the workspace root-directory (
colcon build ls
- See that the
ros2_wsdirectory now contains additional directories (build, install, log).
colcon buildmust always be run from the root of your workspace directory.
- Don’t run
colcon buildfrom a terminal where you’ve also sourced this workspace’s setup file. Use a dedicated terminal for building.
- See that the
These new directories can be safely deleted at any time. This is sometimes used to resolve unusual build errors by “starting with a clean slate”. Note that colcon never changes any files in the
colcon buildto re-create the build/install/log directories.
rm -r build/ install/ log/ ls colcon build ls
Make the contents of this workspace visible to ROS. Source the setup file in the install directory.
- This file MUST be sourced for every new terminal.
- This file will automatically include the ROS environment that was active when you first built this workspace. Make sure you have sourced the correct ROS distribution before building a new workspace for the first time!