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

After revising what I had written, I found many minor things that were wrong, so I rewrote in the following way, and now it works like a charm:

def __init__(self):
     ......
     self.server = actionlib.SimpleActionServer(rospy.get_name(), doMeFavorAction, self.execute, False)
     self.server.start()

def done(self, state, result):
    print state
    print result 

def active(self):
    print 'Goal just sent!'

def feedback(self, feedback):
    print 'Feedback: %f\n' % feedback.percent_complete

def test_action_server(self):
    client = actionlib.SimpleActionClient('/robot2/brain_node', doMeFavorAction)
    client.wait_for_server()
    print rospy.get_name()
    print 'I am requesting a favor'
    goal = doMeFavorGoal(3500)
    print str(goal)
    print goal

        client.send_goal(goal, self.done, self.active, self.feedback)

def execute(self, goal):
    # Do lots of awesome groundbreaking robot stuff here
    print goal.dishwasher_id
    feedback = doMeFavorFeedback()
    result = doMeFavorResult()
    percent = 0
    while percent < 100.0:
        percent = percent + 10.0
        feedback.percent_complete = percent
        self.server.publish_feedback(feedback)
    result.total_dishes_cleaned = 30
    self.server.set_succeeded(result)