ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Now someone suggested using a service to perform the action - the service performs the action in the appropriate way, and returns some feedback, and responds to the main program.

Took me awhile to understand what you mean by above, but I think you mean "'an end client' calls ROS Service, then Service server calls ROS Action, and return Action's output via ROS Service' return value".

If that's correct, I think that's a legit usecase in certain situation e.g. when the end client doesn't have an access to the existing Action Server. You can run Action Client somehow in your ROS Service' callback, then once the Action Client returns the value, re-pack the value to the ROS Service and return it.

Following can be a simple pseudo-code in Python that I modified the code from the Service' tutorial:

#!/usr/bin/env python
import actionlib
from beginner_tutorials.srv import *
import rospy

def handle_add_two_ints(req):
    # Call action client's sendGoal

    # Return with the output action client received.

def add_two_ints_server():
    rospy.init_node('add_two_ints_server')
    s = rospy.Service('add_two_ints', AddTwoInts, handle_add_two_ints)
:

Now someone suggested using a service to perform the action - the service performs the action in the appropriate way, and returns some feedback, and responds to the main program.

Took me awhile to understand what you mean by above, but I think you mean "'an end client' calls ROS Service, then Service server calls ROS Action, and return Action's output via ROS Service' return value".

If that's correct, I think that's a legit usecase in certain situation e.g. when the end client doesn't have an access to the existing Action Server. Server (although I've never done that). You can run Action Client somehow in your ROS Service' callback, then once the Action Client returns the value, re-pack the value to the ROS Service and return it.

Following can be a simple pseudo-code in Python that I modified the code from the Service' tutorial:

#!/usr/bin/env python
import actionlib
from beginner_tutorials.srv import *
import rospy

def handle_add_two_ints(req):
    # Call action client's sendGoal

    # Return with the output action client received.

def add_two_ints_server():
    rospy.init_node('add_two_ints_server')
    s = rospy.Service('add_two_ints', AddTwoInts, handle_add_two_ints)
: