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

ENH: Rocket Axes Definition #635

Merged
merged 21 commits into from
Aug 4, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
8c1834f
ENH: make aerosurface position a Vector
MateusStano Jul 3, 2024
7183486
DOC: fixes to addsurfaces refs
MateusStano Jul 3, 2024
e0a8aae
DOC: mv rocket.rst to rocket\rocket_usage.rst
MateusStano Jul 5, 2024
ac925eb
ENH: remaining changes for vector position
MateusStano Jul 5, 2024
6340c1a
DOC: aero surfaces docs minor improvements
MateusStano Jul 5, 2024
1c2db24
DOC: create rocket axes description page
MateusStano Jul 5, 2024
27df555
DOC: 3d csys correction
MateusStano Jul 5, 2024
12f0051
ENH: add rail button angular position to initial flight state
MateusStano Jul 5, 2024
c7bceff
REV: revert position to Vector
MateusStano Jul 8, 2024
75f4da2
ENH: consider buttons angular position in initial flight state
MateusStano Jul 8, 2024
b4fe7f1
DOC: improve docstrings and add references
MateusStano Jul 8, 2024
bbec1aa
TST: adapt tests for new buttons angular position
MateusStano Jul 8, 2024
2b30236
DOC: final additions to flight csys
MateusStano Jul 8, 2024
3a07999
Merge branch 'mnt/refactor-aerosurfaces' into enh/rocket-axis-definition
MateusStano Jul 8, 2024
9c78466
DEV: changelog
MateusStano Jul 8, 2024
c6536e3
MNT: isort again
MateusStano Jul 8, 2024
a79085e
Merge branch 'develop' into enh/rocket-axis-definition
Gui-FernandesBR Aug 4, 2024
9c39d74
DOC: minor fixes
Gui-FernandesBR Aug 4, 2024
37c5d47
DOC: minor fixes
Gui-FernandesBR Aug 4, 2024
134d8e1
Merge branch 'develop' into enh/rocket-axis-definition
Gui-FernandesBR Aug 4, 2024
e95d3c6
DOC: minor adjustments
Gui-FernandesBR Aug 4, 2024
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
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ Attention: The newest changes should be on top -->

### Added

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

### Changed

Expand Down
Binary file added docs/static/rocket/3dcsys.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/static/rocket/angularpos.png
Gui-FernandesBR marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/static/rocket/flightcsys.png
Gui-FernandesBR marked this conversation as resolved.
Show resolved Hide resolved
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion docs/user/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RocketPy's User Guide

Positions and Coordinate Systems <positions.rst>
Motors <motors/motors.rst>
Rocket <rocket.rst>
Rocket <rocket/rocket.rst>
Environment <environment.rst>

.. toctree::
Expand Down
15 changes: 15 additions & 0 deletions docs/user/rocket/rocket.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
Rocket Usage
============

.. toctree::
:maxdepth: 2
:caption: Rocket Class Usage

Rocket Class Usage <rocket_usage.rst>

.. toctree::
:maxdepth: 3
:caption: Rocket Class Axes Definitions

Rocket Class Axes Definitions <rocket_axes.rst>

145 changes: 145 additions & 0 deletions docs/user/rocket/rocket_axes.rst
Gui-FernandesBR marked this conversation as resolved.
Show resolved Hide resolved
Gui-FernandesBR marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
Rocket Class Axes Definitions
=============================

The Rocket class has two different coordinate systems:

1. **User Defined Coordinate System**: Used for geometrical inputs of the
aerodynamic surfaces and motor.
2. **Body Axes Coordinate System**: Used inside the simulation to assess the
governing equations of motion.

All inputs from the user's coordinate system are converted to the body axes
coordinate system for use during the simulation.

1. User Defined Coordinate System
---------------------------------

Two things are set by the user in the user input coordinate system:

1. **Coordinate System Origin**: The origin of the coordinate system is set at
any point along the rocket's center line. This point can be arbitrarily chosen
and is not explicitly defined. All inputs must be given in relation to this
point.
2. **Direction of Center Axis**: Specified in the ``coordinate_system_orientation``
argument of the class constructor :class:`rocketpy.Rocket.__init__`. This
argument defines the direction of the axis that follows the rocket's center
line. It can be either ``"nose_to_tail"`` or ``"tail_to_nose"``.

.. seealso::

See `Positions and Coordinate Systems <positions.rst>`_ for more
information on how this is used in the definitions of the rocket's
aerodynamic surfaces and motor.

The ``x`` and ``y`` axes are defined in the plane perpendicular to the center axis,
and the ``z`` axis is defined along the center axis. Depending on the choice of
``coordinate_system_orientation``, the ``x`` axis and ``y`` axis can be inverted.

The following figure shows the two possibilities for the user input coordinate system:

.. figure:: ../../static/rocket/3dcsys.png
:align: center
:alt: Rocket axes

.. note::

