ROS Workspace
ROS 工作空间AdvancedA directory convention for holding, building, and installing your own ROS packages.
A workspace is ROS's directory convention for organizing code: a top-level src folder holds the source of packages (a package being ROS's smallest unit of code), and building it produces build (intermediate files), install or devel (the built output), and log directories. ROS 1 builds with catkin, and the workspace is conventionally named catkin_ws; ROS 2 builds with colcon, and it's usually called ros2_ws. After building, you have to source the corresponding setup script before the terminal can find the packages inside. Workspaces can be overlaid: you source the system-installed ROS (the underlay) first, then your own workspace on top, and if a package exists in both, the top one wins. The single most common beginner mistake is forgetting to source, or sourcing things in the wrong order.
Examplemkdir -p ~/ros2_ws/src, clone your code into src, run colcon build from ros2_ws, then source install/setup.bash — after that, ros2 run can find your own node.
- Also called
- catkin_ws, ros2_ws, colcon workspace
- Related
- Package (ROS) · colcon · catkin · ament · rosdep · Robot Operating System 2
- Sources
- ROS 2 Docs: Creating a workspace
ROS Wiki: catkin workspaces