Skip to content

Commit fea6bfc

Browse files
BUG: Rail Buttons Not Accepted in Add Surfaces (#701)
* DEP: deprecate NOAA's RUC sounding model * DEV: updates CHANGELOG * BUG: restart rail buttons components * DEP: deprecate NOAA's RUC sounding model * DEV: updates CHANGELOG * MNT: fix pylint * BUG: add rail buttons checks in add_surfaces * DEV: updates CHANGELOG --------- Co-authored-by: Gui-FernandesBR <[email protected]> Co-authored-by: Gui-FernandesBR <[email protected]>
1 parent 8fa8f4c commit fea6bfc

File tree

2 files changed

+20
-14
lines changed

2 files changed

+20
-14
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ Attention: The newest changes should be on top -->
4040

4141
### Fixed
4242

43+
- BUG: Rail Buttons Not Accepted in Add Surfaces [#701](https://github.com/RocketPy-Team/RocketPy/pull/701)
4344
- BUG: Vector encoding breaks MonteCarlo export. [#704](https://github.com/RocketPy-Team/RocketPy/pull/704)
4445

4546
## [v1.6.0] - 2024-09-29

rocketpy/rocket/rocket.py

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -966,14 +966,30 @@ def add_motor(self, motor, position): # pylint: disable=too-many-statements
966966
self.evaluate_com_to_cdm_function()
967967
self.evaluate_nozzle_gyration_tensor()
968968

969+
def __add_single_surface(self, surface, position):
970+
"""Adds a single aerodynamic surface to the rocket. Makes checks for
971+
rail buttons case, and position type.
972+
"""
973+
position = (
974+
Vector([0, 0, position])
975+
if not isinstance(position, (Vector, tuple, list))
976+
else Vector(position)
977+
)
978+
if isinstance(surface, RailButtons):
979+
self.rail_buttons = Components()
980+
self.rail_buttons.add(surface, position)
981+
else:
982+
self.aerodynamic_surfaces.add(surface, position)
983+
self.__evaluate_single_surface_cp_to_cdm(surface, position)
984+
969985
def add_surfaces(self, surfaces, positions):
970986
"""Adds one or more aerodynamic surfaces to the rocket. The aerodynamic
971987
surface must be an instance of a class that inherits from the
972988
AeroSurface (e.g. NoseCone, TrapezoidalFins, etc.)
973989
974990
Parameters
975991
----------
976-
surfaces : list, AeroSurface, NoseCone, TrapezoidalFins, EllipticalFins, Tail
992+
surfaces : list, AeroSurface, NoseCone, TrapezoidalFins, EllipticalFins, Tail, RailButtons
977993
Aerodynamic surface to be added to the rocket. Can be a list of
978994
AeroSurface if more than one surface is to be added.
979995
positions : int, float, list, tuple, Vector
@@ -996,22 +1012,11 @@ def add_surfaces(self, surfaces, positions):
9961012
-------
9971013
None
9981014
"""
999-
# TODO: separate this method into smaller methods: https://github.com/RocketPy-Team/RocketPy/pull/696#discussion_r1771978422
10001015
try:
10011016
for surface, position in zip(surfaces, positions):
1002-
if not isinstance(position, (Vector, tuple, list)):
1003-
position = Vector([0, 0, position])
1004-
else:
1005-
position = Vector(position)
1006-
self.aerodynamic_surfaces.add(surface, position)
1007-
self.__evaluate_single_surface_cp_to_cdm(surface, position)
1017+
self.__add_single_surface(surface, position)
10081018
except TypeError:
1009-
if not isinstance(positions, (Vector, tuple, list)):
1010-
positions = Vector([0, 0, positions])
1011-
else:
1012-
positions = Vector(positions)
1013-
self.aerodynamic_surfaces.add(surfaces, positions)
1014-
self.__evaluate_single_surface_cp_to_cdm(surfaces, positions)
1019+
self.__add_single_surface(surfaces, positions)
10151020

10161021
self.evaluate_center_of_pressure()
10171022
self.evaluate_stability_margin()

0 commit comments

Comments
 (0)