Skip to content

ENH: A more intuitive deployable payload flight example #243

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

Closed
wants to merge 69 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
2ba19d4
ADD: create deployable payload simplest simulation
Gui-FernandesBR Sep 10, 2022
7f24ae6
MAINT: adding an off-topic to-do
Gui-FernandesBR Sep 10, 2022
256475a
ENH: now it's ploting the three trajectory
Gui-FernandesBR Sep 10, 2022
37cb3e9
MAINT: Adding few more to-dos
Gui-FernandesBR Sep 10, 2022
d5ab944
ENH: improve notebook
Gui-FernandesBR Sep 12, 2022
f7503f2
ENH: Adding combine_trajectories function
Gui-FernandesBR Sep 12, 2022
18a1537
ENH: Improve TODOs at function
Gui-FernandesBR Sep 12, 2022
d3c0ee9
Fix code style issues with Black
lint-action Sep 12, 2022
ff3f7a5
ENH: added compareFlightTrajectories and improved compareTrajectories
MateusStano Sep 13, 2022
7253b62
ENH: Refactor compare functions
Gui-FernandesBR Sep 13, 2022
6de473b
Fix code style issues with Black
lint-action Sep 13, 2022
5584a3e
BUG: fix minZ
MateusStano Sep 13, 2022
f68aea8
Merge pull request #227 from RocketPy-Team/enh/combine_trajectories
MateusStano Sep 13, 2022
6987481
ENH: allow Flight instance to be used as initialSolution
giovaniceotto Sep 14, 2022
ea8e8e8
MAINT: refactor solution monitors initialization
giovaniceotto Sep 14, 2022
171ffbb
Fix code style issues with Black
lint-action Sep 14, 2022
24e4f7d
Merge remote-tracking branch 'RocketPy-Team/master' into enh/complex_…
Gui-FernandesBR Sep 23, 2022
8991ee2
GIT: Merging conclicts while stashing changes
Gui-FernandesBR Sep 23, 2022
ec7815c
ENH: Updating notebook and plot title
Gui-FernandesBR Sep 23, 2022
19dc471
FIX: refactoring initialSolution array
Gui-FernandesBR Sep 24, 2022
4849063
MAINT: add tests TODO so we don't forget
Gui-FernandesBR Sep 27, 2022
e781509
Merge pull request #230 from RocketPy-Team/eng/complex_simulations/si…
Gui-FernandesBR Sep 27, 2022
e389f4c
MAINT: Make rail buttons optional in simulation
Gui-FernandesBR Sep 27, 2022
7ec22c2
Merge branch 'enh/complex_simulations' of https://github.com/rocketpy…
Gui-FernandesBR Sep 27, 2022
3b30fe8
Merge develop into enh/complex_simulations
Gui-FernandesBR Sep 27, 2022
eafed9b
Fix code style issues with Black
lint-action Sep 27, 2022
8c6c5b4
Merge complex_simulations into deployable-payload
Gui-FernandesBR Sep 27, 2022
b25aac0
ENH: using compareFlights in notebook example
Gui-FernandesBR Sep 27, 2022
bdf428e
Fix code style issues with Black
lint-action Sep 27, 2022
380bc29
ENH: fixing initialization on initial solution
Gui-FernandesBR Sep 28, 2022
451fe58
ENH: Final touches on example notebook
Gui-FernandesBR Oct 2, 2022
50fb09c
Fix code style issues with Black
lint-action Oct 2, 2022
8742771
ENH: reverting initialization of wind arrays
Gui-FernandesBR Oct 3, 2022
bba249b
BUG: fixing quaternions boundaries num errors
Gui-FernandesBR Oct 4, 2022
4672bd4
MAINT: final touches to fix links and typos
giovaniceotto Oct 5, 2022
678fc8d
ENH: normalize quaternions during simulation rather then after
giovaniceotto Oct 5, 2022
054a936
MAINT: implement a quicker fix to grid mismatch when using initialSol…
giovaniceotto Oct 5, 2022
ad3935c
MAINT: cleanup of unnecessary changes given last commits
giovaniceotto Oct 5, 2022
7f5f6c0
LINT: apply black styling
giovaniceotto Oct 5, 2022
2919e79
DOC: update docs to include new notebook on deployable payloads
giovaniceotto Oct 5, 2022
a16af86
MAINT: clip np.arcsin argument to prevent NaNs
giovaniceotto Oct 5, 2022
0f8559a
MAINT: fix initial solution test quaternion inputs
giovaniceotto Oct 5, 2022
948a16f
Fix code style issues with Black
lint-action Oct 5, 2022
7cd26b7
MAINT: Removing TODOs from the notebook
Gui-FernandesBR Oct 5, 2022
2eea3f6
Revert "MAINT: Removing TODOs from the notebook"
Gui-FernandesBR Oct 5, 2022
389b533
Merge branch 'docs-deployable-payload' of https://github.com/Projeto-…
Gui-FernandesBR Oct 5, 2022
ccbe27b
MAINT: Updating flight example heading
Gui-FernandesBR Oct 5, 2022
bc4516f
Merge pull request #245 from RocketPy-Team/docs-deployable-payload
Gui-FernandesBR Oct 5, 2022
0394c39
Main script
PatrickSampaioUSP Oct 9, 2022
cb99c63
Enh: Add parachute, fin, tail handling
PatrickSampaioUSP Oct 10, 2022
987f6f9
Enh: Functional for first rocket!
PatrickSampaioUSP Oct 11, 2022
28ef590
Enh: starting parameters separation
PatrickSampaioUSP Oct 11, 2022
b9ac457
Enh: parametrization
PatrickSampaioUSP Oct 11, 2022
be6a0ac
Enh: update jsons
PatrickSampaioUSP Oct 11, 2022
2fa85ab
Enh: Added mont carlo analysis
PatrickSampaioUSP Oct 11, 2022
29e2da3
Merge pull request #257 from RocketPy-Team/enh/swept-back-fins
giovaniceotto Oct 12, 2022
a94e8df
Enh
PatrickSampaioUSP Oct 12, 2022
83d3e37
REMOVE AFTER: saving changes to notebooks
PatrickSampaioUSP Oct 12, 2022
11a25e5
Enh
PatrickSampaioUSP Oct 13, 2022
62e2172
FIX: fixes bearing method to solve KML issue
giovaniceotto Oct 13, 2022
521b90f
Merge branch 'enh/euroc_simulations' into enh/complex_simulations
Gui-FernandesBR Oct 14, 2022
bd2fa74
Fix code style issues with Black
lint-action Oct 14, 2022
c772925
FIX: remove totally misplaced files
Gui-FernandesBR Nov 12, 2022
b092d32
FIX: Revt 521b90f5ac8bc81543219de0ed6ced74aacaaafb
Gui-FernandesBR Nov 12, 2022
08ddc1e
Merge branch 'master' into enh/complex_simulations
Gui-FernandesBR Nov 12, 2022
ab80ab2
FIX: euroc nc files restored
Gui-FernandesBR Nov 12, 2022
1f347df
FIX: revert files by upstreaming develop
Gui-FernandesBR Nov 12, 2022
83af9d8
Merge remote-tracking branch 'RocketPy-Team/develop' into enh/complex…
Gui-FernandesBR Nov 12, 2022
3c31290
FIX: restore user index.rst
Gui-FernandesBR Nov 12, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
698 changes: 698 additions & 0 deletions docs/notebooks/deployable_payload_example.ipynb

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
nbsphinx>=0.8.0
pydata-sphinx-theme==0.6.3
pydata-sphinx-theme==0.10.1
m2r2>=0.2.1
2 changes: 2 additions & 0 deletions docs/user/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ Welcome to RocketPy's user documentation!
../notebooks/environment_class_usage.ipynb
../notebooks/environment_analysis_class_usage.ipynb
../notebooks/environment_analysis_EuroC_example.ipynb
../notebooks/solid_motor_class_usage.ipynb
../notebooks/dispersion_analysis/dispersion_analysis.ipynb
../notebooks/utilities_usage.ipynb
../notebooks/deployable_payload_example.ipynb
../matlab/matlab.rst

