Skip to content

Commit 95a8851

Browse files
Merge pull request #356 from RocketPy-Team/bug/no-chute-lag-warning
BUG: Parachute lag warning when lag is 0 #2
2 parents ff5e4c9 + 280c2f9 commit 95a8851

File tree

1 file changed

+16
-10
lines changed

1 file changed

+16
-10
lines changed

rocketpy/Flight.py

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ def __init__(
547547
Default is 90, which points in the x direction.
548548
initialSolution : array, Flight, optional
549549
Initial solution array to be used. Format is
550-
initialSolution = []
550+
initialSolution = [
551551
self.tInitial,
552552
xInit, yInit, zInit,
553553
vxInit, vyInit, vzInit,
@@ -729,13 +729,15 @@ def __init__(
729729
self.parachutes.remove(parachute)
730730
# Create flight phase for time after detection and before inflation
731731
# Must only be created if parachute has any lag
732+
i = 1
732733
if parachute.lag != 0:
733734
self.flightPhases.addPhase(
734735
node.t,
735736
phase.derivative,
736737
clear=True,
737-
index=phase_index + 1,
738+
index=phase_index + i,
738739
)
740+
i += 1
739741
# Create flight phase for time after inflation
740742
callbacks = [
741743
lambda self, parachuteCdS=parachute.CdS: setattr(
@@ -747,7 +749,7 @@ def __init__(
747749
self.uDotParachute,
748750
callbacks,
749751
clear=False,
750-
index=phase_index + 2,
752+
index=phase_index + i,
751753
)
752754
# Prepare to leave loops and start new flight phase
753755
phase.timeNodes.flushAfter(node_index)
@@ -1024,12 +1026,16 @@ def __init__(
10241026
# Remove parachute from flight parachutes
10251027
self.parachutes.remove(parachute)
10261028
# Create flight phase for time after detection and before inflation
1027-
self.flightPhases.addPhase(
1028-
overshootableNode.t,
1029-
phase.derivative,
1030-
clear=True,
1031-
index=phase_index + 1,
1032-
)
1029+
# Must only be created if parachute has any lag
1030+
i = 1
1031+
if parachute.lag != 0:
1032+
self.flightPhases.addPhase(
1033+
overshootableNode.t,
1034+
phase.derivative,
1035+
clear=True,
1036+
index=phase_index + i,
1037+
)
1038+
i += 1
10331039
# Create flight phase for time after inflation
10341040
callbacks = [
10351041
lambda self, parachuteCdS=parachute.CdS: setattr(
@@ -1041,7 +1047,7 @@ def __init__(
10411047
self.uDotParachute,
10421048
callbacks,
10431049
clear=False,
1044-
index=phase_index + 2,
1050+
index=phase_index + i,
10451051
)
10461052
# Rollback history
10471053
self.t = overshootableNode.t

0 commit comments

Comments
 (0)