Repository navigation
Enh/class parachute #113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Enh/class parachute #113
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f6ab631
commit on 'enh/class_parachute')
153b306
commit on 'enh/class_parachute'
39196b4
commit on 'enh/class_parachute'
5ac0238
Update Parachute.py
FranzYuri 57cc0e2
commit on 'enh/class_parachute'
19ba28a
commit on 'enh/class_parachute'
9359eab
Fix code style issues with Black
lint-action 35bcc61
Merge branch 'develop' into enh/class_parachute
Gui-FernandesBR File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,131 @@ | ||
| __author__ = "Giovani Hidalgo Ceotto, Franz Masatoshi Yuri" | ||
| __copyright__ = "Copyright 20XX, Projeto Jupiter" | ||
| __license__ = "MIT" | ||
|
|
||
| import re | ||
| import math | ||
| import bisect | ||
| import warnings | ||
| import time | ||
| from datetime import datetime, timedelta | ||
| from inspect import signature, getsourcelines | ||
| from collections import namedtuple | ||
|
|
||
| import numpy as np | ||
| from scipy import integrate | ||
| from scipy import linalg | ||
| import matplotlib.pyplot as plt | ||
| from mpl_toolkits.mplot3d import Axes3D | ||
| from matplotlib import cm | ||
| from numpy import genfromtxt | ||
|
|
||
| from .Function import Function | ||
|
|
||
|
|
||
| class Parachute: | ||
| """Keeps parachute information. | ||
|
|
||
| Attributes | ||
| ---------- | ||
| Parachute attributes: | ||
| name : string | ||
| Parachute name, such as drogue and main. Has no impact in | ||
| simulation, as it is only used to display data in a more | ||
| organized matter. | ||
| CdS : float | ||
| Drag coefficient times reference area for parachute. It is | ||
| used to compute the drag force exerted on the parachute by | ||
| the equation F = ((1/2)*rho*V^2)*CdS, that is, the drag | ||
| force is the dynamic pressure computed on the parachute | ||
| times its CdS coefficient. Has units of area and must be | ||
| given in squared meters. | ||
| trigger : function | ||
| Function which defines if the parachute ejection system is | ||
| to be triggered. It must take as input the freestream | ||
| pressure in pascal and the state vector of the simulation, | ||
| which is defined by [x, y, z, vx, vy, vz, e0, e1, e2, e3, wx, wy, wz]. | ||
| It will be called according to the sampling rate given next. | ||
| It should return True if the parachute ejection system is | ||
| to be triggered and False otherwise. | ||
| samplingRate : float | ||
| Sampling rate in which the trigger function works. It is used to | ||
| simulate the refresh rate of onboard sensors such as barometers. | ||
| Default value is 100. Value must be given in hertz. | ||
| lag : float | ||
| Time between the parachute ejection system is triggered and the | ||
| parachute is fully opened. During this time, the simulation will | ||
| consider the rocket as flying without a parachute. Default value | ||
| is 0. Must be given in seconds. | ||
| noiseBias : float | ||
| Mean value of the noise added to the pressure signal, which is | ||
| passed to the trigger function. Unit is in pascal. | ||
| noiseDeviation : float | ||
| Standard deviation of the noise added to the pressure signal, | ||
| which is passed to the trigger function. Unit is in pascal. | ||
| noiseCorr : tuple, list | ||
| Tupple with the correlation between noise and time. | ||
| noiseSignal : list | ||
| List of (t, noise signal) corresponding to signal passed to | ||
| trigger function. Completed after running a simulation. | ||
| noisyPressureSignal : list | ||
| List of (t, noisy pressure signal) that is passed to the | ||
| trigger function. Completed after running a simulation. | ||
| cleanPressureSignal : list | ||
| List of (t, clean pressure signal) corresponding to signal passed to | ||
| trigger function. Completed after running a simulation. | ||
| noiseSignalFunction : Function | ||
| Function of noiseSignal. | ||
| noisyPressureSignalFunction : Function | ||
| Function of noisyPressureSignal. | ||
| cleanPressureSignalFunction : Function | ||
| Function of cleanPressureSignal. | ||
| """ | ||
|
|
||
| def __init__( | ||
| self, | ||
| name, | ||
| CdS, | ||
| Trigger, | ||
| samplingRate, | ||
| lag, | ||
| noise=(0, 0, 0), | ||
| ): | ||
| """Initializes Parachute class. | ||
| Parameters | ||
| ---------- | ||
| name : string | ||
| Name of the parachute. | ||
| CdS : float | ||
| CdS of the parachute. | ||
| Trigger : function | ||
| Trigger function. | ||
| samplngRate : float | ||
| Sampling rate, in hertz, for the Trigger function. | ||
| lag : float | ||
| Time, in seconds, between the parachute ejection system is triggered and the | ||
| parachute is fully opened. | ||
| noise : tuple, list, optional | ||
| List in the format (mean, standard deviation, time-correlation). | ||
| The values are used to add noise to the pressure signal which is | ||
| passed to the trigger function. Default value is (0, 0, 0). Units | ||
| are in pascal. | ||
| Returns | ||
| ------- | ||
| None | ||
| """ | ||
| self.name = name | ||
| self.CdS = CdS | ||
| self.trigger = Trigger | ||
| self.samplingRate = samplingRate | ||
| self.lag = lag | ||
| self.noiseSignal = [[-1e-6, np.random.normal(noise[0], noise[1])]] | ||
| self.noisyPressureSignal = [] | ||
| self.cleanPressureSignal = [] | ||
| self.noiseBias = noise[0] | ||
| self.noiseDeviation = noise[1] | ||
| self.noiseCorr = (noise[2], (1 - noise[2] ** 2) ** 0.5) | ||
| alpha, beta = self.noiseCorr | ||
| self.noiseFunction = lambda: alpha * self.noiseSignal[-1][ | ||
| 1 | ||
| ] + beta * np.random.normal(noise[0], noise[1]) | ||
| return None | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.