您当前的位置: 首页 > 
  • 2浏览

    0关注

    483博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

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

高精度计算机视觉 发布时间:2022-03-24 22:34:25 ,浏览量:2

系统安装路径: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 > quality_of_service_demo_cpp
Finished > quality_of_service_demo_py
Finished > topic_monitor
Finished > topic_statistics_demo
Finished > dummy_robot_bringup
Finished  action_tutorials_cpp
Starting >>> action_tutorials_py
Finished             
关注
打赏
1661664439
查看更多评论
0.0621s