ros2与Python入门教程-创建动作
ros2与Python入门教程-创建动作
说明:
- 介绍如何创建动作
步骤:
- 与ros1类似,创建一个.action文件,格式如下:
# Request
---
# Result
---
# Feedback
- 创建包
cd ~/dev_ws/src
ros2 pkg create action_tutorials
- 创建action目录,新建action文件
mkdir action_tutorials/action
vim action/Fibonacci.action
- 内容如下:
int32 order
---
int32[] sequence
---
int32[] partial_sequence
- 增加CMakeLists.txt,增加如下:
find_package(rosidl_default_generators REQUIRED)
rosidl_generate_interfaces(${PROJECT_NAME}
"action/Fibonacci.action"
)
- 变更package.xml,增加如下:
<buildtool_depend>rosidl_default_generators</buildtool_depend>
<depend>action_msgs</depend>
<member_of_group>rosidl_interface_packages</member_of_group>
- 编译
colcon build --pakages-select action_tutorials
- 新开终端,执行,检测是否创建成功
. install/setup.bash
ros2 interface show action_tutorials/action/Fibonacci
获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号