From 9a7022a6446a6a1ea1ea77392b69bec4284d81e8 Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Fri, 9 Apr 2021 09:57:11 -0700 Subject: [PATCH 1/3] Add GoalEvent back to module Signed-off-by: Shane Loretz --- rclpy/rclpy/action/server.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rclpy/rclpy/action/server.py b/rclpy/rclpy/action/server.py index aa27f9160..8157d3f78 100644 --- a/rclpy/rclpy/action/server.py +++ b/rclpy/rclpy/action/server.py @@ -43,6 +43,9 @@ class CancelResponse(Enum): ACCEPT = 2 +GoalEvent = _rclpy.GoalEvent + + class ServerGoalHandle: """Goal handle for working with Action Servers.""" From a0d387a3f1ae9dd6c5de657d15a7161f739aba7b Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Fri, 9 Apr 2021 09:57:22 -0700 Subject: [PATCH 2/3] self._goal -> self._goal_handle Signed-off-by: Shane Loretz --- rclpy/rclpy/action/server.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/rclpy/rclpy/action/server.py b/rclpy/rclpy/action/server.py index 8157d3f78..717e4db54 100644 --- a/rclpy/rclpy/action/server.py +++ b/rclpy/rclpy/action/server.py @@ -62,7 +62,7 @@ def __init__(self, action_server, goal_info, goal_request): :param goal_info: GoalInfo message. :param goal_request: The user defined goal request message from an ActionClient. """ - self._goal = _rclpy.ActionGoalHandle(action_server._handle, goal_info) + self._goal_handle = _rclpy.ActionGoalHandle(action_server._handle, goal_info) self._action_server = action_server self._goal_info = goal_info self._goal_request = goal_request @@ -88,9 +88,9 @@ def goal_id(self): @property def is_active(self): with self._lock: - if self._goal is None: + if self._goal_handle is None: return False - return self._goal.is_active() + return self._goal_handle.is_active() @property def is_cancel_requested(self): @@ -99,24 +99,24 @@ def is_cancel_requested(self): @property def status(self): with self._lock: - if self._goal is None: + if self._goal_handle is None: return GoalStatus.STATUS_UNKNOWN - return self._goal.get_status() + return self._goal_handle.get_status() def _update_state(self, event): with self._lock: # Ignore updates for already destructed goal handles - if self._goal is None: + if self._goal_handle is None: return # Update state - self._goal.update_goal_state(event) + self._goal_handle.update_goal_state(event) # Publish state change _rclpy.rclpy_action_publish_status(self._action_server._handle) # If it's a terminal state, then also notify the action server - if not self._goal.is_active(): + if not self._goal_handle.is_active(): self._action_server.notify_goal_done() def execute(self, execute_callback=None): @@ -133,7 +133,7 @@ def publish_feedback(self, feedback): with self._lock: # Ignore for already destructed goal handles - if self._goal is None: + if self._goal_handle is None: return # Populate the feedback message with metadata about this goal @@ -157,10 +157,10 @@ def canceled(self): def destroy(self): with self._lock: - if self._goal is None: + if self._goal_handle is None: return - self._goal.destroy_when_not_in_use() - self._goal = None + self._goal_handle.destroy_when_not_in_use() + self._goal_handle = None self._action_server.remove_future(self._result_future) From cec74cf4ffad2e6e1bdd33a8c94cb8116b79318b Mon Sep 17 00:00:00 2001 From: Shane Loretz Date: Fri, 9 Apr 2021 09:57:48 -0700 Subject: [PATCH 3/3] Remove unused API Signed-off-by: Shane Loretz --- rclpy/src/rclpy/_rclpy_action.cpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/rclpy/src/rclpy/_rclpy_action.cpp b/rclpy/src/rclpy/_rclpy_action.cpp index cb239147d..096069476 100644 --- a/rclpy/src/rclpy/_rclpy_action.cpp +++ b/rclpy/src/rclpy/_rclpy_action.cpp @@ -900,12 +900,6 @@ rclpy_action_take_status(py::capsule pyaction_client, py::object pymsg_type) TAKE_MESSAGE(status) } -rclpy::ActionGoalHandle -rclpy_action_accept_new_goal(py::capsule pyaction_server, py::object pygoal_info_msg) -{ - return rclpy::ActionGoalHandle(pyaction_server, pygoal_info_msg); -} - void rclpy_action_notify_goal_done(py::capsule pyaction_server) { @@ -1177,9 +1171,6 @@ define_action_api(py::module m) m.def( "rclpy_action_take_status", &rclpy_action_take_status, "Take a status message."); - m.def( - "rclpy_action_accept_new_goal", &rclpy_action_accept_new_goal, - "Accept a new goal using an action server."); m.def( "rclpy_action_notify_goal_done", &rclpy_action_notify_goal_done, "Notify and action server that a goal has reached a terminal state.");