Skip to content

Commit 7c52a8d

Browse files
committed
Remove Action prefix from action goal, goal status, feedback and result
1 parent 2c1ee67 commit 7c52a8d

File tree

6 files changed

+50
-47
lines changed

6 files changed

+50
-47
lines changed

docs/files/ros2-action-client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_action_success(action_client):
2323
global result
2424
result = None
2525

26-
goal = roslibpy.ActionGoal({"order": 8})
26+
goal = roslibpy.Goal({"order": 8})
2727
action_client.send_goal(goal,
2828
result_callback,
2929
feedback_callback,
@@ -45,7 +45,7 @@ def test_action_cancel(action_client):
4545
global result
4646
result = None
4747

48-
goal = roslibpy.ActionGoal({"order": 8})
48+
goal = roslibpy.Goal({"order": 8})
4949
goal_id = action_client.send_goal(goal,
5050
result_callback,
5151
feedback_callback,

src/roslibpy/__init__.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -90,11 +90,13 @@ class and are passed around via :class:`Topics <Topic>` using a **publish/subscr
9090
9191
.. autoclass:: ActionClient
9292
:members:
93-
.. autoclass:: ActionGoal
93+
.. autoclass:: Goal
9494
:members:
95-
.. autoclass:: ActionFeedback
95+
.. autoclass:: GoalStatus
9696
:members:
97-
.. autoclass:: ActionResult
97+
.. autoclass:: Feedback
98+
:members:
99+
.. autoclass:: Result
98100
:members:
99101
100102
Parameter server
@@ -129,13 +131,13 @@ class and are passed around via :class:`Topics <Topic>` using a **publish/subscr
129131
)
130132
from .core import (
131133
ActionClient,
132-
ActionFeedback,
133-
ActionGoal,
134-
ActionGoalStatus,
135-
ActionResult,
134+
Feedback,
135+
Goal,
136+
GoalStatus,
136137
Header,
137138
Message,
138139
Param,
140+
Result,
139141
Service,
140142
ServiceRequest,
141143
ServiceResponse,
@@ -153,19 +155,19 @@ class and are passed around via :class:`Topics <Topic>` using a **publish/subscr
153155
"__title__",
154156
"__url__",
155157
"__version__",
158+
"ActionClient",
159+
"Feedback",
160+
"Goal",
161+
"GoalStatus",
156162
"Header",
157163
"Message",
158164
"Param",
165+
"Result",
166+
"Ros",
159167
"Service",
160168
"ServiceRequest",
161169
"ServiceResponse",
162-
"ActionClient",
163-
"ActionGoal",
164-
"ActionGoalStatus",
165-
"ActionFeedback",
166-
"ActionResult",
170+
"set_rosapi_timeout",
167171
"Time",
168172
"Topic",
169-
"set_rosapi_timeout",
170-
"Ros",
171173
]

src/roslibpy/comm/comm.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
import logging
55

66
from roslibpy.core import (
7-
ActionFeedback,
8-
ActionGoalStatus,
9-
ActionResult,
7+
Feedback,
8+
GoalStatus,
109
Message,
1110
MessageEncoder,
11+
Result,
1212
ServiceResponse,
1313
)
1414

@@ -151,7 +151,7 @@ def _handle_action_feedback(self, message):
151151

152152
request_id = message["id"]
153153
_, feedback, _ = self._pending_action_requests.get(request_id, None)
154-
feedback(ActionFeedback(message["values"]))
154+
feedback(Feedback(message["values"]))
155155

156156
def _handle_action_result(self, message):
157157
request_id = message["id"]
@@ -170,15 +170,15 @@ def _handle_action_result(self, message):
170170
status = message["values"].get("status")
171171
if status is None:
172172
# Default to UNKNOWN if status is not found
173-
status = ActionGoalStatus.UNKNOWN.value
173+
status = GoalStatus.UNKNOWN.value
174174

175175
LOGGER.debug("Received Action result with status: %s", status)
176176

177-
results = {"status": ActionGoalStatus(status), "values": message.get("values", {})}
177+
results = {"status": GoalStatus(status), "values": message.get("values", {})}
178178

179179
if "result" in message and message["result"] is False:
180180
if errback:
181181
errback(results)
182182
else:
183183
if resultback:
184-
resultback(ActionResult(results))
184+
resultback(Result(results))

src/roslibpy/core.py

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,10 @@
2222
"Service",
2323
"ServiceRequest",
2424
"ServiceResponse",
25-
"ActionGoal",
26-
"ActionFeedback",
27-
"ActionResult",
25+
"Goal",
26+
"GoalStatus",
27+
"Feedback",
28+
"Result",
2829
"Time",
2930
"Topic",
3031
]
@@ -136,26 +137,26 @@ def __init__(self, values=None):
136137
self.update(values)
137138

138139

139-
class ActionResult(UserDict):
140-
"""Result returned from a action call."""
140+
class Result(UserDict):
141+
"""Result returned from an action call."""
141142

142143
def __init__(self, values=None):
143144
self.data = {}
144145
if values is not None:
145146
self.update(values)
146147

