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.

All the ROS packages that you create need to reside inside a catkin workspace. The name of this catkin workspace is typically called catkin_ws.
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.
Directions
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
cd ~/catkin_ws/
catkin_make

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.
source devel/setup.bash

Make sure the workspace is properly overlayed by the setup script (which we ran above).
echo $ROS_PACKAGE_PATH

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:
gedit ~/.bashrc
Add this line to the end of the .bashrc file:
source ~/catkin_ws/devel/setup.bash

That’s it! You’re all done. Just click Save and exit the text editor.