Skip to content
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

Bug: do not allow drawing rockets with no aerodynamic surface #774

Merged
merged 4 commits into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ Attention: The newest changes should be on top -->

### Fixed

- BUG: do not allow drawing rockets with no aerodynamic surface [#774](https://github.com/RocketPy-Team/RocketPy/pull/774)
- BUG: update flight simulation logic to include burn start time [#778](https://github.com/RocketPy-Team/RocketPy/pull/778)

## [v1.8.0] - 2025-01-20
Expand Down
18 changes: 15 additions & 3 deletions rocketpy/plots/rocket_plots.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@
eps, jpg, jpeg, pdf, pgf, png, ps, raw, rgba, svg, svgz, tif, tiff
and webp (these are the formats supported by matplotlib).
"""

self.__validate_aerodynamic_surfaces()

if vis_args is None:
vis_args = {
"background": "#EEEEEE",
Expand Down Expand Up @@ -248,6 +251,12 @@
plt.tight_layout()
show_or_save_plot(filename)

def __validate_aerodynamic_surfaces(self):
if not self.rocket.aerodynamic_surfaces:
raise ValueError(

Check warning on line 256 in rocketpy/plots/rocket_plots.py

View check run for this annotation

Codecov / codecov/patch

rocketpy/plots/rocket_plots.py#L256

Added line #L256 was not covered by tests
"The rocket must have at least one aerodynamic surface to be drawn."
)

def _draw_aerodynamic_surfaces(self, ax, vis_args, plane):
"""Draws the aerodynamic surfaces and saves the position of the points
of interest for the tubes."""
Expand Down Expand Up @@ -399,6 +408,8 @@

def _draw_tubes(self, ax, drawn_surfaces, vis_args):
"""Draws the tubes between the aerodynamic surfaces."""
radius = 0
last_x = 0
for i, d_surface in enumerate(drawn_surfaces):
# Draw the tubes, from the end of the first surface to the beginning
# of the next surface, with the radius of the rocket at that point
Expand Down Expand Up @@ -670,9 +681,10 @@
"""

# Rocket draw
print("\nRocket Draw")
print("-" * 40)
self.draw()
if len(self.rocket.aerodynamic_surfaces) > 0:
print("\nRocket Draw")
print("-" * 40)
self.draw()

# Mass Plots
print("\nMass Plots")
Expand Down