Commit 3c7eaea
state_machine + action_planner: port 9 scripts/ Python files from rospy to rclpy
The per-package subagents focused on the C++ side and missed the 9
Python scripts living under action_planner/scripts/ and
state_machine_core/scripts/ that still imported rospy and actionlib.
These are dev tools (trajectory evaluators, a goal publisher) and the
main state-machine orchestrator, none of which are installed by
CMakeLists. Port them to rclpy under a separate subagent pass.
Scripts ported (9 files, ~1886 source lines):
action_planner/scripts/:
- publish_plantwopointaction.py: rclpy.create_node + rclpy.action.
ActionClient(PlanTwoPoint) replacing actionlib.SimpleActionClient
and the PlanTwoPointActionGoal publisher. send_goal_async +
spin_until_future_complete flow.
- evaluate_traj.py: Evaluater(node) class with 3 ActionClient
migrations. Local variable `time` renamed to `time_total` to avoid
shadowing the time module (pre-existing latent bug).
- evaluate_traj_exp.py: 10 planner ActionClient migrations. Every
ServiceProxy -> create_client + call_async + spin_until_future_complete.
rospy.get_param_names() has no rclpy equivalent; a best-effort fallback
using the node's internal parameter map is flagged with inline TODOs.
state_machine_core/scripts/:
- main_state_machine.py: rclpy.init + create_node + spin loop wrapper.
rospy.names.get_namespace() -> node.get_namespace() with trailing-
slash normalization. QuadTracker now constructed with (node, ...)
first arg. smach ecosystem is ROS1-only; top-of-file TODO note
preserved so the smach state graph itself still works when a ROS2
smach port (smach_ros2 / yasmin) becomes available.
- QuadTracker.py: constructor signature changed to (self, node,
abort_topic). 5 rospy.Subscriber calls -> node.create_subscription.
tf.TransformListener -> tf2_ros.Buffer + TransformListener.
tf.transformations.euler_from_quaternion -> tf_transformations.
euler_from_quaternion.
- MainStates.py: _node(quad_monitor) helper pulls the rclpy node off
the QuadTracker. Deferred publisher/client creation in
PublishBoolMsgState and ArmDisarmMavros because they inherit from
smach.State (no __init__ Node access) — main_state_machine.py wires
`state.quad_monitor = quad_tracker` after constructing them.
rospy.ServiceProxy -> create_client + async call pattern.
WaitState.__init__ param renamed `time` -> `time_sec` to avoid
shadowing the imported time module.
- Replanner.py: rospy.sleep -> time.sleep. smach_ros.SimpleActionState
wrapper preserved as-is with a TODO note; the wrapper has no ROS2
equivalent and the class will need to be reimplemented when
smach_ros2 lands.
- SwitchState.py: rospy.Subscriber -> quad_monitor.node.create_subscription.
roslib.load_manifest dropped (ROS1-only).
- Utils.py: tf.Transformer (ROS1-only) -> direct 4x4 matrix math via
tf_transformations.concatenate_matrices + inverse_matrix. Pure
helper module, no node reference.
Known limitations (documented inline in each file):
- `smach` itself is ROS1-only. Every SMACH state file has a top-of-file
TODO note saying the state machine graph must be re-implemented once
smach_ros2 or yasmin is available. The rospy -> rclpy translation
below the TODO is best-effort and correct in isolation.
- Absolute parameter paths like /mapper/global/origin_x and
/local_plan_server0/mav_name cannot be read directly in ROS2
(parameters are per-node). The slash-named declare_parameter calls
are preserved as best-effort mechanical translations; at runtime
these should use rclpy.parameter_client to read from the target
node, or the value should be passed in at launch.
- smach_ros.SimpleActionState and smach_ros.ServiceState wrappers are
used in Replanner.py and MainStates.py. These don't exist in ROS2.
Deferred to the smach_ros2 / yasmin follow-up.
None of these scripts are installed by any CMakeLists.txt, so this
commit does not affect colcon build. It does bring the tree into a
state where grep -rn 'import rospy' returns zero hits.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 01a1e0a commit 3c7eaea
9 files changed
Lines changed: 518 additions & 289 deletions
File tree
- autonomy_core
- map_plan/action_planner/scripts
- state_machine/state_machine_core/scripts
Lines changed: 54 additions & 41 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
3 | 6 | | |
4 | | - | |
| 7 | + | |
| 8 | + | |
5 | 9 | | |
6 | 10 | | |
7 | 11 | | |
8 | 12 | | |
9 | 13 | | |
10 | | - | |
11 | 14 | | |
12 | 15 | | |
13 | 16 | | |
| |||
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
45 | | - | |
| 48 | + | |
| 49 | + | |
46 | 50 | | |
47 | 51 | | |
48 | | - | |
49 | | - | |
50 | | - | |
51 | | - | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
52 | 56 | | |
53 | | - | |
54 | | - | |
| 57 | + | |
| 58 | + | |
55 | 59 | | |
56 | 60 | | |
57 | 61 | | |
| |||
75 | 79 | | |
76 | 80 | | |
77 | 81 | | |
78 | | - | |
| 82 | + | |
79 | 83 | | |
80 | 84 | | |
81 | | - | |
82 | | - | |
| 85 | + | |
| 86 | + | |
83 | 87 | | |
84 | 88 | | |
85 | 89 | | |
86 | 90 | | |
87 | | - | |
88 | | - | |
89 | | - | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
90 | 95 | | |
91 | 96 | | |
92 | 97 | | |
93 | 98 | | |
94 | 99 | | |
95 | | - | |
| 100 | + | |
96 | 101 | | |
97 | 102 | | |
98 | 103 | | |
99 | | - | |
| 104 | + | |
100 | 105 | | |
101 | 106 | | |
102 | 107 | | |
| |||
108 | 113 | | |
109 | 114 | | |
110 | 115 | | |
111 | | - | |
| 116 | + | |
112 | 117 | | |
113 | 118 | | |
114 | | - | |
| 119 | + | |
115 | 120 | | |
116 | | - | |
117 | | - | |
| 121 | + | |
| 122 | + | |
118 | 123 | | |
119 | 124 | | |
120 | | - | |
| 125 | + | |
121 | 126 | | |
122 | 127 | | |
123 | 128 | | |
124 | 129 | | |
125 | | - | |
| 130 | + | |
126 | 131 | | |
127 | 132 | | |
128 | 133 | | |
| |||
131 | 136 | | |
132 | 137 | | |
133 | 138 | | |
134 | | - | |
| 139 | + | |
135 | 140 | | |
136 | | - | |
137 | | - | |
138 | | - | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
139 | 144 | | |
140 | | - | |
| 145 | + | |
141 | 146 | | |
142 | 147 | | |
143 | 148 | | |
144 | | - | |
145 | | - | |
| 149 | + | |
| 150 | + | |
146 | 151 | | |
147 | 152 | | |
148 | 153 | | |
149 | 154 | | |
150 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
151 | 166 | | |
152 | 167 | | |
153 | | - | |
154 | | - | |
155 | | - | |
156 | | - | |
157 | 168 | | |
158 | | - | |
159 | 169 | | |
160 | 170 | | |
161 | 171 | | |
| |||
190 | 200 | | |
191 | 201 | | |
192 | 202 | | |
193 | | - | |
194 | | - | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
195 | 206 | | |
196 | 207 | | |
197 | | - | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
198 | 211 | | |
199 | 212 | | |
200 | 213 | | |
201 | 214 | | |
202 | 215 | | |
203 | | - | |
| 216 | + | |
204 | 217 | | |
0 commit comments