一般项目结构: . ├── build ├── install ├── log └── src 只有src是自己要写的,其他都是colcon构建的,不要随便改动

一般创建workspace流程 先用 rosdep install -i –from-path src –rosdistro lyrical -y 保证src里的依赖没问题

然后 colcon build –packages-up-to builds the package you want, plus all its dependencies, but not the whole workspace (saves time) –symlink-install saves you from having to rebuild every time you tweak python scripts –event-handlers console_direct+ shows console output while building (can otherwise be found in the log directory) –executor sequential processes the packages one by one instead of using parallelism 构建workspcae

构建好后就要,在shell中使用overlay的workspace了 source install/local_setup.bash

注意,假如更改src后,需要重新colcon build时,一定不要在overlay workspace(就是刚刚构建的workspace上),要在更低一层的workspace里构建

package构建,在src下 ros2 pkg create –build-type ament_cmake –license Apache-2.0 <package_name> 记得修改package.xml好发布