2,525 changes: 795 additions & 1,730 deletions rocketpy/Flight.py

Large diffs are not rendered by default.

152 changes: 152 additions & 0 deletions rocketpy/utilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,15 @@
__copyright__ = "Copyright 20XX, RocketPy Team"
__license__ = "MIT"

import matplotlib.pyplot as plt
import numpy as np
from scipy.integrate import solve_ivp
import matplotlib.pyplot as plt

from .Environment import Environment
from .Function import Function

# Parachutes related functions

# TODO: Needs tests
def compute_CdS_from_drop_test(
Expand Down Expand Up @@ -198,6 +201,155 @@ def du(z, u):
return altitudeFunction, velocityFunction, final_sol


def compareTrajectories(
trajectory_list,
names=None,
legend=True,
):
"""Creates a trajectory plot combining the trajectories listed.
This function was created based two source-codes:
- Mateus Stano: https://github.com/RocketPy-Team/Hackathon_2020/pull/123
- Dyllon Preston: https://github.com/Dyllon-P/MBS-Template/blob/main/MBS.py

Parameters
----------
trajectory_list : list, array
List of trajectories. Must be in the form of [trajectory_1, trajectory_2, ..., trajectory_n]
where each element is a list with the arrays regarding positions in x, y and z [x, y, z].
The trajectories must be in the same reference frame. The z coordinate must be referenced
to the ground or to the sea level, but it is important that all trajectories are passed
in the same reference.
names : list, optional
List of strings with the name of each trajectory inputted. The names must be in
the same order as the trajectories in trajectory_list. If no names are passed, the
trajectories will be named as "Trajectory 1", "Trajectory 2", ..., "Trajectory n".
legend : boolean, optional
Whether legend will or will not be plotted. Default is True

Returns
-------
None

"""
# TODO: Allow the user to catch different planes (xy, yz, xz) from the main plot (this can be done in a separate function)
# TODO: Allow the user to set the colors or color style
# TODO: Allow the user to set the line style

# Initialize variables
maxX, maxY, maxZ, minX, minY, minZ, maxXY, minXY = 0, 0, 0, 0, 0, 0, 0, 0

names = (
[("Trajectory " + str(i + 1)) for i in range(len(trajectory_list))]
if names == None
else names
)

# Create the figure
fig1 = plt.figure(figsize=(9, 9))
ax1 = plt.subplot(111, projection="3d")

# Iterate through trajectories
for i, trajectory in enumerate(trajectory_list):

x, y, z = trajectory

# Find max/min values for each component
maxX = max(x) if max(x) > maxX else maxX
maxY = max(y) if max(y) > maxY else maxY
maxZ = max(z) if max(z) > maxZ else maxZ
minX = min(x) if min(x) < minX else minX
minY = min(x) if min(x) < minX else minX
minZ = min(z) if min(z) < minZ else minZ
maxXY = max(maxX, maxY) if max(maxX, maxY) > maxXY else maxXY
minXY = min(minX, minY) if min(minX, minY) > minXY else minXY

# Add Trajectory as a plot in main figure
ax1.plot(x, y, z, linewidth="2", label=names[i])

# Plot settings
ax1.scatter(0, 0, 0)
ax1.set_xlabel("X - East (m)")
ax1.set_ylabel("Y - North (m)")
ax1.set_zlabel("Z - Altitude (m)")
ax1.set_title("Flight Trajectories Comparison")
ax1.set_zlim3d([minZ, maxZ])
ax1.set_ylim3d([minXY, maxXY])
ax1.set_xlim3d([minXY, maxXY])
ax1.view_init(15, 45)
if legend:
plt.legend()
plt.show()

return None


def compareFlightTrajectories(
flight_list,
names=None,
legend=True,
):
"""Creates a trajectory plot that is the combination of the trajectories of
the Flight objects passed via a Python list.

Parameters
----------
flight_list : list, array
List of FLight objects. The flights must be in the same reference frame.
names : list, optional
List of strings with the name of each trajectory inputted. The names must be in
the same order as the trajectories in flight_list
legend : boolean, optional
Whether legend will or will not be included. Default is True

Returns
-------
None

"""
# TODO: Allow the user to catch different planes (xy, yz, xz) from the main plot
# TODO: Allow the user to set the colors or color style
# TODO: Allow the user to set the line style

# Iterate through Flight objects and create a list of trajectories
trajectory_list = []
for flight in flight_list:

# Check post process
if flight.postProcessed is False:
flight.postProcess()

# Get trajectories
x = flight.x[:, 1]
y = flight.y[:, 1]
z = flight.z[:, 1] - flight.env.elevation
trajectory_list.append([x, y, z])

# Call compareTrajectories function to do the hard work
compareTrajectories(trajectory_list, names, legend)

return None


def compareAllInfo(flight_list, names=None):
"""Creates a plot with the altitude, velocity and acceleration of the
Flight objects passed via a Python list.

Parameters
----------
flight_list : list, array
List of FLight objects. The flights must be in the same reference frame.
names : list, optional
List of strings with the name of each trajectory inputted. The names must be in
the same order as the trajectories in flight_list

Returns
-------
None

"""
return None


def create_dispersion_dictionary(filename):
"""Creates a dictionary with the rocket data provided by a .csv file.
File should be organized in four columns: attribute_class, parameter_name,
Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
"pytz",
"timezonefinder",
"simplekml",
"jsonpickle",
],
maintainer="RocketPy Developers",
author="Giovani Hidalgo Ceotto",
Expand Down
8 changes: 4 additions & 4 deletions tests/test_flight.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,9 @@ def mainTrigger(p, y):
10,
0.0,
0.0,
0.0,
0.0,
0.0,
0.9990482215818579,
-0.043619387365336,
-0.0,
0.0,
0.0,
0.0,
Expand Down Expand Up @@ -533,7 +533,7 @@ def test_export_data():


def test_export_KML():
"Tests weather the method Flight.exportKML is working as intended"
"Tests wether the method Flight.exportKML is working as intended"

test_env = Environment(
railLength=5,
Expand Down