【ROS2】中级-创建一个动作

目标:在 ROS 2 包中定义一个动作。

教程级别:中级

 时间:5 分钟

 目录

  •  背景

  •  先决条件

  •  任务

    • 1. 创建一个接口包

    • 2. 定义一个动作

    • 3. 构建动作

  •  摘要

  •  下一步

  •  相关内容

 背景

您之前已经在了解动作教程中学习了有关动作的内容。就像其他通信类型及其各自的接口(主题/msg 和服务/srv)一样,您也可以在您的包中自定义动作。本教程将向您展示如何定义和构建一个动作,您可以在下一个教程中编写的动作服务器和动作客户端中使用它。

先决条件

您应该安装 ROS 2 和 colcon。

您应该知道如何设置工作区并创建包。

记得首先配置你的 ROS 2 安装环境。

 任务

1. 创建一个接口包

mkdir -p ~/ros2_ws/src # you can reuse an existing workspace with this naming convention
cxy@ubuntu2404-cxy:~$ cd ~/ros2_ws/src
cxy@ubuntu2404-cxy:~/ros2_ws/src$ ros2 pkg create --license Apache-2.0 custom_action_interfaces
going to create a new package
package name: custom_action_interfaces
destination directory: /home/cxy/ros2_ws/src
package format: 3
version: 0.0.0
description: TODO: Package description
maintainer: ['cxy <cxy@todo.todo>']
licenses: ['Apache-2.0']
build type: ament_cmake
dependencies: []
creating folder ./custom_action_interfaces
creating ./custom_action_interfaces/package.xml
creating source and include folder
creating folder ./custom_action_interfaces/src
creating folder ./custom_action_interfaces/include/custom_action_interfaces
creating ./custom_action_interfaces/CMakeLists.txt

2.定义一个动作

行动定义在 .action 形式的文件中:


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值