当前位置: 首页 > news >正文

ROS2进阶:colcon的初步使用--‘colcon‘ is not recognized

系统安装路径:C:\opt\ros\galactic

系统安装参考:ROS2在windows上的安装。

如果你是按ROS官网的办法安装的,路径可能会有所不同,比如按

Installing ROS 2 on Windows — ROS 2 Documentation: Galactic documentation

此时的路径会是,

C:\dev\ros2_galactic

不管你按哪个办法安装,使用起来都差不多。

首先检查一下你是否安装了必要的工具,例如,你可能会碰到这样的报错,

ERROR: 'colcon' is not recognized as an internal or external command,

colcon是依赖python的,那说明你没有安装colcon脚本,或者,你没有在系统路径中添加这个:C:\Python38\Scripts。下面的把一些常用的脚本例在下面,

pip install -U colcon-common-extensions
pip install -U vcstool

貌似各个版本的ROS2文档都有些区别,比如eloquent就单独列出了这些命令,但foxy和galactic就没有,

Building ROS 2 on Windows — ROS 2 Documentation: Eloquent documentation

安装好了之后,你就可以正常使用colcon了,检查一下,

C:>colcon
usage: C:\Python38\Scripts\colcon [-h] [--log-base LOG_BASE] [--log-level LOG_LEVEL]
                                  {build,extension-points,extensions,graph,info,list,metadata,test,test-result,version-check} ...

Error: No verb provided

另外,如果你碰到找不到vc之类的问题,通常是因为没有启动VS2019或VS2017的环境,

call "C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Auxiliary\Build\vcvarsall.bat" x86_amd64

 为了避免这个麻烦,我通常都是直接在VS2019命令窗口"x64 Native Tools Command Prompt for VS 2019" 中进行操作。

什么是colcon?

在ROS2中的构建工具是colcon,这非常类似我们在ROS中使用的catkin_make。

下面我们打开一个命令窗口,

call C:\opt\ros\galactic\x64\setup.bat

然后,新建一个路径

~> mkdir  examples_ws\src
~> cd  examples_ws\src
~examples_ws\src>  git clone -b galactic-devel https://github.com/ros2/examples.git
~examples_ws\src>  cd ..
~examples_ws>  colcon build

另外,我们也可以试一下那个demos

~> mkdir  demos_ws\src
~> cd  demos_ws\src
~demos_ws\src>  git clone -b galactic-devel https://github.com/ros2/demos.git
~demos_ws\src>  cd ..
~demos_ws>  colcon build

比如我第一次构建的结果是这样的,

D:\ros2prj\demo_ws>colcon build
[0.755s] root DEBUG Using proactor: IocpProactor
Starting >>> action_tutorials_interfaces
Starting >>> dummy_map_server
Starting >>> dummy_sensors
Starting >>> pendulum_msgs
Starting >>> composition
Starting >>> demo_nodes_cpp
Starting >>> demo_nodes_cpp_native
Starting >>> demo_nodes_py
Starting >>> image_tools
Starting >>> intra_process_demo
Starting >>> lifecycle
Starting >>> logging_demo
Finished <<< demo_nodes_py [1.61s]
Starting >>> quality_of_service_demo_cpp
Finished <<< dummy_map_server [4.20s]
Starting >>> quality_of_service_demo_py
Finished <<< dummy_sensors [4.80s]
Starting >>> topic_monitor
Finished <<< lifecycle [5.20s]
Starting >>> topic_statistics_demo
Finished <<< quality_of_service_demo_py [1.34s]
Starting >>> dummy_robot_bringup
Finished <<< topic_monitor [1.34s]
Finished <<< pendulum_msgs [7.11s]
Starting >>> pendulum_control
Finished <<< action_tutorials_interfaces [7.36s]
Starting >>> action_tutorials_cpp
Starting >>> action_tutorials_py
Finished <<< dummy_robot_bringup [1.99s]
Finished <<< action_tutorials_py [2.16s]
Failed   <<< demo_nodes_cpp_native [10.1s, exited with code 1]
Aborted  <<< image_tools [11.6s]
Aborted  <<< demo_nodes_cpp [12.0s]
Aborted  <<< composition [12.7s]
Aborted  <<< intra_process_demo [13.9s]
Aborted  <<< quality_of_service_demo_cpp [13.3s]
Aborted  <<< topic_statistics_demo [10.8s]
Aborted  <<< logging_demo [16.0s]
Aborted  <<< pendulum_control [9.20s]
Aborted  <<< action_tutorials_cpp [11.2s]

