Note: This tutorial assumes that you have completed the previous tutorials: 编写一个简单的行为(action)客户端.
(!) Please ask about problems and questions regarding this tutorial on answers.ros.org. Don't forget to include in your question the link to this page, the versions of your OS & ROS, and also add appropriate tags.

运行行为客户端和服务器

Description: 本教程涵盖了运行Fibonacci服务器和客户端,随后通过可视化工具查看输出通道和节点图。

Tutorial Level: BEGINNER

Next Tutorial: 使用Execute Callback (Python)编写一个简单的行为服务器

  Show EOL distros: 

查看行为反馈

首先,和之前的教程一样,运行行为服务器 (C++ | Python) 和客户端(C++ | Python),和roscore一起运行。

在一个新的终端中,使用rostopic查看行为服务器的反馈通道:

$ rostopic echo /fibonacci/feedback

同时服务器将作用目标,并且你会看到类似于如下输出:

  • ---
    header: 
      seq: 1
      stamp: 1250813676611629000
      frame_id: 
    status: 
      goal_id: 
        stamp: 1250813676611339000
        id: 1250813676611339000
      status: 1
      text: 
    feedback: 
      sequence: (0, 1, 1)
    ---
    header: 
      seq: 2
      stamp: 1250813677611559000
      frame_id: 
    status: 
      goal_id: 
        stamp: 1250813676611339000
        id: 1250813676611339000
      status: 1
      text: 
    feedback: 
      sequence: (0, 1, 1, 2)
    ---
    header: 
      seq: 3
      stamp: 1250813678611635000
      frame_id: 
    status: 
      goal_id: 
        stamp: 1250813676611339000
        id: 1250813676611339000
      status: 1
      text: 
    feedback: 
      sequence: (0, 1, 1, 2, 3)
    ---

查看行为结果

在一个新的终端中,使用rostopic查看行为服务器的反馈通道:

$ rostopic echo /fibonacci/result

当一个目标完成后,你将看到类似于如下输出:

  • ---
    header: 
      seq: 1
      stamp: 1250813759950015000
      frame_id: 
    status: 
      goal_id: 
        stamp: 1250813739949752000
        id: 1250813739949752000
      status: 3
      text: 
    result: 
      sequence: (0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946)

查看行为节点图

或者你可以看看节点在服务器和客户端运行情况:

$ rxgraph

$ rxgraph

rqt_graph

fibonacci_client_server.png

运行客户端和服务器

运行行为服务器:

$ rosrun actionlib_tutorials fibonacci_server

当行为完成后,将会打印成功消息信息到屏幕上。

  • [ INFO] 1251489514.736936000: /fibonacci: Succeeded

然后运行行为客户端:

$ rosrun actionlib_tutorials fibonacci_client

当客户端接收到完成目标通告时,它将会打印行为结果消息到屏幕上。

  • [ INFO] 1251489514.737339000: Action finished: SUCCEEDED

Wiki: cn/actionlib_tutorials/Tutorials/RunningServerAndClient (last edited 2017-03-19 04:04:41 by Playfish)