Skip to content

Commit 4531ed5

Browse files
ENH: Rocket Axes Definition (#635)
* ENH: make aerosurface position a Vector * DOC: fixes to addsurfaces refs * DOC: mv rocket.rst to rocket\rocket_usage.rst * ENH: remaining changes for vector position * DOC: aero surfaces docs minor improvements * DOC: create rocket axes description page * DOC: 3d csys correction * ENH: add rail button angular position to initial flight state * REV: revert position to Vector * ENH: consider buttons angular position in initial flight state * DOC: improve docstrings and add references * TST: adapt tests for new buttons angular position * DOC: final additions to flight csys * DEV: changelog * MNT: isort again * DOC: minor fixes * DOC: minor fixes * DOC: minor adjustments --------- Co-authored-by: Gui-FernandesBR <[email protected]>
1 parent 91b8011 commit 4531ed5

21 files changed

+325
-53
lines changed

.vscode/settings.json

+6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,14 @@
1414
"cSpell.language": "en-US",
1515
"cSpell.words": [
1616
"Abdulklech",
17+
"addsurface",
1718
"adjugate",
1819
"akima",
1920
"allclose",
2021
"altitudemode",
2122
"Alves",
2223
"amax",
24+
"angularpos",
2325
"arange",
2426
"arccos",
2527
"arcsin",
@@ -39,6 +41,7 @@
3941
"axvline",
4042
"axvspan",
4143
"Barrowman",
44+
"Baruh",
4245
"behaviour",
4346
"Bigl",
4447
"Bigr",
@@ -77,6 +80,7 @@
7780
"csys",
7881
"datapoints",
7982
"datetime",
83+
"dcsys",
8084
"ddot",
8185
"deepcopy",
8286
"deletechars",
@@ -105,6 +109,7 @@
105109
"figsize",
106110
"filt",
107111
"firstsimulation",
112+
"flightcsys",
108113
"Fluxogram",
109114
"fmax",
110115
"fmin",
@@ -130,6 +135,7 @@
130135
"Gonçalvez",
131136
"grav",
132137
"Guilherme",
138+
"Haim",
133139
"hemis",
134140
"hgtprs",
135141
"hgtsfc",

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Attention: The newest changes should be on top -->
3232

3333
### Added
3434

35+
- ENH: Rocket Axis Definition [#635](https://github.com/RocketPy-Team/RocketPy/pull/635)
3536

3637
### Changed
3738

docs/static/rocket/3dcsys.png

40.2 KB
Loading

docs/static/rocket/angularpos.png

45.1 KB
Loading

docs/static/rocket/flightcsys.png

34.2 KB
Loading

docs/user/index.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ RocketPy's User Guide
1414

1515
Positions and Coordinate Systems <positions.rst>
1616
Motors <motors/motors.rst>
17-
Rocket <rocket.rst>
17+
Rocket <rocket/rocket.rst>
1818
Environment <environment.rst>
1919

2020
.. toctree::

docs/user/rocket/rocket.rst

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
Rocket Usage
2+
============
3+
4+
.. toctree::
5+
:maxdepth: 2
6+
:caption: Rocket Class Usage
7+
8+
Rocket Class Usage <rocket_usage.rst>
9+
10+
.. toctree::
11+
:maxdepth: 3
12+
:caption: Rocket Class Axes Definitions
13+
14+
Rocket Class Axes Definitions <rocket_axes.rst>
15+

docs/user/rocket/rocket_axes.rst

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
Rocket Class Axes Definitions
2+
=============================
3+
4+
The Rocket class has two different coordinate systems:
5+
6+
1. **User Defined Coordinate System**: Used for geometrical inputs of the \
7+
aerodynamic surfaces and motor.
8+
2. **Body Axes Coordinate System**: Used during the flight simulation to assess \
9+
the governing equations of motion.
10+
11+
All inputs are automatically converted from the user's coordinate system to the
12+
rocket body axes coordinate system for use during the simulation.
13+
14+
Let's dive into the definitions of these coordinate systems:
15+
16+
17+
1. User Defined Coordinate System
18+
---------------------------------
19+
20+
Two things are set by the user in the user input coordinate system:
21+
22+
1. **Coordinate System Origin**: The origin of the coordinate system is set at \
23+
any point along the rocket's center line. This point can be arbitrarily chosen \
24+
and is not explicitly defined. All inputs must be given relative to this \
25+
point.
26+
2. **Direction of Center Axis**: Specified by the ``coordinate_system_orientation`` \
27+
argument when initializing the Rocket (:class:`rocketpy.Rocket.__init__`). This \
28+
argument defines the direction of the axis that follows the rocket's center \
29+
line. It can be either ``"nose_to_tail"`` or ``"tail_to_nose"``.
30+
31+
.. tip::
32+
33+
If you are using some CAD software to design your rocket, you can imagine the \
34+
coordinate system as the one used in the CAD software. The origin of the \
35+
coordinate system is the origin of the rocket in the CAD software, and the \
36+
direction of the center axis is the direction of the rocket's centerline. \
37+
You don't need to worry about the exact position of the origin, as long as \
38+
all inputs are given relative to this point.
39+
40+
.. seealso::
41+
42+
See `Positions and Coordinate Systems <positions.rst>`_ for more \
43+
information on the definitions of the rocket's aerodynamic surfaces and motor.
44+
45+
The ``x`` and ``y`` axes are defined at the plane perpendicular to the center axis,
46+
while the ``z`` axis is defined along the center axis. Depending on the choice of
47+
``coordinate_system_orientation``, the ``x`` axis and ``y`` axis can be inverted.
48+
49+
The following figure shows the two possibilities for the user input coordinate system:
50+
51+
.. figure:: ../../static/rocket/3dcsys.png
52+
:align: center
53+
:alt: Rocket axes
54+
55+
.. note::
56+
57+
When ``coordinate_system_orientation`` is set to ``"tail_to_nose"``, the direction \
58+
of the ``x``, ``y``, and ``z`` axes of the **User Defined Coordinate System** is \
59+
the same as the **Body Axes Coordinate System**. The origin of the coordinate \
60+
system may still be different.
61+
62+
Angular Position Inputs
63+
~~~~~~~~~~~~~~~~~~~~~~~
64+
65+
Angular position inputs (``angular_position``) refer to the roll angle position
66+
of that surface along the rocket's tube. The roll angle is defined as the angle
67+
from the ``y`` axis to the surface.
68+
Currently, only the :class:`rocketpy.RailButtons` class uses this kind of input.
69+
70+
The following figure shows the roll angle
71+
definition for both ``coordinate_system_orientation`` options:
72+
73+
.. figure:: ../../static/rocket/angularpos.png
74+
:align: center
75+
:alt: Angular position
76+
77+
78+
.. note::
79+
80+
The positive direction of the roll angle is defined as the direction that \
81+
rotates the surface in the positive direction of the ``z`` axis.
82+
83+
.. _rocket_axes_body_axes:
84+
85+
2. Body Axes Coordinate System
86+
------------------------------
87+
88+
The body axes coordinate system is used inside the simulation to assess the
89+
governing equations of motion. The body axes coordinate system is defined as follows:
90+
91+
- The origin is at the rocket's center of dry mass (``center_of_dry_mass_position``).
92+
- The ``z`` axis is defined along the rocket's centerline, pointing from the center of dry mass towards the nose.
93+
- The ``x`` and ``y`` axes are perpendicular.
94+
95+
3. Relation to Flight Coordinates
96+
---------------------------------
97+
98+
The ``Flight`` class uses a coordinate system defined as follows:
99+
100+
- The origin is at the launch rail.
101+
- The ``Z`` axis is positive upwards.
102+
- The ``X`` axis is position eastwards.
103+
- The ``Y`` axis is positive northwards.
104+
105+
The following figure shows the rotational relationship between the
106+
**Body Axes Coordinate System** and the **Flight Coordinate System**:
107+
108+
.. figure:: ../../static/rocket/flightcsys.png
109+
:align: center
110+
:alt: Flight coordinate system
111+
112+
In the figure above, :math:`\bf{i}` is the ``inclination`` and :math:`\bf{h}`
113+
is the ``heading`` of the launch rail.
114+
115+
The heading and inclination can be described in terms of Euler angles.
116+
The relation is given by:
117+
118+
.. math::
119+
\begin{aligned}
120+
&\text{Precession:} \quad &\psi &= -\bf{h} \\
121+
&\text{Nutation:} \quad &\theta &= \bf{i} - 90° \\
122+
\end{aligned}
123+
124+
A last rotation is defined by the ``angular_position`` of the rocket's rail buttons.
125+
This is a rotation around the rocket's centerline, and describes the last
126+
Euler angle:
127+
128+
.. math::
129+
\begin{aligned}
130+
&\text{Spin:} \quad &φ & \\
131+
\end{aligned}
132+
133+
If no rail buttons pair ir present, the spin angle is set to ****.
134+
135+
.. note::
136+
137+
With spin angle set to ****, if the launch rail ``heading`` is set to \
138+
**** and rail ``inclination`` to **90°**, the **Body Axes Coordinate \
139+
System** is aligned with the **Flight Coordinate System**.
140+
141+
Rocket's initial orientation
142+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
143+
144+
The initial orientation of the rocket is expressed in Euler parameters (quaternions).
145+
The Euler parameters are defined using the 3-1-3 rotation sequence:
146+
147+
.. math::
148+
149+
\begin{aligned}
150+
e_{0} &= \cos\left(\frac{φ}{2}\right) \cos\left(\frac{θ}{2}\right) \cos\left(\frac{ψ}{2}\right) - \sin\left(\frac{φ}{2}\right) \cos\left(\frac{θ}{2}\right) \sin\left(\frac{ψ}{2}\right) \\
151+
e_{1} &= \cos\left(\frac{φ}{2}\right) \cos\left(\frac{ψ}{2}\right) \sin\left(\frac{θ}{2}\right) + \sin\left(\frac{φ}{2}\right) \sin\left(\frac{θ}{2}\right) \sin\left(\frac{ψ}{2}\right) \\
152+
e_{2} &= \cos\left(\frac{φ}{2}\right) \sin\left(\frac{θ}{2}\right) \sin\left(\frac{ψ}{2}\right) - \sin\left(\frac{φ}{2}\right) \cos\left(\frac{ψ}{2}\right) \sin\left(\frac{θ}{2}\right) \\
153+
e_{3} &= \cos\left(\frac{φ}{2}\right) \cos\left(\frac{θ}{2}\right) \sin\left(\frac{ψ}{2}\right) + \cos\left(\frac{θ}{2}\right) \cos\left(\frac{ψ}{2}\right) \sin\left(\frac{φ}{2}\right) \\
154+
\end{aligned}
155+
156+

docs/user/rocket.rst docs/user/rocket/rocket_usage.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ to the rocket in one step:
209209

210210
.. caution::
211211

212-
Once again, pay special attention to the ``position`` parameter. Check
212+
Once again, pay special attention to the ``position`` parameter. Check \
213213
the :meth:`rocketpy.Rocket.add_surfaces` method for more information.
214214

215215
.. seealso::

rocketpy/mathutils/vector_matrix.py

+4
Original file line numberDiff line numberDiff line change
@@ -955,6 +955,10 @@ def transformation(quaternion):
955955
-------
956956
Matrix
957957
The transformation matrix from frame B to frame A.
958+
959+
Reference
960+
---------
961+
https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles
958962
"""
959963
q_w, q_x, q_y, q_z = quaternion
960964
return Matrix(

rocketpy/rocket/aero_surface/fins/elliptical_fins.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ class EllipticalFins(Fins):
1313
1414
Note
1515
----
16-
Local coordinate system: Z axis along the longitudinal axis of symmetry,
17-
positive downwards (top -> bottom). Origin located at the top of the root
18-
chord.
16+
Local coordinate system:
17+
- Origin located at the top of the root chord.
18+
- Z axis along the longitudinal axis of symmetry, positive downwards (top -> bottom).
19+
- Y axis perpendicular to the Z axis, in the span direction, positive upwards.
20+
- X axis completes the right-handed coordinate system.
1921
2022
See Also
2123
--------

rocketpy/rocket/aero_surface/fins/fins.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ class Fins(AeroSurface):
1111
1212
Note
1313
----
14-
Local coordinate system: Z axis along the longitudinal axis of symmetry,
15-
positive downwards (top -> bottom). Origin located at the top of the root
16-
chord.
14+
Local coordinate system:
15+
- Origin located at the top of the root chord.
16+
- Z axis along the longitudinal axis of symmetry, positive downwards (top -> bottom).
17+
- Y axis perpendicular to the Z axis, in the span direction, positive upwards.
18+
- X axis completes the right-handed coordinate system.
1719
1820
Attributes
1921
----------

rocketpy/rocket/aero_surface/fins/trapezoidal_fins.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@ class TrapezoidalFins(Fins):
1313
1414
Note
1515
----
16-
Local coordinate system: Z axis along the longitudinal axis of symmetry,
17-
positive downwards (top -> bottom). Origin located at the top of the root
18-
chord.
16+
Local coordinate system:
17+
- Origin located at the top of the root chord.
18+
- Z axis along the longitudinal axis of symmetry, positive downwards (top -> bottom).
19+
- Y axis perpendicular to the Z axis, in the span direction, positive upwards.
20+
- X axis completes the right-handed coordinate system.
1921
2022
See Also
2123
--------

rocketpy/rocket/aero_surface/nose_cone.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ class NoseCone(AeroSurface):
1515
1616
Note
1717
----
18-
The local coordinate system has the origin at the tip of the nose cone
19-
and the Z axis along the longitudinal axis of symmetry, positive
20-
downwards (top -> bottom).
18+
Local coordinate system:
19+
- the origin at the tip of the nose cone and
20+
- the Z axis along the longitudinal axis of symmetry, positive downwards (top -> bottom).
2121
2222
Attributes
2323
----------

rocketpy/rocket/aero_surface/rail_buttons.py

+8-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import numpy as np
2+
13
from rocketpy.mathutils.function import Function
24
from rocketpy.prints.aero_surface_prints import _RailButtonsPrints
35

@@ -15,6 +17,8 @@ class RailButtons(AeroSurface):
1517
Angular position of the rail buttons in degrees measured
1618
as the rotation around the symmetry axis of the rocket
1719
relative to one of the other principal axis.
20+
RailButtons.angular_position_rad : float
21+
Angular position of the rail buttons in radians.
1822
"""
1923

2024
def __init__(
@@ -40,11 +44,6 @@ def __init__(
4044
Radius of the rocket at the location of the rail buttons in meters.
4145
If not provided, it will be calculated when the RailButtons object
4246
is added to a Rocket object.
43-
44-
Returns
45-
-------
46-
None
47-
4847
"""
4948
super().__init__(name, None, None)
5049
self.buttons_distance = buttons_distance
@@ -56,6 +55,10 @@ def __init__(
5655

5756
self.prints = _RailButtonsPrints(self)
5857

58+
@property
59+
def angular_position_rad(self):
60+
return np.radians(self.angular_position)
61+
5962
def evaluate_center_of_pressure(self):
6063
"""Evaluates the center of pressure of the rail buttons. Rail buttons
6164
do not contribute to the center of pressure of the rocket.

rocketpy/rocket/aero_surface/tail.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ class Tail(AeroSurface):
1212
1313
Note
1414
----
15-
Local coordinate system: Z axis along the longitudinal axis of symmetry,
16-
positive downwards (top -> bottom). Origin located at top of the tail
17-
(generally the portion closest to the rocket's nose).
15+
Local coordinate system:
16+
- Z axis along the longitudinal axis of symmetry, positive downwards (top -> bottom).
17+
- Origin located at top of the tail (generally the portion closest to the rocket's nose).
1818
1919
Attributes
2020
----------

0 commit comments

Comments
 (0)