工作空间是包含ROS 2软件的文件夹。在使用ROS 2之前，必须在正在使用的终端中配置ROS 2工作区（包括系统和局部），使ROS 2的软件包可在此终端中使用。如上图所示，foxy/noetic分别为ros2和ros1的系统工作区，使用如下命令可以顺利加载配置：
- source /opt/ros/foxy/setup.bash
- rosdep install -i --from-path src --rosdistro foxy -y
- colcon build
- source install/setup.bash
- You also have the option of sourcing an “overlay” – a secondary workspace where you can add new packages without interfering with the existing ROS 2 workspace that you’re extending, or “underlay”. Your underlay must contain the dependencies of all the packages in your overlay. Packages in your overlay will override packages in the underlay. It’s also possible to have several layers of underlays and overlays, with each successive overlay using the packages of its parent underlays.
- Sourcing the
local_setupof the overlay will only add the packages available in the overlay to your environment.
setupsources the overlay as well as the underlay it was created in, allowing you to utilize both workspaces.So, sourcing your main ROS 2 installation’s
setupand then the
local_setup, like you just did, is the same as just sourcing
setup, because that includes the environment of the underlay it was created in.