def __init__(self, actions=None, connect_arbitrator=True): # Instantiate the action clients if actions is None: self.actions = get_default_actions() else: self.actions = actions # Provide a service to reload, and then reload self._reload_service = rospy.Service('~reload', Trigger, self.reload) self.reload(None) # Connect to the arbitrator only if needed self._arbitration_client = self._arbitration_connector = None if connect_arbitrator: # Instantiate a connection to the arbitration server self._arbitration_connector = actionlib.SimpleActionClient( TaskServer.ASSISTANCE_ARBITRATOR_ACTION_SERVER, RequestAssistanceAction ) self._arbitration_connector_timer = None # Instantiate the action server self._server = actionlib.SimpleActionServer( rospy.get_name(), ExecuteAction, self.execute, auto_start=False )
def __init__(self): # Load the actions that are available to us self.actions = get_default_actions() # Idle behaviours. These are normally always available, however, they # can be locked out during interactions self._listen_behaviour_lock = Lock()
def main(): # Initialize the node rospy.init_node('action_client') # Instantiate the actions. But initialize only the ones we need actions = get_default_actions() # Create the argparser parser = argparse.ArgumentParser() parser.add_argument( "--background", action="store_true", help="spin until shutdown is signaled; action is stopped then") subparsers = parser.add_subparsers(dest='action') for key, action in actions.registry.iteritems(): action_parser = subparsers.add_parser(key, help="Action: {}".format(key)) action_parser.add_argument('params', help="params as JSON to the action") # Then parse the arguments args = parser.parse_args(rospy.myargv(sys.argv)[1:]) # Initialize the action action = actions[args.action] action.init(args.action) # Read the params def convert_params(d): new_d = {} for k, v in d.iteritems(): if isinstance(k, unicode): k = str(k) new_d[k] = v if isinstance(v, unicode): new_d[k] = str(v) elif isinstance(v, dict): new_d[k] = convert_params(v) return new_d params = json.loads(args.params) params = convert_params(params) # Run the action and return the value status, variables = action(**params) if args.background: rospy.spin() action.stop() rospy.loginfo("Status: {}. Variables: {}".format( goal_status_from_code(status), variables))
def __init__(self): # Instantiate the action server to perform the recovery self._server = actionlib.SimpleActionServer(rospy.get_name(), RequestAssistanceAction, self.execute, auto_start=False) # The actions that we are interested in using self.actions = get_default_actions() # Also subscribe to the joystick topic in order to enable and disable # the breakers self._assisting = False # Flag for we-are-assisting self._last_pressed = None # Which button was pressed? self._last_pressed_time = rospy.Time(0) # Don't spam the breaker srv self._joy_sub = rospy.Subscriber(LocalRecoveryServer.JOY_TOPIC, Joy, self._on_joy)
def __init__(self): global APP # The Flask application self._app = APP self._flask_server = self._app.server # Create the stop signal handler signal.signal(signal.SIGINT, self.stop) # The publisher of the trace self._trace_pub = rospy.Publisher( InterventionTracer.INTERVENTION_TRACE_TOPIC, InterventionEvent, queue_size=10) # Service proxy to indicate that the intervention is complete self._complete_intervention_srv = rospy.ServiceProxy( RemoteRecoveryServer.INTERVENTION_COMPLETE_SERVICE, Trigger) # Flags and services to enable and disable this controller self._current_error = None self._current_response = None self._enable_service = rospy.Service( RemoteRecoveryServer.ENABLE_SERVICE, EnableRemoteControl, self.enable) self._disable_service = rospy.Service( RemoteRecoveryServer.DISABLE_SERVICE, DisableRemoteControl, self.disable) # The robot controller self.controller = RobotController( get_default_actions(), intervention_trace_pub=self._trace_pub) self._action_buttons = None # Buttons for controller actions self._completion_buttons = None # Buttons for ending the intervention # Register a subscriber to the localization and goal interfaces on RViz self._relocalize_subscriber = rospy.Subscriber( RemoteController.RELOCALIZATION_TOPIC, PoseWithCovarianceStamped, self._on_relocalize) self._move_goal_subscriber = rospy.Subscriber( RemoteController.MOVE_GOAL_TOPIC, PoseStamped, self._on_move_goal) # Initialize the application self._define_app()
def __init__(self): # Instantiate the action server to perform the recovery self._server = actionlib.SimpleActionServer(rospy.get_name(), RequestAssistanceAction, self.execute, auto_start=False) # The intervention trace publisher self._trace_pub = rospy.Publisher( LocalRecoveryServer.INTERVENTION_TRACE_TOPIC, InterventionEvent, queue_size=10) # The actions that we are interested in using self.actions = get_default_actions() # The dialogue manager self.dialogue_manager = DialogueManager()
def __init__(self, tasks_config): self._tasks_config = tasks_config self._actions = get_default_actions()