147148

148-
class ActionFeedback(UserDict):
149-
"""Feedback returned from a action call."""
149+
class Feedback(UserDict):
150+
"""Feedback returned from an action call."""
150151

151152
def __init__(self, values=None):
152153
self.data = {}
153154
if values is not None:
154155
self.update(values)
155156

156157

157-
class ActionGoalStatus(Enum):
158-
""" ROS 2 Action Goal statuses.
158+
class GoalStatus(Enum):
159+
""" ROS 2 goal statuses.
159160
Reference: https://docs.ros2.org/latest/api/action_msgs/msg/GoalStatus.html
160161
"""
161162

@@ -168,8 +169,8 @@ class ActionGoalStatus(Enum):
168169
ABORTED = 6
169170

170171

171-
class ActionGoal(UserDict):
172-
"""Action Goal for an action call."""
172+
class Goal(UserDict):
173+
"""Goal for an action call."""
173174

174175
def __init__(self, values=None):
175176
self.data = {}
@@ -562,7 +563,7 @@ def send_goal(self, goal, resultback, feedback, errback):
562563
Note: The action client is non-blocking.
563564
564565
Args:
565-
goal (:class:`.ActionGoal`): Action goal.
566+
goal (:class:`.Goal`): Action goal.
566567
resultback: Callback invoked on receiving action result.
567568
feedback: Callback invoked on receiving action feedback.
568569
errback: Callback invoked on error.

tests/ros2/test_action_client.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from unittest.mock import Mock
44

55
from roslibpy.comm.comm import RosBridgeProtocol
6-
from roslibpy.core import ActionGoalStatus, ActionResult
6+
from roslibpy.core import GoalStatus, Result
77

88

99
def test_action_result_with_status_at_top_level():
@@ -33,8 +33,8 @@ def test_action_result_with_status_at_top_level():
3333

3434
assert result_callback.called
3535
result = result_callback.call_args[0][0]
36-
assert isinstance(result, ActionResult)
37-
assert result["status"] == ActionGoalStatus.SUCCEEDED
36+
assert isinstance(result, Result)
37+
assert result["status"] == GoalStatus.SUCCEEDED
3838
assert result["values"] == message["values"]
3939

4040

@@ -71,8 +71,8 @@ def test_action_result_with_status_in_values():
7171

7272
assert result_callback.called
7373
result = result_callback.call_args[0][0]
74-
assert isinstance(result, ActionResult)
75-
assert result["status"] == ActionGoalStatus.SUCCEEDED
74+
assert isinstance(result, Result)
75+
assert result["status"] == GoalStatus.SUCCEEDED
7676

7777

7878
def test_action_result_failure_with_status_at_top_level():
@@ -101,7 +101,7 @@ def test_action_result_failure_with_status_at_top_level():
101101

102102
assert error_callback.called
103103
result = error_callback.call_args[0][0]
104-
assert result["status"] == ActionGoalStatus.ABORTED
104+
assert result["status"] == GoalStatus.ABORTED
105105
assert result["values"] == message["values"]
106106

107107

@@ -136,6 +136,6 @@ def test_action_result_without_status_field():
136136

137137
assert result_callback.called
138138
result = result_callback.call_args[0][0]
139-
assert isinstance(result, ActionResult)
139+
assert isinstance(result, Result)
140140
# Should have some status value (likely UNKNOWN)
141141
assert "status" in result

tests/ros2/test_actions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import time
44

5-
from roslibpy import ActionClient, ActionGoal, ActionGoalStatus, Ros
5+
from roslibpy import ActionClient, Goal, GoalStatus, Ros
66

77

88
def test_fibonacci():
@@ -27,13 +27,13 @@ def on_feedback(feedback):
2727
def on_error(error):
2828
print(f"Error: {error}")
2929

30-
goal = ActionGoal({"order": 4})
30+
goal = Goal({"order": 4})
3131
goal_id = action.send_goal(goal, on_result, on_feedback, on_error)
3232
action.wait_goal(goal_id)
3333
time.sleep(0.2)
3434

3535
assert results["result"]["values"]["sequence"] == [0, 1, 1, 2, 3]
36-
assert results["result"]["status"] == ActionGoalStatus.SUCCEEDED
36+
assert results["result"]["status"] == GoalStatus.SUCCEEDED
3737

3838
ros.close()
3939

@@ -60,14 +60,14 @@ def on_feedback(feedback):
6060
def on_error(error):
6161
print(f"Error: {error}")
6262

63-
goal = ActionGoal({"order": 10})
63+
goal = Goal({"order": 10})
6464
goal_id = action.send_goal(goal, on_result, on_feedback, on_error)
6565
time.sleep(2)
6666
action.cancel_goal(goal_id)
6767
action.wait_goal(goal_id)
6868
time.sleep(0.2)
6969

70-
assert results["result"]["status"] == ActionGoalStatus.CANCELED
70+
assert results["result"]["status"] == GoalStatus.CANCELED
7171

7272
ros.close()
7373

0 commit comments

Comments
 (0)