Bird
Raised Fist0
ROSframework~10 mins

catkin workspace creation in ROS - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - catkin workspace creation
Create workspace directory
↓
Create src folder inside workspace
↓
Run catkin_make in workspace
↓
Source setup.bash to update environment
↓
Workspace ready for packages
This flow shows the steps to create a catkin workspace: make folders, build with catkin_make, then source setup to use it.
Execution Sample
ROS
mkdir -p ~/catkin_ws/src
cd ~/catkin_ws
catkin_make
source devel/setup.bash
Creates a catkin workspace directory, builds it, and sets up environment variables.
Execution Table
StepCommandActionResult
1mkdir -p ~/catkin_ws/srcCreate workspace and src folderDirectories ~/catkin_ws and ~/catkin_ws/src created
2cd ~/catkin_wsChange directory to workspaceCurrent directory is ~/catkin_ws
3catkin_makeBuild workspaceBuild system initializes, creates build and devel folders
4source devel/setup.bashUpdate environment variablesROS environment updated to use new workspace
5-Workspace readyYou can now add ROS packages inside src and build
💡 All steps complete, workspace is created and environment is set
Variable Tracker
VariableStartAfter Step 1After Step 3After Step 4
DirectoriesNone~/catkin_ws, ~/catkin_ws/src~/catkin_ws/build, ~/catkin_ws/develNo change
Current DirectoryHome (~)~/catkin_ws~/catkin_ws~/catkin_ws
EnvironmentDefault ROS envNo changeNo changeUpdated to include workspace paths
Key Moments - 3 Insights
Why do we need to create the src folder inside the workspace?
The src folder is where ROS packages go; catkin_make expects this folder to find packages to build (see Step 1 in execution_table).
What does sourcing setup.bash do?
It updates your shell environment so ROS commands use the new workspace paths (see Step 4 in execution_table). Without this, ROS won't find your workspace packages.
Why run catkin_make after creating the workspace?
catkin_make initializes the workspace by creating build and devel folders and preparing the environment for packages (see Step 3).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what directories exist after Step 3?
A~/catkin_ws/src only
B~/catkin_ws/build and ~/catkin_ws/devel
CNo directories created yet
D~/catkin_ws/src and ~/catkin_ws/build only
💡 Hint
Check the 'Result' column for Step 3 in execution_table
At which step does the environment get updated to use the new workspace?
AStep 1
BStep 2
CStep 4
DStep 3
💡 Hint
Look for 'Update environment variables' in the 'Action' column
If you skip creating the src folder, what will happen when you run catkin_make?
Acatkin_make will fail or do nothing because no packages found
BThe environment will update anyway
Ccatkin_make will build normally
DThe workspace will be created without src
💡 Hint
Refer to the importance of src folder in key_moments and Step 1
Concept Snapshot
catkin workspace creation steps:
1. mkdir -p ~/catkin_ws/src (make workspace and src folder)
2. cd ~/catkin_ws (go to workspace)
3. catkin_make (build workspace, creates build and devel)
4. source devel/setup.bash (update environment to use workspace)
Now you can add ROS packages inside src and build them.
Full Transcript
To create a catkin workspace, first make a directory named catkin_ws with a src folder inside it. Then change into the workspace directory. Run catkin_make to build the workspace; this creates build and devel folders. Finally, source the setup.bash file in devel to update your environment so ROS commands use this workspace. After these steps, you can add ROS packages inside src and build them with catkin_make.

Practice

(1/5)
1. What is the purpose of creating a catkin workspace in ROS?
easy
A. To organize and build your ROS packages in one place
B. To install ROS system-wide dependencies
C. To run ROS nodes without any packages
D. To update the ROS core automatically

Solution

  1. Step 1: Understand what a catkin workspace is

    A catkin workspace is a folder where you keep your ROS packages organized and build them together.
  2. Step 2: Identify the purpose of the workspace

    It helps you manage your own ROS projects, not system-wide installations or running nodes without packages.
  3. Final Answer:

    To organize and build your ROS packages in one place -> Option A
  4. Quick Check:

    Workspace = Organize & build packages [OK]
