Create Catkin Workspace¶
In this exercise, we will create a ROS catkin workspace.
Motivation¶
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.
Reference Example¶
Steps to creating a workspace: Creating a Catkin Workspace
Note: Many current examples on ros.org use the older-style catkin_init_workspace
commands. These are similar, but not directly interchangeable with the catkin_tools
commands used in this course.
Further Information and Resources¶
Using a Catkin Workspace: Using a Workspace
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 - a catkin workspace - for your application and its supplements.
Scan-N-Plan Application: Guidance¶
Create a Catkin Workspace¶
Create the root workspace directory (we’ll use
catkin_ws
)cd ~/ mkdir --parents catkin_ws/src cd catkin_ws
Initialize the catkin workspace
catkin init
- Look for the statement “Workspace configuration appears valid”, showing that your catkin workspace was created successfully. If you forgot to create the
src
directory, or did not runcatkin init
from the workspace root (both common mistakes), you’ll get an error message like “WARNING: Source space does not yet exist”.
- Look for the statement “Workspace configuration appears valid”, showing that your catkin workspace was created successfully. If you forgot to create the
Build the workspace. This command may be issued anywhere under the workspace root-directory (i.e.
catkin_ws
).catkin build ls
- See that the
catkin_ws
directory now contains additional directories (build, devel, logs).
- See that the
These new directories can be safely deleted at any time (either manually, or using
catkin clean
). Note that catkin never changes any files in thesrc
directory. Re-runcatkin build
to re-create the build/devel/logs directories.catkin clean ls catkin build ls
Make the workspace visible to ROS. Source the setup file in the devel directory.
source devel/setup.bash
- This file MUST be sourced for every new terminal.
- To save typing, add this to your
~/.bashrc
file, so it is automatically sourced for each new terminal:gedit ~/.bashrc
- add to the end:
source ~/catkin_ws/devel/setup.bash
- save and close the editor