Skip to content

Commit 6d79d62

Browse files
committed
FIX: Add missing u_dot parameter to direct triggerfunc calls
Direct calls to parachute.triggerfunc() were missing the u_dot parameter, causing TypeError in unit tests. Added u_dot=None to non-overshoot and overshoot trigger evaluation paths where u_dot is not computed. Fixes test failures in: - tests/unit/simulation/test_flight.py - tests/unit/test_utilities.py - tests/unit/test_rail_buttons_bending_moments.py - tests/unit/test_flight_data_exporter.py
1 parent d45b3a5 commit 6d79d62

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

rocketpy/simulation/flight.py

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -777,8 +777,7 @@ def __simulate(self, verbose):
777777
lambda self, parachute_porosity=parachute.porosity: setattr(
778778
self, "parachute_porosity", parachute_porosity
779779
),
780-
lambda self,
781-
added_mass_coefficient=parachute.added_mass_coefficient: setattr(
780+
lambda self, added_mass_coefficient=parachute.added_mass_coefficient: setattr(
782781
self,
783782
"parachute_added_mass_coefficient",
784783
added_mass_coefficient,
@@ -964,6 +963,7 @@ def __check_and_handle_parachute_triggers(
964963
height_above_ground_level,
965964
self.y_sol,
966965
self.sensors,
966+
None, # u_dot not computed in non-overshoot path
967967
):
968968
continue # Check next parachute
969969

@@ -999,8 +999,7 @@ def __check_and_handle_parachute_triggers(
999999
lambda self, parachute_porosity=parachute.porosity: setattr(
10001000
self, "parachute_porosity", parachute_porosity
10011001
),
1002-
lambda self,
1003-
added_mass_coefficient=parachute.added_mass_coefficient: setattr(
1002+
lambda self, added_mass_coefficient=parachute.added_mass_coefficient: setattr(
10041003
self,
10051004
"parachute_added_mass_coefficient",
10061005
added_mass_coefficient,
@@ -1373,6 +1372,7 @@ def __check_overshootable_parachute_triggers(
13731372
height_above_ground_level,
13741373
overshootable_node.y_sol,
13751374
self.sensors,
1375+
None, # u_dot not computed in overshoot path
13761376
):
13771377
continue # Check next parachute
13781378

@@ -1405,8 +1405,7 @@ def __check_overshootable_parachute_triggers(
14051405
lambda self, parachute_porosity=parachute.porosity: setattr(
14061406
self, "parachute_porosity", parachute_porosity
14071407
),
1408-
lambda self,
1409-
added_mass_coefficient=parachute.added_mass_coefficient: setattr(
1408+
lambda self, added_mass_coefficient=parachute.added_mass_coefficient: setattr(
14101409
self,
14111410
"parachute_added_mass_coefficient",
14121411
added_mass_coefficient,
@@ -1989,7 +1988,9 @@ def udot_rail2(self, t, u, post_processing=False): # pragma: no cover
19891988
# Hey! We will finish this function later, now we just can use u_dot
19901989
return self.u_dot_generalized(t, u, post_processing=post_processing)
19911990

1992-
def u_dot(self, t, u, post_processing=False): # pylint: disable=too-many-locals,too-many-statements
1991+
def u_dot(
1992+
self, t, u, post_processing=False
1993+
): # pylint: disable=too-many-locals,too-many-statements
19931994
"""Calculates derivative of u state vector with respect to time
19941995
when rocket is flying in 6 DOF motion during ascent out of rail
19951996
and descent without parachute.
@@ -2535,7 +2536,9 @@ def u_dot_generalized_3dof(self, t, u, post_processing=False):
25352536

25362537
return u_dot
25372538

2538-
def u_dot_generalized(self, t, u, post_processing=False): # pylint: disable=too-many-locals,too-many-statements
2539+
def u_dot_generalized(
2540+
self, t, u, post_processing=False
2541+
): # pylint: disable=too-many-locals,too-many-statements
25392542
"""Calculates derivative of u state vector with respect to time when the
25402543
rocket is flying in 6 DOF motion in space and significant mass variation
25412544
effects exist. Typical flight phases include powered ascent after launch
@@ -4370,9 +4373,7 @@ def add(self, flight_phase, index=None): # TODO: quite complex method
43704373
new_index = (
43714374
index - 1
43724375
if flight_phase.t < previous_phase.t
4373-
else index + 1
4374-
if flight_phase.t > next_phase.t
4375-
else index
4376+
else index + 1 if flight_phase.t > next_phase.t else index
43764377
)
43774378
flight_phase.t += adjust
43784379
self.add(flight_phase, new_index)

0 commit comments

Comments
 (0)