actionlib的概念和作用:
ROS wiki的解释为:
In any large ROS based system, there are cases when someone would like to send a request to a node to perform some task, and also receive a reply to the request. This can currently be achieved via ROS services.
In some cases, however, if the service takes a long time to execute, the user might want the ability to cancel the request during execution or get periodic feedback about how the request is progressing. The actionlib package provides tools to create servers that execute long-running goals that can be preempted. It also provides a client interface in order to send requests to the server.
译:在任何基于ros的大型系统中,都存在这样的情况:有人希望向节点发送请求以执行某些任务,同时也希望收到对请求的回复。这目前可以通过ros server实现。
但是,在某些情况下,如果服务需要很长时间才能执行,则用户可能希望能够在执行期间取消请求,或获得有关请求进度的定期反馈。actionlib包提供了创建servers的工具,这些servers执行可以抢占的长期运行目标。它还提供了一个client接口,以便向服务器发送请求。
actionlib设计的目的在于在ROS server机制之上提供可以控制中断以及过程中的反馈的机制,从而使整个系统不会因为某个任务执行时间过长而导致整个系统的阻塞。
我们将此特性应用到ROS系统和机器人底层控制之间的通信上,从而保证上位机对下位机的实时监控。
actionlib的运行机制
如图,整体的运行机制为:Action Client发送goal请求,Action Server接受并执行goal请求。同时客户端也可以下发cancel请求,服务端会在必要的时刻上报(给客户端)当前的status,result,feedback。
ROS wiki中关于这些消息内容的解释:
Goal
To accomplish tasks using actions, we introduce the notion of a goal that can be sent to an ActionServer by an ActionClient. In the case of moving the base, the goal would be a PoseStamped message that contains information about where the robot should move to in the world. For controlling the tilting laser scanner, the goal would contain the scan parameters (min angle, max angle, speed, etc).
Feedback
Feedback provides server implementers a way to tell an ActionClient about the incremental progress of a goal. For moving the base, this might be the robot’s current pose along the path. For controlling the tilting laser scanner, this might be the time left until the scan completes.
Result
A result is sent from the ActionServer to the ActionClient upon completion of the goal. This is different than feedback, since it is sent exactly once. This is extremely useful when the purpose of the action is to provide some sort of information. For move base, the result isn’t very important, but it might contain the final pose of the robot. For controlling the tilting laser scanner, the result might contain a point cloud generated from the requested scan.
在我们设计的机器人系统中:
- goal 各个关节的目标位置以及到达目标位置的速度
- cancel 取消当前目标指令
. - result goal指令是否执行成功
- status 当前机器人主体是否空闲、工作、故障
- feedback 对机器人主体各个关节位置和速度的实时反馈
其中,result和feedback需求澄清的一点是:
result只在整个交互中由server发送一次,用来告诉client下发的goal是否执行成功,而feedback是在整个执行过程中多次发送,反馈的内容为当前运行的角度和速度等信息。
主要的逻辑已经描述完成,ROS wiki提供了官方实例。
后边会更新我自己设计的面向双臂机器人的整个框架,待续。。。