Back to the 2025 paper

ROS

20257m

Explain the steps involved in setting up a Catkin Workspace.

Worked SolutionAI Assisted

Solution: Setting Up a Catkin Workspace

A Catkin workspace is a directory structure used to organize and build ROS 1 packages.

Steps

1. Create the workspace

mkdir -p ~/catkin_ws/src
cd ~/catkin_ws/src

The src directory contains ROS packages.

2. Initialize the workspace

From the workspace root:

cd ~/catkin_ws
catkin_make

This creates build and devel directories and generates the required build configuration.

3. Source the workspace

source ~/catkin_ws/devel/setup.bash

This makes packages in the workspace available in the current terminal.

To source it automatically:

echo "source ~/catkin_ws/devel/setup.bash" >> ~/.bashrc
source ~/.bashrc

4. Create a package

cd ~/catkin_ws/src
catkin_create_pkg my_robot_pkg roscpp rospy std_msgs

The package now contains its manifest and build configuration.

5. Build the workspace

cd ~/catkin_ws
catkin_make

6. Verify the package

rospack find my_robot_pkg

If the package path is returned, the workspace is correctly sourced.

Workspace Structure

catkin_ws/
├── src/
│   └── my_robot_pkg/
│       ├── src/
│       ├── include/
│       ├── CMakeLists.txt
│       └── package.xml
├── build/
└── devel/

Conclusion

The normal workflow is create workspace → initialize/build → source → create packages → build again → verify. This provides an organized environment for ROS development.

Similar questions