Skip to content

Commit

Permalink
Minor bug fix and feature extension
Browse files Browse the repository at this point in the history
- Fixed airfoil signature to be the same as power_off_drag (str -> List[tuples])
- Implement multiple rocket fins attachment

Fixes #32

addresses pylint issue

adjusts airfoil signature accordingly

addresses review comments

Update lib/services/rocket.py

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
GabrielBarberini and coderabbitai[bot] committed Oct 3, 2024
1 parent 245aee1 commit dc0138f
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 17 deletions.
9 changes: 7 additions & 2 deletions lib/models/aerosurfaces.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enum import Enum
from typing import Optional
from typing import Optional, Tuple, List
from pydantic import BaseModel


Expand All @@ -24,6 +24,11 @@ class FinsKinds(str, Enum):
ELLIPTICAL: str = "ELLIPTICAL"


class AngleUnit(str, Enum):
RADIANS: str = "RADIANS"
DEGREES: str = "DEGREES"


class Fins(BaseModel):
fins_kind: FinsKinds
name: str
Expand All @@ -34,7 +39,7 @@ class Fins(BaseModel):
position: float
cant_angle: float
radius: float
airfoil: str
airfoil: Tuple[List[Tuple[float, float]], AngleUnit]


# TODO: implement airbrakes
Expand Down
26 changes: 14 additions & 12 deletions lib/models/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,20 @@ class Rocket(BaseModel):
base_radius=0.0635,
rocket_radius=0.0635,
)
fins: Optional[Fins] = Fins(
fins_kind=FinsKinds.TRAPEZOIDAL,
name="Fins",
n=4,
root_chord=0.12,
tip_chord=0.04,
span=0.1,
position=-1.04956,
cant_angle=0,
radius=0.0635,
airfoil="",
)
fins: Optional[List[Fins]] = [
Fins(
fins_kind=FinsKinds.TRAPEZOIDAL,
name="Fins",
n=4,
root_chord=0.12,
tip_chord=0.04,
span=0.1,
position=-1.04956,
cant_angle=0,
radius=0.0635,
airfoil=([(0.0, 0.0), (0.1, 0.1), (0.2, 0.2)], "RADIANS"),
)
]
tail: Optional[Tail] = Tail(
name="Tail",
top_radius=0.0635,
Expand Down
17 changes: 14 additions & 3 deletions lib/services/rocket.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Self
from typing import Self, List

import dill

Expand Down Expand Up @@ -63,8 +63,11 @@ def from_rocket_model(cls, rocket: Rocket) -> Self:
rocketpy_rocket.evaluate_static_margin()

# FinSet
finset = cls.get_rocketpy_finset(rocket.fins, rocket.fins.fins_kind)
rocketpy_rocket.aerodynamic_surfaces.add(finset, finset.position)
rocketpy_finset_list = cls.get_rocketpy_finset_list_from_fins_list(
rocket.fins
)
for finset in rocketpy_finset_list:
rocketpy_rocket.aerodynamic_surfaces.add(finset, finset.position)
rocketpy_rocket.evaluate_static_margin()

# Tail
Expand Down Expand Up @@ -134,6 +137,14 @@ def get_rocketpy_nose(nose: NoseCone) -> RocketPyNoseCone:
rocketpy_nose.position = nose.position
return rocketpy_nose

@classmethod
def get_rocketpy_finset_list_from_fins_list(
cls, fins_list: List[Fins]
) -> List[RocketPyFins]:
return [
cls.get_rocketpy_finset(fins, fins.fins_kind) for fins in fins_list
]

@staticmethod
def get_rocketpy_finset(fins: Fins, kind: str) -> RocketPyFins:
"""
Expand Down

0 comments on commit dc0138f

Please sign in to comment.