Summary: 10 packages finished [18.9s]
  1 package failed: demo_nodes_cpp_native
  9 packages aborted: action_tutorials_cpp composition demo_nodes_cpp image_tools intra_process_demo logging_demo pendulum_control quality_of_service_demo_cpp topic_statistics_demo

官方介绍

官方资料可以去这里,

colcon - collective construction — colcon documentation

或者

GitHub - colcon/colcon.readthedocs.org

一些常用的colcon参数

参考:

build - Build Packages — colcon documentation

colcon提供了很多的参数选项,大家可以去官网查看,这里我不再逐一翻译 ,只是简单枚举一下官网的内容,

目前遇到常用参数:

1.--symlink-install     :使用符号链接而不是复制文件,如

 以动态链接库为例,会在install目录中使用符号链接,指向build目录下生成的库文件(如 *.so). 没有该选项,则两个目录都会有该库文件

2.--packages-select :只编译指定包,如

colcon build --packages-select  autoware_map_msgs  vector_map_msgs
3.--packages-ignore  : 忽略指定包,同上

4. --continue-on-error :在编译出错之后继续编译其他模块

5. --cmake-args ,--ament-cmake-args, --catkin-cmake-args :传递参数给对应的package

针对cmake参数,常用的有

 -DCMAKE_BUILD_TYPE=Release
 
 -DCMAKE_CXX_FLAGS="-O2 -g -Wall " 
  “-D” --宏定义, 每定义一个就在前边加上"-D",给gcc传递参数

   -g  debug选项, gdb模式,符号表会保存

  -s    link选项,删除符号表,这一步会极大减少文件体积

下面为colcon官网上的原英文解释。

build - Build Packages

The build verb is building a set of packages. It is provided by the colcon-core package.

Command line arguments

These common arguments can be used:

  • executor arguments
  • event handler arguments
  • discovery arguments
  • package selection arguments
  • mixin arguments

Additionally, the following specific command line arguments can be used:

--build-base BUILD_BASE

The base path for all build directories. The default value is ./build. Each package uses a subdirectory in that base path as its package specific build directory.

--install-base INSTALL_BASE

The base path for all install prefixes. The default value is ./install.

--merge-install

Use the --install-base as the install prefix for all packages instead of a package specific subdirectory in the install base.

Without this option each package will contribute its own paths to environment variables which leads to very long environment variable values.

With this option most of the paths added to environment variables will be the same, resulting in shorter environment variable values.

The disadvantage of using this option is that it doesn’t provide proper isolation between packages. For example declaring a dependency on one package also allows access to resources from other packages installed in the same install prefix (without requiring a declared dependency).

Note: on Windows using cmd this argument should be used for workspaces with many packages otherwise the environment variables might exceed the supported maximum length.

--symlink-install

Use symlinks instead of copying files from the source and build directories where possible.

--test-result-base TEST_RESULT_BASE

The base path for all test results. The default value is the --build-base argument. Each package uses a subdirectory in that base path as its package specific test result directory.

--continue-on-error

Continue building other packages when a package fails to build. Packages recursively depending on the failed package are skipped.

CMake specific arguments

The following arguments are provided by the colcon-cmake package:

--cmake-args [* [* …]]

Pass arbitrary arguments to CMake projects. Arguments matching other options must be prefixed by a space, e.g. --cmake-args " --help".

--cmake-target CMAKE_TARGET

Build a specific target instead of the default target. To avoid packages which don’t have that target causing the build to fail, also pass –cmake-target-skip-unavailable.

--cmake-target-skip-unavailable

Skip building packages which don’t have the target passed to –cmake-target.

--cmake-clean-cache

Remove the CMake cache file CMakeCache.txt from the build directory before proceeding with the build. This implicitly forces a CMake configure step.

--cmake-clean-first

Build the target clean first, then proceed with a regular build. To only invoke the clean target use –cmake-target clean.

--cmake-force-configure

Force CMake configure step.

ROS ament_cmake specific arguments