When ``coordinate_system_orientation`` is set to ``"tail_to_nose"``, the direction
of the ``x``, ``y``, and ``z`` axes of the **User Defined Coordinate System** is
the same as the **Body Axes Coordinate System**. The orgin of the coordinate
Gui-FernandesBR marked this conversation as resolved.
Show resolved Hide resolved
system may still be different.

Angular Position Inputs
~~~~~~~~~~~~~~~~~~~~~~~

Angular position inputs (``angular_position``) refer to the roll angle position
of that surface along the rocket's tube. The roll angle is defined as the angle
from the ``y`` axis to the surface. Currently, only :class:`rocketpy.RailButtons`
use this input.

The following figure shows the roll angle
definition for both ``coordinate_system_orientation`` options:

.. figure:: ../../static/rocket/angularpos.png
:align: center
:alt: Angular position


.. note::

The positive direction of the roll angle is defined as the direction that
rotates the surface in the positive direction of the ``z`` axis.



2. Body Axes Coordinate System
------------------------------

The body axes coordinate system is used inside the simulation to assess the
governing equations of motion. The body axes coordinate system is defined as follows:

- The origin is at the rocket's center of dry mass (``center_of_dry_mass_position``).
- The ``z`` axis is defined along the rocket's centerline, pointing from the
center of dry mass towards the nose.
- The ``x`` and ``y`` axes are perpendicular.

3. Relation to Flight Coordinates
---------------------------------

The ``Flight`` class uses a coordinate system defined as follows:

- The origin is at the launch rail.
- The ``Z`` axis is positive upwards.
- The ``X`` axis is position eastwards.
- The ``Y`` axis is positive northwards.

The following figure shows the rotational relationship between the
**Body Axes Coordinate System** and the **Flight Coordinate System**:

.. figure:: ../../static/rocket/flightcsys.png
:align: center
:alt: Flight coordinate system

In the figure $\bf{i}$** is the ``inclination`` and $\bf{h}$ is the
Gui-FernandesBR marked this conversation as resolved.
Show resolved Hide resolved
``heading`` of the launch rail.

The heading and inclination can be described in terms of Euler angles.
The relation is given by:

.. math::
\begin{aligned}
&\text{Precession:} \quad &\psi &= -\bf{h} \\
&\text{Nutation:} \quad &\theta &= \bf{i} - 90° \\
\end{aligned}

A last rotation is defined by the ``angular_position`` of the rocket's rail buttons.
This is a rotation around the rocket's centerline, and describes the last
Euler angle:

.. math::
\begin{aligned}
&\text{Spin:} \quad &φ & \\
\end{aligned}

If no rail buttons are present, the spin angle is set to **0°**.

.. note::

With spin angle set to **0°**, if the
lauch rail ``heading`` is set to **0°** and rail ``inclination`` to **90°**,
the **Body Axes Coordinate System** is aligned with the **Flight Coordinate System**.


This is used to calculate the initial orientation of the rocket, which is
expressed in Euler parameters (quaternions). The Euler parameters are defined
using the 3-1-3 rotation sequence:

.. math::

\begin{aligned}
e₀ &= \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) \\
e₁ &= \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) \\
e₂ &= \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) \\
e₃ &= \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) \\
\end{aligned}


Gui-FernandesBR marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ to the rocket in one step:
.. caution::

Again, pay special attention to the ``position`` parameter. See
the :ref:`Adding Aerodynamic Surfaces <add_surfaces>` section for
the :ref:`Adding Aerodynamic Surfaces <addsurface>` section for
more information.

.. seealso::
Expand Down
4 changes: 4 additions & 0 deletions rocketpy/mathutils/vector_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -955,6 +955,10 @@ def transformation(quaternion):
-------
Matrix
The transformation matrix from frame B to frame A.

