A ROS Workspace is like the home directory for all the ROS related work on your system. It's nothing but a special folder which stores all the executable items and everything you create in ROS. So it's like a parent directory for ROS development. Usually people have only one workspace, but you could have many. Essentially, if you have a project that requires a lot of things, it's generally a good idea to create a workspace.
I'd prefer to create a folder in your home folder that contains all the ROS workspaces, so the entire ROS development is at one place. But actually, you can create a workspace anywhere you have permissions.
To create a ROS workspace, do the following:
cd ~
mkdir ROS_workspaces
cd ROS_workspaces
mkdir -p ros_ws/src/
cd ros_ws/src/
cd ~/ROS_workspaces/ros_ws/src/
catkin_init_workspace
ls -la
, you'll observe that a new file called CMakrLists.txt has been created (you could verify the same using Files)cd ../
catkin_make
ls -la */
. We'll explore more about them later, but notice the "setup.bash" in the devel folder.source ~/ROS_workspaces/ros_ws/devel/setup.bash
echo $ROS_PACKAGE_PATH
and the output will also have your workspace source directory.ROS section of "~/.bashrc" file
This time onward, whenever you want to do anything ROS on a terminal, make sure that you have the correct workspace setup file sourced (either in the "~/.bashrc" file or do it manually every time).
That's it, you've created the parent directory and basic files for development in ROS. Let's know a little about the way we organize files in ROS
Here's an image showing the basic structure in which ROS stores files. There is much more to it which we'll cover later, but for now there are a few things that we must note
ROS File Structure
Now that we've seen how the files are organized, let's start by making our first package in the workspace that we just created.
cd ~/ROS_workspaces/ros_ws/src/
catkin_create_pkg intro_pkg1 std_msgs roscpp rospy
cd ~/ROS_workspaces/ros_ws/
catkin_make
Done ! You've successfully created your first package 🎊🎉
Open a terminal and try out the commands in this
font.
rospack help
to know everything about it.cd ~/ROS_workspaces
)rospack find intro_pkg1
catkin_find_pkg intro_pkg1
Now that we know ROS file structure and how to create a package, let's see what are the terminologies in ROS and what are the components in ROS
Let's discuss in brief about some components in ROS. Just their name, what are they for, and what are the command line tools available for them. Check the spreadsheet next to know about all of them. We'll later learn them in detail, one by one
We'll learn about each one of them, for now just see the output of the "Know more command" to get a gist of what the commands do and what they're used for. You can come back to this place anytime for reference anyways.
The workspace for these pages is stored on GitHub.