Hint: Workspace holds your ROS projects and builds them [OK]
Common Mistakes:
  • Confusing workspace with system installation
  • Thinking workspace runs nodes alone
  • Assuming workspace updates ROS core
2. Which command correctly creates the source folder inside a catkin workspace named catkin_ws in your home directory?
easy
A. catkin_make ~/catkin_ws/src
B. mkdir ~/catkin_ws/src
C. mkdir -p ~/catkin_ws/src
D. source ~/catkin_ws/src

Solution

  1. Step 1: Understand the folder creation command

    The mkdir -p command creates the full directory path, including parent folders if missing.
  2. Step 2: Identify the correct command for creating src inside catkin_ws

    mkdir -p ~/catkin_ws/src uses mkdir -p ~/catkin_ws/src, which creates both catkin_ws and src if needed.
  3. Final Answer:

    mkdir -p ~/catkin_ws/src -> Option C
  4. Quick Check:

    Use mkdir -p for nested folders [OK]
Hint: Use mkdir -p to create nested folders at once [OK]
Common Mistakes:
  • Using mkdir without -p and missing parent folder
  • Confusing catkin_make with mkdir
  • Trying to source a folder instead of creating it
3. After creating your catkin workspace folder and src directory, what is the output of running catkin_make inside ~/catkin_ws?
medium
A. Error: src folder missing
B. Build successful with devel and build folders created
C. No output, command ignored
D. Workspace deleted

Solution

  1. Step 1: Understand what catkin_make does

    It builds the packages inside the src folder and creates devel and build folders for development and build files.
  2. Step 2: Predict output after running catkin_make in a valid workspace

    Since src exists, it will build successfully and create those folders.
  3. Final Answer:

    Build successful with devel and build folders created -> Option B
  4. Quick Check:

    catkin_make builds workspace and creates folders [OK]
Hint: catkin_make builds and creates devel/build folders [OK]
Common Mistakes:
  • Expecting error if src exists
  • Thinking catkin_make deletes workspace
  • Assuming no output or ignored command
4. You created a catkin workspace but forgot to source the setup file. What problem will you face?
medium
A. catkin_make will fail with syntax errors
B. The workspace will delete itself automatically
C. Your system will crash
D. ROS commands and packages from your workspace won't be recognized

Solution

  1. Step 1: Understand the role of sourcing the setup file

    Sourcing devel/setup.bash sets environment variables so ROS can find your workspace packages.
  2. Step 2: Identify the effect of not sourcing

    Without sourcing, ROS commands won't find your workspace packages, so they won't be recognized.
  3. Final Answer:

    ROS commands and packages from your workspace won't be recognized -> Option D
  4. Quick Check:

    Source setup file to use workspace [OK]
Hint: Always source setup.bash to use your workspace [OK]
Common Mistakes:
  • Thinking workspace deletes itself
  • Expecting catkin_make syntax errors
  • Assuming system crashes
5. You want to create a new catkin workspace named my_ws in your home directory and build it. Which sequence of commands is correct?
hard
A. mkdir -p ~/my_ws/src && cd ~/my_ws && catkin_make && source devel/setup.bash
B. cd ~/my_ws && mkdir src && catkin_make && source ~/my_ws/devel/setup.bash
C. mkdir ~/my_ws && catkin_make ~/my_ws/src && source ~/my_ws/setup.bash
D. mkdir -p ~/my_ws/src && catkin_make src && source ~/my_ws/devel/setup.bash

Solution

  1. Step 1: Create workspace and src folder correctly

    Use mkdir -p ~/my_ws/src to create both folders at once.
  2. Step 2: Navigate to workspace and build

    Change directory to ~/my_ws and run catkin_make to build the workspace.
  3. Step 3: Source the setup file

    Source devel/setup.bash inside the workspace to use the built packages.
  4. Final Answer:

    mkdir -p ~/my_ws/src && cd ~/my_ws && catkin_make && source devel/setup.bash -> Option A
  5. Quick Check:

    Create src, build, source setup.bash [OK]
Hint: Create src, cd workspace, catkin_make, then source setup.bash [OK]
Common Mistakes:
  • Running catkin_make outside workspace folder
  • Not sourcing the correct setup file
  • Using wrong paths in commands
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard