From 3d0fb1ef73108093a4f8fac4e13e26e08c257f23 Mon Sep 17 00:00:00 2001 From: Christopher Herr Date: Wed, 18 Jan 2023 16:12:06 +0100 Subject: [PATCH] revert ed2f2c95c75d3fb8373d66c6c0775a5468b9737a revert ROS actionlib start --- src/pubsub/pubsub/pubsub_library_v3.py | 102 ++----------------------- 1 file changed, 8 insertions(+), 94 deletions(-) diff --git a/src/pubsub/pubsub/pubsub_library_v3.py b/src/pubsub/pubsub/pubsub_library_v3.py index 7cf1193..9c1d07a 100644 --- a/src/pubsub/pubsub/pubsub_library_v3.py +++ b/src/pubsub/pubsub/pubsub_library_v3.py @@ -16,25 +16,19 @@ import rclpy from rclpy.node import Node -from rclpy.action import ActionServer - -# How to use, please refer to: -# Topic: -# - topic_talker.py -# - topic_listener.py -# Service: -# - service_host.py -# - service_client.py -# Action: -# - action_server.py -# - action_client.py +# How to use: +# from pubsub_library import MinimalPublisher +# from pubsub_library import MinimalSubscriber +# minimal_publisher = MinimalPublisher(NODE_NAME='minimal_pub', TOPIC_NAME='user_controller', MSG_TYPE=Usercontroller, MSG_PERIOD=0.5) +# minimal_subscriber = MinimalSubscriber(NODE_NAME='minimal_sub', TOPIC_NAME='epos_feedback', MSG_TYPE=Eposreturn) +# See --> talker.py, listener.py # Definition of Parent Classes #******************************************************************************# -# TOPIC +# TOPICS #******************************************************************************# class MinimalPublisher(Node): @@ -181,6 +175,7 @@ class MinimalServiceProvider(Node): response.success = True # Change this to fit your service type return response + #******************************************************************************# class MinimalServiceClientAsync(Node): @@ -229,84 +224,3 @@ class MinimalServiceClientAsync(Node): return self.future.done(), response # response is of type ".Response()" else: return self.future.done(), None - - - - -#******************************************************************************# -# ACTIONS -#******************************************************************************# - -class MinimalActionServer(Node): - """ Minimal Action Server Class - Inputs: - * NODE_NAME: string - * ACT_NAME: string - * ACT_TYPE: action type class - * act_callback_input: action callback function - - Return: - * - """ - - def __init__(self, NODE_NAME, ACT_NAME, ACT_TYPE, act_callback_input=None): - self.NODE_NAME = NODE_NAME - self.ACT_NAME = ACT_NAME - self.ACT_TYPE = ACT_TYPE - # Check if user passed callback function - if act_callback_input == None: - self.execute_callback= self.std_act_callback - else: - self.execute_callback = act_callback_input - - # Init above laying class "Node" (super class) - super().__init__(self.NODE_NAME) - print("\tStarting Action Server:\t%s"%(self.ACT_NAME)) - self._action_server = ActionServer(self, self.ACT_TYPE, self.ACT_NAME, self.execute_callback) - - - # standard action callback - def std_act_callback(self, goal_handle): - """ Standard Action Callback Method - - Replace this method by inputting a custom callback method using 'act_callback_input'. - This method MUST return a variable of the type 'action result', - eg. result = ACTION_TYPE.Result() - """ - self.get_logger().info('Executing goal...') - ################# - # Action Method # - # here # - ################# - result = self.ACT_TYPE.Result() - return result - -#******************************************************************************# - -class MinimalActionClient(Node): - """ Minimal Action Client - Inputs: - * NODE_NAME: string - * ACT_NAME: string - * ACT_TYPE: action type class - * act_callback_input: action callback function - - Return: - * - """ - - def __init__(self, NODE_NAME, ACT_NAME, ACT_TYPE, act_callback_input=None): - self.NODE_NAME = NODE_NAME - self.ACT_NAME = ACT_NAME - self.ACT_TYPE = ACT_TYPE - - # Init above laying class "Node" (super class) - super().__init__(self.NODE_NAME) - print("\tStarting Action Client for:\t%s"%(self.ACT_NAME)) - self._action_client = ActionClient(self, self.ACT_TYPE, self.ACT_NAME) - - def send_goal(self, input): - return - - def abort_goal(self): - return \ No newline at end of file