← Back to search

[ROS in 5 mins] 033 - How to create a ROS Action Server

The Construct Robotics Institute 13:42

11,029 views · 75 likes Watch on YouTube ↗

We're going learn how to create a ROS Action Server.

Check out the full code and more info here: http://www.theconstructsim.com/ros-5-mins-033-create-ros-action-server/

For that we are going to use Robot Ignite Academy, which is the best tool if you want Learn ROS Fast: http://www.theconstructsim.com/construct-learn-develop-robots-using-ros/robotigniteacademy_learnros/

Before we start, if you are new to ROS, I highly recommend you to take any of the following courses on Robot Ignite Academy:

ROS Basics In 5 Days (Python) - http://www.theconstructsim.com/construct-learn-develop-robots-using-ros/robotigniteacademy_learnros/ros-courses-library/ros-basics-in-5-days/
ROS Basics In 5 Days (C++) - http://www.theconstructsim.com/construct-learn-develop-robots-using-ros/robotigniteacademy_learnros/ros-courses-library/ros-courses-ros-basics-in-5-days-c/

To know how to compile your own ROS Action messages, please check this video: https://youtu.be/XOSX3Z6qkok

The code used in this video is the following:



#! /usr/bin/env python

import rospy
import actionlib
from actions_tutorial.msg import WashTheDishesAction, WashTheDishesFeedback, WashTheDishesResult

class ActionServer():

def __init__(self):
self.a_server = actionlib.SimpleActionServer(
"wash_dishes_as", WashTheDishesAction, execute_cb=self.execute_cb, auto_start=False)
self.a_server.start()


def execute_cb(self, goal):

success = True
last_dish_washed = ''
dishes_washed = []
feedback = WashTheDishesFeedback()
result = WashTheDishesResult()
rate = rospy.Rate(1)

for i in range(0, goal.number_of_minutes):
if self.a_server.is_preempt_requested():
self.a_server.set_preempted()
success = False
break

last_dish_washed = 'bowl-' + str(i)
feedback.last_dish_washed = last_dish_washed
result.dishes_washed.append(last_dish_washed)
self.a_server.publish_feedback(feedback)
rate.sleep()

if success:
self.a_server.set_succeeded(result)



if __name__ == "__main__":
rospy.init_node("action_server")
s = ActionServer()
rospy.spin()





We love feedback, so, whether you like the video or not, please share your thoughts on the comments section below.

Thanks for watching.

Category (YouTube): Science & Technology

Playback is via YouTube's official embedded player. Data from YouTube; Exumo is not affiliated with YouTube.