The following arguments are provided by the colcon-ros package:

--ament-cmake-args [* [* …]]

Pass arbitrary arguments to ROS packages with the build type ament_cmake. Arguments matching other options must be prefixed by a space, e.g. --ament-cmake-args " --help".

ROS catkin specific arguments

The following arguments are provided by the colcon-ros package:

--catkin-cmake-args [* [* …]]

Pass arbitrary arguments to ROS packages with the build type catkin. Arguments matching other options must be prefixed by a space, e.g. --catkin-cmake-args " --help".

--catkin-skip-building-tests

By default the tests target building the tests in catkin packages is invoked. If running colcon test later isn’t intended this can be skipped.

未完待续
 

相关文章:

  • ROS2进阶:基本指令与RVIZ2介绍
  • Windows控制台cmd默认代码页修改的办法【GBK、UTF-8】
  • ROS2 ERROR: qt.qpa.plugin: Could not find the Qt platform plugin “windows“ in
  • ROS2 Warning: RosPluginProvider._parse_plugin_xml() plugin file rqt_gui_cpp/plugin.xml not found
  • ROS2进阶:turtlesim与rqt
  • TCP/UDP常见的端口号
  • ROS2进阶:基于cmake创建自己的开发包
  • ROS2进阶:如何查找特定的包(package)并列出包中所有节点(node)
  • ROS2进阶:VS2019调试ROS2-examples程序
  • Python Error: 系统找不到指定的文件。: ‘c:\\python38\\Scripts\\pep8.exe‘ -> ‘c:\\python38\\Scripts\\pep8.exe.del
  • Ubuntu中如何处理难缠的软件包升级
  • 3D进阶之OSG:从VS2019编译osgEarth开始
  • vcpkg如何全面卸载和重新安装包
  • 3D进阶之OSG: VS2019编译OpenSceneGraph
  • 3D进阶之OSG: 编译osgQt(附:Qt的下载与安装)
  • 0基础学习移动端适配
  • 30天自制操作系统-2
  • Android Studio:GIT提交项目到远程仓库
  • Angular4 模板式表单用法以及验证
  • iOS筛选菜单、分段选择器、导航栏、悬浮窗、转场动画、启动视频等源码
  • JS专题之继承
  • Logstash 参考指南(目录)
  • Mysql数据库的条件查询语句
  • Python学习笔记 字符串拼接
  • vue脚手架vue-cli
  • 阿里研究院入选中国企业智库系统影响力榜
  • 代理模式
  • 数据可视化之 Sankey 桑基图的实现
  • 王永庆:技术创新改变教育未来
  • 系统认识JavaScript正则表达式
  • 小程序开发之路(一)
  • 一些基于React、Vue、Node.js、MongoDB技术栈的实践项目
  • ​力扣解法汇总946-验证栈序列
  • #{}和${}的区别?
  • #pragma预处理命令
  • #预处理和函数的对比以及条件编译
  • ()、[]、{}、(())、[[]]等各种括号的使用
  • (13)[Xamarin.Android] 不同分辨率下的图片使用概论
  • (4)事件处理——(2)在页面加载的时候执行任务(Performing tasks on page load)...
  • (Bean工厂的后处理器入门)学习Spring的第七天
  • (HAL)STM32F103C6T8——软件模拟I2C驱动0.96寸OLED屏幕
  • (MATLAB)第五章-矩阵运算
  • (附源码)php投票系统 毕业设计 121500
  • (黑马C++)L06 重载与继承
  • (六)vue-router+UI组件库
  • (转)jQuery 基础
  • .NET Compact Framework 3.5 支持 WCF 的子集
  • .NET8.0 AOT 经验分享 FreeSql/FreeRedis/FreeScheduler 均已通过测试
  • @media screen 针对不同移动设备
  • [ 常用工具篇 ] POC-bomber 漏洞检测工具安装及使用详解
  • [2017][note]基于空间交叉相位调制的两个连续波在few layer铋Bi中的全光switch——
  • [2018-01-08] Python强化周的第一天
  • [Android Pro] Notification的使用
  • [Angular] 笔记 16:模板驱动表单 - 选择框与选项
  • [BUUCTF NewStarCTF 2023 公开赛道] week4 crypto/pwn