Reference
---------
.. [1] https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles
"""
q_w, q_x, q_y, q_z = quaternion
return Matrix(
Expand Down
7 changes: 4 additions & 3 deletions rocketpy/rocket/aero_surface/fins/elliptical_fins.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ class EllipticalFins(Fins):

Note
----
Local coordinate system: Z axis along the longitudinal axis of symmetry,
positive downwards (top -> bottom). Origin located at the top of the root
chord.
Local coordinate system: Origin located at the top of the root chord. Z axis
along the longitudinal axis of symmetry, positive downwards (top -> bottom).
Y axis perpendicular to the Z axis, in the span direction, positive upwards.
X axis completes the right-handed coordinate system.

See Also
--------
Expand Down
7 changes: 4 additions & 3 deletions rocketpy/rocket/aero_surface/fins/fins.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ class Fins(AeroSurface):

Note
----
Local coordinate system: Z axis along the longitudinal axis of symmetry,
positive downwards (top -> bottom). Origin located at the top of the root
chord.
Local coordinate system: Origin located at the top of the root chord. Z axis
along the longitudinal axis of symmetry, positive downwards (top -> bottom).
Y axis perpendicular to the Z axis, in the span direction, positive upwards.
X axis completes the right-handed coordinate system.

Attributes
----------
Expand Down
7 changes: 4 additions & 3 deletions rocketpy/rocket/aero_surface/fins/trapezoidal_fins.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ class TrapezoidalFins(Fins):

Note
----
Local coordinate system: Z axis along the longitudinal axis of symmetry,
positive downwards (top -> bottom). Origin located at the top of the root
chord.
Local coordinate system: Origin located at the top of the root chord. Z axis
along the longitudinal axis of symmetry, positive downwards (top -> bottom).
Y axis perpendicular to the Z axis, in the span direction, positive upwards.
X axis completes the right-handed coordinate system.

See Also
--------
Expand Down
3 changes: 3 additions & 0 deletions rocketpy/rocket/aero_surface/rail_buttons.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import numpy as np

from rocketpy.mathutils.function import Function
from rocketpy.prints.aero_surface_prints import _RailButtonsPrints

Expand Down Expand Up @@ -39,6 +41,7 @@ def __init__(self, buttons_distance, angular_position=45, name="Rail Buttons"):
super().__init__(name, None, None)
self.buttons_distance = buttons_distance
self.angular_position = angular_position
self.angular_position_rad = np.radians(angular_position)
self.name = name

self.evaluate_lift_coefficient()
Expand Down
41 changes: 25 additions & 16 deletions rocketpy/rocket/rocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from rocketpy.control.controller import _Controller
from rocketpy.mathutils.function import Function
from rocketpy.mathutils.vector_matrix import Matrix
from rocketpy.mathutils.vector_matrix import Matrix, Vector
from rocketpy.motors.motor import EmptyMotor
from rocketpy.plots.rocket_plots import _RocketPlots
from rocketpy.prints.rocket_prints import _RocketPrints
Expand Down Expand Up @@ -885,7 +885,7 @@ def add_motor(self, motor, position): # pylint: disable=too-many-statements

See Also
--------
:ref:`add_surfaces`
:ref:`addsurface`

Returns
-------
Expand Down Expand Up @@ -950,7 +950,7 @@ def add_surfaces(self, surfaces, positions):

See Also
--------
:ref:`add_surfaces`
:ref:`addsurface`

Returns
-------
Expand Down Expand Up @@ -1009,10 +1009,16 @@ def add_tail(
By tail position, understand the point belonging to the tail which
is highest in the rocket coordinate system (i.e. the point
closest to the nose cone).
radius : int, float, optional
Reference radius of the tail. This is used to calculate lift
coefficient. If None, which is default, the rocket radius will
be used.
name : string
Tail name. Default is "Tail".

See Also
--------
:ref:`add_surfaces`
:ref:`addsurface`

Returns
-------
Expand Down Expand Up @@ -1041,7 +1047,6 @@ def add_nose(
along the rocket and its derivative of the coefficient of lift
in respect to angle of attack.


Parameters
----------
length : int, float
Expand All @@ -1067,7 +1072,7 @@ def add_nose(

See Also
--------
:ref:`add_surfaces`
:ref:`addsurface`

Returns
-------
Expand Down Expand Up @@ -1132,10 +1137,6 @@ def add_trapezoidal_fins(
By fin set position, understand the point belonging to the root
chord which is highest in the rocket coordinate system (i.e.
the point closest to the nose cone tip).

See Also
--------
:ref:`add_surfaces`
cant_angle : int, float, optional
Fins cant angle with respect to the rocket centerline. Must
be given in degrees.
Expand Down Expand Up @@ -1228,10 +1229,6 @@ def add_elliptical_fins(
set position, understand the point belonging to the root chord which
is highest in the rocket coordinate system (i.e. the point
closest to the nose cone tip).

See Also
--------
:ref:`add_surfaces`
cant_angle : int, float, optional
Fins cant angle with respect to the rocket centerline. Must be given
in degrees.
Expand All @@ -1254,6 +1251,10 @@ def add_elliptical_fins(
The tuple's second item is the unit of the angle of attack,
accepting either "radians" or "degrees".

See Also
--------
:ref:`addsurface`

Returns
-------
fin_set : EllipticalFins
Expand Down Expand Up @@ -1473,7 +1474,11 @@ def add_air_brakes(
return air_brakes

def set_rail_buttons(
self, upper_button_position, lower_button_position, angular_position=45
self,
upper_button_position,
lower_button_position,
angular_position=45,
radius=None,
):
"""Adds rail buttons to the rocket, allowing for the calculation of
forces exerted by them when the rocket is sliding in the launch rail.
Expand All @@ -1498,20 +1503,24 @@ def set_rail_buttons(
relative to one of the other principal axis.
Default value is 45 degrees, generally used in rockets with
4 fins.
radius : int, float, optional
Fuselage radius where the rail buttons are located.

See Also
--------
:ref:`add_surfaces`
:ref:`addsurface`

Returns
-------
rail_buttons : RailButtons
RailButtons object created
"""
radius = radius if radius else self.radius
buttons_distance = abs(upper_button_position - lower_button_position)
rail_buttons = RailButtons(
buttons_distance=buttons_distance, angular_position=angular_position
)
self.rail_buttons = Components()
self.rail_buttons.add(rail_buttons, lower_button_position)
return rail_buttons

Expand Down
Loading
Loading