Before you start writing code in ROS, you need to create a workspace. A workspace is a set of directories (or folders) where you store related pieces of ROS code. The official name for workspaces in ROS is catkin workspaces. The word ‘catkin’ comes from the tail-shaped flower cluster found on willow trees (see photo below) — a reference to Willow Garage, the original developers of ROS.
The official instructions for creating a ROS workspace are at ROS.org, but I will walk you through the process below so you can see how it is done.
Open up a new terminal window (I’m assuming you are using ROS on Ubuntu Linux), and type the following commands to create and build at catkin workspace.
mkdir -p ~/catkin_ws/src
Type the dir command, and you will see three folders inside of this directory: build, devel, and src.
Now we need to source the setup.bash file. This file sets the path of the workspace so that packages and code inside the workspace can be found.
Make sure the workspace is properly overlayed by the setup script (which we ran above).
So we don’t have to source the setup.bash file every time we open a new Linux terminal, let’s add the ~/catkin_ws/devel/setup.bash command to the .bashrc file. Open a new Linux terminal window.
Type the following command to edit the .bashrc text file:
Add this line to the end of the .bashrc file:
That’s it! You’re all done. Just click Save and exit the text editor.