ROS2humble版本使用colcon构建包

colcon与与catkin相比,没有 **devel**目录。

创建工作空间

首先,创建一个目录 ( ros2_example_ws ) 来包含我们的工作区:

复制代码
mkdir -p ~/ros2_example_ws/src
cd ~/ros2_example_ws

此时,工作区包含一个空目录 src :

复制代码
.
└── src

1 directory, 0 files

让我们将 examples 仓库克隆到工作区的 src 目录中:

复制代码
git clone https://github.com/ros2/examples src/examples

现在工作区应该有 ROS 2 examples 的源代码了:

复制代码
.
└── src
    └── examples
        ├── CONTRIBUTING.md
        ├── LICENSE
        ├── rclcpp
        ├── rclpy
        └── README.md

4 directories, 3 files

通过source添加依赖

复制代码
source /opt/ros/humble/setup.bash

开始构建

复制代码
colcon build --symlink-install

构建完成后,我们应该会看到 buildinstalllog 目录:

复制代码
.
├── build
├── install
├── log
└── src

4 directories, 0 files

运行测试

要对我们刚刚构建的包运行测试,请运行以下命令:

复制代码
colcon test

尝试例程

第一个终端运行一个订阅服务器节点:

复制代码
ros2 run examples_rclcpp_minimal_subscriber subscriber_member_function

在另一个终端中,让我们运行一个发布程序节点

复制代码
ros2 run examples_rclcpp_minimal_publisher publisher_member_function
相关推荐
别让别人觉得你做不到8 天前
Ros工作空间
ros
吃水果不削皮14 天前
VINS-FUSION:跑通手机录制数据
ros·vio
Mr.Winter`16 天前
无人船 | 图解基于LQR控制的路径跟踪算法(以全驱动无人艇WAMV为例)
人工智能·算法·机器人·ros·ros2·运动规划·无人船
Stuomasi_xiaoxin21 天前
如何Ubuntu 22.04.5 LTS 64 位 操作系统部署运行SLAM3! 详细流程
linux·运维·ubuntu·ros·slam3
Mr.Winter`21 天前
无人船 | 图解基于PID控制的路径跟踪算法(以欠驱动无人艇Otter为例)
人工智能·算法·机器人·自动驾驶·ros·ros2·无人船
MocapLeader23 天前
新型多机器人协作运输系统,轻松应对复杂路面
机器人·ros·强化学习·多机器人协同·协同搬运
Mr.Winter`23 天前
无人船 | 图解基于PID控制的路径跟踪算法(以全驱动无人艇WAMV为例)
人工智能·机器人·ros·ros2·路径规划·无人船
sanzk1 个月前
Ubuntu18.04 ROS Melodic安装
ros
kyle~1 个月前
ROS2---std_msgs基础消息包
开发语言·python·机器人·ros·机器人操作系统
hillstream31 个月前
ROS2学习笔记1-起步的程序
ros·ros2