Skip to content

Commit dc0138f

Browse files
Minor bug fix and feature extension
- 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>
1 parent 245aee1 commit dc0138f

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

lib/models/aerosurfaces.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from enum import Enum
2-
from typing import Optional
2+
from typing import Optional, Tuple, List
33
from pydantic import BaseModel
44

55

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

2626

27+
class AngleUnit(str, Enum):
28+
RADIANS: str = "RADIANS"
29+
DEGREES: str = "DEGREES"
30+
31+
2732
class Fins(BaseModel):
2833
fins_kind: FinsKinds
2934
name: str
@@ -34,7 +39,7 @@ class Fins(BaseModel):
3439
position: float
3540
cant_angle: float
3641
radius: float
37-
airfoil: str
42+
airfoil: Tuple[List[Tuple[float, float]], AngleUnit]
3843

3944

4045
# TODO: implement airbrakes

lib/models/rocket.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,18 +60,20 @@ class Rocket(BaseModel):
6060
base_radius=0.0635,
6161
rocket_radius=0.0635,
6262
)
63-
fins: Optional[Fins] = Fins(
64-
fins_kind=FinsKinds.TRAPEZOIDAL,
65-
name="Fins",
66-
n=4,
67-
root_chord=0.12,
68-
tip_chord=0.04,
69-
span=0.1,
70-
position=-1.04956,
71-
cant_angle=0,
72-
radius=0.0635,
73-
airfoil="",
74-
)
63+
fins: Optional[List[Fins]] = [
64+
Fins(
65+
fins_kind=FinsKinds.TRAPEZOIDAL,
66+
name="Fins",
67+
n=4,
68+
root_chord=0.12,
69+
tip_chord=0.04,
70+
span=0.1,
71+
position=-1.04956,
72+
cant_angle=0,
73+
radius=0.0635,
74+
airfoil=([(0.0, 0.0), (0.1, 0.1), (0.2, 0.2)], "RADIANS"),
75+
)
76+
]
7577
tail: Optional[Tail] = Tail(
7678
name="Tail",
7779
top_radius=0.0635,

lib/services/rocket.py

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Self
1+
from typing import Self, List
22

33
import dill
44

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

6565
# FinSet
66-
finset = cls.get_rocketpy_finset(rocket.fins, rocket.fins.fins_kind)
67-
rocketpy_rocket.aerodynamic_surfaces.add(finset, finset.position)
66+
rocketpy_finset_list = cls.get_rocketpy_finset_list_from_fins_list(
67+
rocket.fins
68+
)
69+
for finset in rocketpy_finset_list:
70+
rocketpy_rocket.aerodynamic_surfaces.add(finset, finset.position)
6871
rocketpy_rocket.evaluate_static_margin()
6972

7073
# Tail
@@ -134,6 +137,14 @@ def get_rocketpy_nose(nose: NoseCone) -> RocketPyNoseCone:
134137
rocketpy_nose.position = nose.position
135138
return rocketpy_nose
136139

140+
@classmethod
141+
def get_rocketpy_finset_list_from_fins_list(
142+
cls, fins_list: List[Fins]
143+
) -> List[RocketPyFins]:
144+
return [
145+
cls.get_rocketpy_finset(fins, fins.fins_kind) for fins in fins_list
146+
]
147+
137148
@staticmethod
138149
def get_rocketpy_finset(fins: Fins, kind: str) -> RocketPyFins:
139150
"""

0 commit comments

Comments
 (0)