ROS2 foxy 学习5 : Action 行动

本文详细介绍了ROS2中的动作(action)和服务(service)的区别,强调了动作的预抢占性和周期反馈功能,以及在机器人导航和任务执行中的应用实例。重点讲解了发送action goal、查看接口信息和常用命令,展示了如何使用ros2action进行交互操作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

也是节点node之间的一种通讯方式

每个节点自己实现了action 客户端 或服务端。

客户端发起请求,action(后台中心)转发给 服务端节点

服务端node处理、执行action动作

客户端节点发起请求(询问动作执行的结果)

服务端node 响应请求 分两步

  • (1.通过topic 持续返回当前执行的状态
  • 2.动作执行结束了, 返回服务的响应报文。)

和服务的区别:

  1. 可以抢占
  2. 稳定周期反馈, 过程的结果(进度)。服务只有一个反馈

Actions are built on topics and services. Their functionality is similar to services, except actions are preemptable 抢占(you can cancel them while executing). They also provide steady feedback, (稳定的反馈,而服务,只返回一个结果)as opposed to services which return a single response.

可以看到下图: 开始action(服务通讯), 请求结果(服务通讯), feedback( topic通讯)

Actions are like services that allow you to execute long running tasks, provide regular feedback, and are cancelable.

行动通讯,和服务通讯一样,可以执行 耗时间的任务,周期的提供反馈结果。同时任务可以取消。

A robot system would likely use actions for navigation. An action goal could tell a robot to travel to a position. While the robot navigates to the position, it can send updates along the way (i.e. feedback), and then a final result message once it’s reached its destination.

很自然,行动通讯,可以用在机器人导航、轨迹跟踪!。设定一个target的, 一路tracking过去。期间返回当前状态变量。

常用命令:

ros2 action list -t

/turtle1/rotate_absolute [turtlesim/action/RotateAbsolute]

前面是action name , 后面是action type的内容

ros2 action info <action name xx> (查看action 是谁是客户端,谁是服务端)

Action: /turtle1/rotate_absolute  action name
Action clients: 1
    /teleop_turtle
Action servers: 1
    /turtlesim

ros2 interface show turtlesim/action/RotateAbsolute

数据结构定义

# The desired heading in radians
float32 theta  这个是请求命令 (目标值)
---
# The angular displacement in radians to the starting position
float32 delta (这个是 结果)
---
# The remaining rotation in radians
float32 remaining  (这个是topic : feedback)

ros2 action send_goal <action_name> <action_type> <values>

 <values> need to be in YAML format.

ros2 action send_goal /turtle1/rotate_absolute turtlesim/action/RotateAbsolute "{theta: 1.57}"

看一下rqt_graph, action request 没显示,因为,之前请求了action goal

归纳:

ros2 topic pub <node name> <message> <value>

ros2 service call <service name> <servie type >< value>

ros2 action send_goal <action name> <action type> <value>

至此, ROS 核心的概念,就这么多。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值