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
相关推荐
kobesdu1 天前
【ROS2实战笔记-14】多机器人系统的三层工具箱:从零基础集群到跨仿真实现
笔记·机器人·ros
dragen_light1 天前
6.ROS2-topic
ros
爱凤的小光6 天前
ROS Service ---个人学习篇
ros
绍磊leo10 天前
ROS2 交互式调试工具:告别繁琐的命令行操作
ros
kobesdu10 天前
连接大模型与物理机器人-RoboNeuron让机器人真正“听懂人话”
机器人·开源·ros·人形机器人
kobesdu10 天前
【ROS2实战笔记-13】Foxglove Studio:ROS可视化工具的另一条路
笔记·机器人·自动驾驶·ros
kobesdu11 天前
【ROS2实战笔记-12】rosshow:终端里的盲文可视化与无头机器人的现场调试
笔记·机器人·ros·移动机器人
txz203512 天前
2,使用功能包组织C++节点
开发语言·c++·ros
dragen_light15 天前
2.ROS2-Packages
ros
dragen_light15 天前
1.ROS2-Install
c++·python·ros