Skip to content

Commit 8253fe6

Browse files
committed
fix: refine control handling in PX4Multirotor step method
1 parent 94dd048 commit 8253fe6

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

rotorpy/vehicles/px4_multirotor.py

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,8 @@ def _send_hil_sensor(self, state, statedot):
285285
fields_updated=updated_bitmask,
286286
)
287287

288-
def step(self, state, control, t_step):
289-
288+
def step(self, state, control, t_step):
289+
290290
# Compute state derivative once for state and messages
291291
# and send both HIL messages
292292
statedot = self.statedot(state, control, 0.0)
@@ -298,14 +298,13 @@ def step(self, state, control, t_step):
298298
px4_control = self._fetch_latest_px4_control(blocking=self._lockstep_enabled)
299299
if px4_control is not None:
300300
self._last_control = px4_control
301-
control = px4_control
302301
else:
303-
control = self._last_control
302+
pass # Do not modify _last_control
304303

305304
else: # In this case we use the control provided by the external controller
306-
pass
307-
308-
state = super().step(state, control, t_step)
305+
self._last_control = control
306+
307+
state = super().step(state, self._last_control, t_step)
309308
self.state = state
310309
self.t += t_step
311310

0 commit comments

Comments
 (0)