Skip to content

ENH: Adds Sensors classes #683

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

Merged
merged 133 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
133 commits
Select commit Hold shift + click to select a range
e403872
ENH: sensors class
MateusStano Apr 1, 2024
6cd3598
ENH: add accelerometer and gyroscope classes
MateusStano Apr 1, 2024
3b81777
ENH: euler to quaternions tool function
MateusStano Apr 1, 2024
4c8aa13
ENH: add sensors to other classes
MateusStano Apr 1, 2024
09e0d75
ENH: prints and sensors draw
MateusStano Apr 1, 2024
38866f4
ENH: add sensors to parachutes
MateusStano Apr 1, 2024
b386e38
TST: add sensors fixtures
MateusStano Apr 1, 2024
6ff2dde
TST: add sensors tests
MateusStano Apr 1, 2024
5ae01b9
DEV: sensors testing notebook
MateusStano Apr 1, 2024
1dd5781
ENH: add option to add noise to each axis seperatly
MateusStano Apr 2, 2024
943542a
MNT: run isort
MateusStano Apr 2, 2024
28ebc46
ENH: calculate u_dot only once for all sensors
MateusStano Apr 2, 2024
378bb54
MNT: change `measured_values` to `measured_data`
MateusStano Apr 2, 2024
d8440f2
TST: unite gyro and accel tests
MateusStano Apr 2, 2024
99f445f
Update rocketpy/plots/rocket_plots.py
MateusStano Apr 11, 2024
4db26f0
ENH: normalize quaternions for transform matrix
MateusStano Apr 12, 2024
4356af7
TST: lower tolerances
MateusStano Apr 12, 2024
5c37f06
BUG: handle zero norm differently due to numpy.float64
MateusStano Apr 15, 2024
8d64998
MNT: quantization typos
MateusStano Apr 15, 2024
28da8f3
DOCS: mention Hadamard product
MateusStano Apr 15, 2024
cef72a0
DOC: complete sensors class docstrings
MateusStano Apr 15, 2024
5f8f1f4
Squashed commit of the following:
MateusStano Apr 29, 2024
9a6b052
MNT: fix component repr for sensors
MateusStano Apr 30, 2024
7953cb0
ENH: add _attatched_rockets to sensors
MateusStano Apr 30, 2024
5a37553
ENH: add sensors saving methods
MateusStano Apr 30, 2024
09ea252
MNT: simplify sensors repr
MateusStano Apr 30, 2024
9851392
ENH: use _save_data in accel and gyro
MateusStano Apr 30, 2024
0f81bc3
ENH: improve accelerometer export
MateusStano Apr 30, 2024
a740fc2
ENH: imrpove gyroscope export
MateusStano Apr 30, 2024
cf6c26d
ENH: add sensor initialization
MateusStano Apr 30, 2024
2a14f1d
ENH: speed up measure call
MateusStano Apr 30, 2024
216523c
ENH: add final sensor cache
MateusStano Apr 30, 2024
09288d4
ENH: add export sensor data
MateusStano Apr 30, 2024
aa6fcdf
BUG: wrong initialization order
MateusStano Apr 30, 2024
bf6b083
TST: test for new measured_data and exports
MateusStano Apr 30, 2024
5f86223
ENH: abstract noise printings
MateusStano Apr 30, 2024
4dcc26b
MNT: run isort
MateusStano May 1, 2024
32898c5
Merge branch 'develop' into enh/sensors
MateusStano May 1, 2024
f7332d8
Merge branch 'develop' into enh/sensors
Gui-FernandesBR May 2, 2024
2131ee9
ENH: add noise variance
MateusStano May 2, 2024
b2da0c3
BUG: fix prints for noise variance
MateusStano May 2, 2024
123d033
TST: add variances
MateusStano May 2, 2024
7d0e6f3
Merge branch 'enh/sensors' of https://github.com/RocketPy-Team/Rocket…
MateusStano May 2, 2024
00f0f3a
Update rocketpy/rocket/rocket.py
MateusStano May 3, 2024
b4b51a4
ENH: add pressure to .measure params
MateusStano May 3, 2024
4c0fbf9
ENH: add InertialSensors and ScalarSensors
MateusStano May 3, 2024
6c4229d
ENH: add Barometer class
MateusStano May 3, 2024
9995904
BUG: fix drawing for scalar sensors
MateusStano May 3, 2024
354e681
ENH: barometer prints
MateusStano May 3, 2024
1f761c0
DOC: change docs for scalar sensors
MateusStano May 4, 2024
17feded
ENH: add barometer export data
MateusStano May 5, 2024
faf098a
BUG: fix scalars sensors prints
MateusStano May 5, 2024
960b1c3
TST: add barometers to tests
MateusStano May 5, 2024
f535e0f
DEV: update sensors testing
MateusStano May 5, 2024
de2d8bd
MNT: remove .type attribute
MateusStano May 6, 2024
fec6725
DOC: fix units of transformation_euler_anges
MateusStano May 6, 2024
ce2a63d
DOC: add examples to transformation_euler_angles
MateusStano May 6, 2024
f2656c5
DOC: mention Euler parameters in docs
MateusStano May 6, 2024
41bf9e9
TST: test_euler_to_quaternions
MateusStano May 6, 2024
11873cd
TST: fix doc tests
MateusStano May 6, 2024
b795031
MNT: privatize components attributes and improve docs
MateusStano May 6, 2024
968f55a
TST: add index to var names
MateusStano May 6, 2024
d827b8e
MNT: return temp drift directly
MateusStano May 6, 2024
0b0f201
ENH: improve export methods
MateusStano May 6, 2024
bad3b07
DOC: typos
MateusStano May 6, 2024
0891c6c
MNT: improve flight init
MateusStano May 6, 2024
fa1b6a8
Fix code style issues with Black
lint-action May 6, 2024
b7439f4
Merge branch 'enh/sensors' of https://github.com/RocketPy-Team/Rocket…
MateusStano May 6, 2024
8c71432
TST: overall improvements on sensor testing
MateusStano May 6, 2024
5885992
ENH: change format of sensor_data dict
MateusStano May 6, 2024
02cad05
MNT: improve flight init
MateusStano May 6, 2024
69f17cd
TST: increase rel tolerances
MateusStano May 6, 2024
6894f58
Merge branch 'enh/sensors' of https://github.com/RocketPy-Team/Rocket…
MateusStano May 6, 2024
8d96e58
TST: fix export sensor data test
MateusStano May 6, 2024
ec4e25e
TST: fix doctests
MateusStano May 6, 2024
adb2dbb
TST: fix doctests
MateusStano May 6, 2024
e0812a2
ENH: change units in prints
MateusStano May 9, 2024
6ec4c0b
ENH: add .round to Matrix and remove broken doctests
MateusStano May 10, 2024
78e67f2
TST: test transfromation euler angles
MateusStano May 10, 2024
d49b5c4
TST: imrpove test_euler_to_quaternions
MateusStano May 10, 2024
57b41ab
DEV: update sensors_testing notebook
Gui-FernandesBR May 15, 2024
7a2e50a
MNT: minor fixes - typos and isort
Gui-FernandesBR May 15, 2024
a57308d
MNT: remove aft double underscore from __units
MateusStano May 16, 2024
11a8ab6
DOC: remove .type
MateusStano May 16, 2024
2984065
MNT: remove .units underscores
MateusStano May 16, 2024
82f79e7
MNT: remove repetition from sensors prints
MateusStano May 16, 2024
5016283
ENH: normalize_quaternions in tools.py
MateusStano May 16, 2024
6806912
BUG: remove Matrix circuklar import in tools
MateusStano May 16, 2024
b99b301
MNT: remove unused variable
MateusStano May 16, 2024
75f8d9e
ENH: explicit for loop variables
MateusStano May 16, 2024
c1864b2
Merge branch 'enh/sensors' of https://github.com/RocketPy-Team/Rocket…
MateusStano May 16, 2024
a20d31d
DOC: improve orientation docs
MateusStano May 16, 2024
ce1d179
ENH: x_position to x_offset
MateusStano May 16, 2024
2e3b895
Merge pull request #583 from RocketPy-Team/enh/sensors
MateusStano May 21, 2024
00cf0c2
Merge remote-tracking branch 'origin/enh/sensors-impl' into enh/barom…
MateusStano May 21, 2024
1e36391
TST: merge tests
MateusStano May 22, 2024
f78e764
ENH: inherited export method
MateusStano May 22, 2024
fbaac53
TST: improve export data tests
MateusStano May 22, 2024
cdb54b1
TST: Refactor sensor tests and export method
MateusStano May 23, 2024
612176d
TST: fix fixture names
MateusStano May 23, 2024
0bd0f51
BUG: duplicate IntertialSensors
MateusStano May 24, 2024
332f3a9
TST: calisto_sensors to calisto_with_sensors
MateusStano Jun 3, 2024
b882579
MNT: isort
MateusStano Jun 3, 2024
5d5f9e9
MNT: remove type docs
MateusStano Jun 3, 2024
f913f86
ENH: move export_sensor_measured_data to tools.py
MateusStano Jun 3, 2024
3558eff
MNT: pylint fixes
MateusStano Jun 3, 2024
7e419b0
ENH: simplify sensors prints
MateusStano Jun 3, 2024
4e5ad4e
MNT: rename sensors classes
MateusStano Jun 3, 2024
4a2eb07
MNT: sensor.py rename
MateusStano Jun 3, 2024
642e1b3
DOC: improve inertialsensor and scalar sensor doc
MateusStano Jun 3, 2024
773ec59
MNT: sensors to sensor rename imports
MateusStano Jun 3, 2024
df02bb4
TST: format argument
MateusStano Jun 3, 2024
332b477
ENH: move generic_export_data back to Sensor class
MateusStano Jun 6, 2024
1d5e769
ENH: rename test files
MateusStano Jun 6, 2024
7f0fe70
ENH: change from celsius to kelvin
MateusStano Jun 13, 2024
0b779f2
TST: fix celsius to kelvin convertion
MateusStano Jun 13, 2024
af410b6
Merge pull request #608 from RocketPy-Team/enh/barometer
MateusStano Jun 13, 2024
5db0ef3
merge develop
MateusStano Jun 14, 2024
5d806c6
MNT: unecessary variable
MateusStano Jun 14, 2024
b4fec6f
Merge branch 'develop' into enh/sensors-impl
MateusStano Jul 8, 2024
de99d86
DEV: solve merge issues
MateusStano Jul 8, 2024
523a819
ENH: Adds GNSS Receiver sensor (#636)
MateusStano Sep 8, 2024
7d873d2
Merge branch 'develop' into enh/sensors-impl
Gui-FernandesBR Sep 8, 2024
6899e9e
DEV: updates changelog
Gui-FernandesBR Sep 8, 2024
6e44d8f
MNT: fix lint
Gui-FernandesBR Sep 8, 2024
1a35067
DOC: improve sensors documentation
Gui-FernandesBR Sep 8, 2024
f4cdc2b
DOC: rename sensors notebook
Gui-FernandesBR Sep 8, 2024
cf1d1ee
Merge branch 'develop' into enh/sensors-impl
Gui-FernandesBR Sep 8, 2024
7fcbdda
Merge branch 'develop' into enh/sensors-impl
Gui-FernandesBR Sep 11, 2024
a0fb6ad
MNT: Add warning for experimental development in Sensor classes
Gui-FernandesBR Sep 12, 2024
2c142c4
MNT: rename euler-quaternion conversions
Gui-FernandesBR Sep 12, 2024
bb8af25
MNT: minor adjustments before merging sensors
Gui-FernandesBR Sep 12, 2024
3c759f7
TST: Add a test for sensors draw
Gui-FernandesBR Sep 12, 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
4 changes: 4 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,14 @@
"github",
"Glauert",
"gmaps",
"Gnss",
"Gomes",
"Gonçalvez",
"grav",
"Guilherme",
"Haim",
"headlength",
"headwidth",
"hemis",
"hgtprs",
"hgtsfc",
Expand Down Expand Up @@ -245,6 +248,7 @@
"reversesort",
"reynolds",
"rightarrow",
"rmul",
"ROABs",
"rocketpy",
"rocketusage",
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Attention: The newest changes should be on top -->

### Added

- DOC : Cavour Flight Example [#682](https://github.com/RocketPy-Team/RocketPy/pull/682)
- ENH: Adds Sensors classes [683](https://github.com/RocketPy-Team/RocketPy/pull/683)
- DOC: Cavour Flight Example [#682](https://github.com/RocketPy-Team/RocketPy/pull/682)
- DOC: Halcyon Flight Example [#681](https://github.com/RocketPy-Team/RocketPy/pull/681)
- ENH: Adds GenericMotor.load_from_eng_file() method [#676](https://github.com/RocketPy-Team/RocketPy/pull/676)
- ENH: Introducing local sensitivity analysis [#575](https://github.com/RocketPy-Team/RocketPy/pull/575)
Expand Down
899 changes: 899 additions & 0 deletions docs/notebooks/sensors.ipynb

Large diffs are not rendered by default.

11 changes: 11 additions & 0 deletions docs/reference/classes/sensors/abstract/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Sensors Abstract Classes
========================

.. toctree::
:maxdepth: 1
:caption: Contents:

Sensor Class <sensor>
Inertial Sensor Class <inertial_sensor>
Scalar Sensor Class <scalar_sensor>

5 changes: 5 additions & 0 deletions docs/reference/classes/sensors/abstract/inertial_sensor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Inertial Class
--------------

.. autoclass:: rocketpy.sensors.InertialSensor
:members:
5 changes: 5 additions & 0 deletions docs/reference/classes/sensors/abstract/scalar_sensor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Scalar Sensor Class
-------------------

.. autoclass:: rocketpy.sensors.ScalarSensor
:members:
5 changes: 5 additions & 0 deletions docs/reference/classes/sensors/abstract/sensor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Sensor Class
------------

.. autoclass:: rocketpy.sensors.Barometer
:members:
5 changes: 5 additions & 0 deletions docs/reference/classes/sensors/accelerometer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Accelerometer Class
---------------

.. autoclass:: rocketpy.sensors.Accelerometer
:members:
5 changes: 5 additions & 0 deletions docs/reference/classes/sensors/barometer.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Barometer Class
---------------

.. autoclass:: rocketpy.sensors.Barometer
:members:
5 changes: 5 additions & 0 deletions docs/reference/classes/sensors/gnss_receiver.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
GNSS Receiver Class
-------------------

.. autoclass:: rocketpy.sensors.GnssReceiver
:members:
5 changes: 5 additions & 0 deletions docs/reference/classes/sensors/gyroscope.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Gyroscope Class
---------------

.. autoclass:: rocketpy.sensors.Gyroscope
:members:
12 changes: 12 additions & 0 deletions docs/reference/classes/sensors/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Sensor Classes
==============

.. toctree::
:maxdepth: 1
:caption: Contents:

Sensors Abstract Classes <abstract/index>
Accelerometer Class <accelerometer>
Barometer Class <barometer>
Gyroscope Class <gyroscope>
GNSS Receiver Class <gnss>
1 change: 1 addition & 0 deletions docs/user/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ RocketPy's User Guide
Compare Flights Class<compare_flights.rst>
Deployable Payload <deployable.rst>
Air Brakes Example <airbrakes.rst>
../notebooks/sensors.ipynb
../matlab/matlab.rst

.. toctree::
Expand Down
1 change: 1 addition & 0 deletions rocketpy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
TrapezoidalFins,
)
from .sensitivity import SensitivityModel
from .sensors import Accelerometer, Barometer, GnssReceiver, Gyroscope
from .simulation import Flight, MonteCarlo
from .stochastic import (
StochasticEllipticalFins,
Expand Down
54 changes: 52 additions & 2 deletions rocketpy/control/controller.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from inspect import signature

from ..prints.controller_prints import _ControllerPrints


Expand Down Expand Up @@ -52,6 +54,10 @@ def __init__(
the controller function can interact with. The objects are
listed in the same order as they are provided in the
`interactive_objects`.
7. `sensors` (list): A list of sensors that are attached to the
rocket. The most recent measurements of the sensors are provided
with the ``sensor.measurement`` attribute. The sensors are
listed in the same order as they are added to the rocket

This function will be called during the simulation at the specified
sampling rate. The function should evaluate and change the interactive
Expand All @@ -78,7 +84,7 @@ def __init__(
None
"""
self.interactive_objects = interactive_objects
self.controller_function = controller_function
self.controller_function = self.__init_controller_function(controller_function)
self.sampling_rate = sampling_rate
self.name = name
self.prints = _ControllerPrints(self)
Expand All @@ -88,7 +94,45 @@ def __init__(
else:
self.observed_variables = []

def __call__(self, time, state_vector, state_history):
def __init_controller_function(self, controller_function):
"""Checks number of arguments of the controller function and initializes
it with the correct number of arguments. This is a workaround to allow
the controller function to receive sensors without breaking changes"""
sig = signature(controller_function)
if len(sig.parameters) == 6:

# pylint: disable=unused-argument
def new_controller_function(
time,
sampling_rate,
state_vector,
state_history,
observed_variables,
interactive_objects,
sensors,
):
return controller_function(
time,
sampling_rate,
state_vector,
state_history,
observed_variables,
interactive_objects,
)

elif len(sig.parameters) == 7:
new_controller_function = controller_function
else:
raise ValueError(
"The controller function must have 6 or 7 arguments. "
"The arguments must be in the following order: "
"(time, sampling_rate, state_vector, state_history, "
"observed_variables, interactive_objects, sensors)."
"Sensors argument is optional."
)
return new_controller_function

def __call__(self, time, state_vector, state_history, sensors):
"""Call the controller function. This is used by the simulation class.

Parameters
Expand All @@ -104,6 +148,11 @@ def __call__(self, time, state_vector, state_history):
history is a list of every state vector of every step of the
simulation. The state history is a list of lists, where each
sublist is a state vector and is ordered from oldest to newest.
sensors : list
A list of sensors that are attached to the rocket. The most recent
measurements of the sensors are provided with the
``sensor.measurement`` attribute. The sensors are listed in the same
order as they are added to the rocket.

Returns
-------
Expand All @@ -116,6 +165,7 @@ def __call__(self, time, state_vector, state_history):
state_history,
self.observed_variables,
self.interactive_objects,
sensors,
)
if observed_variables is not None:
self.observed_variables.append(observed_variables)
Expand Down
2 changes: 1 addition & 1 deletion rocketpy/environment/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ def utm_to_geodesic( # pylint: disable=too-many-locals,too-many-statements
x, y, utm_zone, hemis, semi_major_axis=6378137.0, flattening=1 / 298.257223563
):
# NOTE: already documented in the Environment class.
# TODO: deprecated the static method from the environment class, use only this one.
# TODO: deprecate the static method from the environment class, use only this one.

if hemis == "N":
y = y + 10000000
Expand Down
126 changes: 114 additions & 12 deletions rocketpy/mathutils/vector_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
from functools import cached_property
from itertools import product

from rocketpy.tools import euler321_to_quaternions, normalize_quaternions


class Vector:
"""Pure python basic R3 vector class designed for simple operations.
Expand Down Expand Up @@ -152,7 +154,10 @@ def __len__(self):
@cached_property
def unit_vector(self):
"""R3 vector with the same direction of self, but normalized."""
return self / abs(self)
try:
return self / abs(self)
except ZeroDivisionError:
return self

@cached_property
def cross_matrix(self):
Expand Down Expand Up @@ -238,6 +243,30 @@ def __xor__(self, other):
]
)

def __and__(self, other):
"""Element wise multiplication between two R3 vectors. Also known as
Hadamard product.

Parameters
----------
other : Vector
R3 vector to be multiplied with self.

Returns
-------
Vector
R3 vector resulting from the element wise multiplication between
self and other.

Examples
--------
>>> v = Vector([1, 7, 3])
>>> u = Vector([2, 5, 6])
>>> (v & u)
Vector(2, 35, 18)
"""
return Vector([self.x * other[0], self.y * other[1], self.z * other[2]])

def __matmul__(self, other):
"""Dot product between two R3 vectors."""
return self.x * other.x + self.y * other.y + self.z * other.z
Expand Down Expand Up @@ -914,6 +943,47 @@ def dot(self, other):
"""
return self @ (other)

def round(self, decimals=0):
"""Round all the values matrix to a given number of decimals.

Parameters
----------
decimals : int, optional
Number of decimal places to round to. Defaults to 0.

Returns
-------
Matrix
The rounded matrix.

Examples
--------
>>> M = Matrix([[1.1234, 2.3456, 3.4567], [4.5678, 5.6789, 6.7890], [7.8901, 8.9012, 9.0123]])
>>> M.round(2)
Matrix([1.12, 2.35, 3.46],
[4.57, 5.68, 6.79],
[7.89, 8.9, 9.01])
"""
return Matrix(
[
[
round(self.xx, decimals),
round(self.xy, decimals),
round(self.xz, decimals),
],
[
round(self.yx, decimals),
round(self.yy, decimals),
round(self.yz, decimals),
],
[
round(self.zx, decimals),
round(self.zy, decimals),
round(self.zz, decimals),
],
]
)

def __str__(self):
return (
f"[{self.xx}, {self.xy}, {self.xz}]\n"
Expand Down Expand Up @@ -949,7 +1019,6 @@ def transformation(quaternion):
The quaternion representing the rotation from frame A to frame B.
Example: (cos(phi/2), 0, 0, sin(phi/2)) represents a rotation of
phi around the z-axis.
Note: the quaternion must be normalized.

Returns
-------
Expand All @@ -960,27 +1029,60 @@ def transformation(quaternion):
---------
https://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles
"""
q_w, q_x, q_y, q_z = quaternion
# normalize quaternion
q_w, q_x, q_y, q_z = normalize_quaternions(quaternion)

# pre-compute common terms
q_x2 = q_x**2
q_y2 = q_y**2
q_z2 = q_z**2
q_wx = q_w * q_x
q_wy = q_w * q_y
q_wz = q_w * q_z
q_xy = q_x * q_y
q_xz = q_x * q_z
q_yz = q_y * q_z
return Matrix(
[
[
1 - 2 * (q_y**2 + q_z**2),
2 * (q_x * q_y - q_w * q_z),
2 * (q_x * q_z + q_w * q_y),
1 - 2 * (q_y2 + q_z2),
2 * (q_xy - q_wz),
2 * (q_xz + q_wy),
],
[
2 * (q_x * q_y + q_w * q_z),
1 - 2 * (q_x**2 + q_z**2),
2 * (q_y * q_z - q_w * q_x),
2 * (q_xy + q_wz),
1 - 2 * (q_x2 + q_z2),
2 * (q_yz - q_wx),
],
[
2 * (q_x * q_z - q_w * q_y),
2 * (q_y * q_z + q_w * q_x),
1 - 2 * (q_x**2 + q_y**2),
2 * (q_xz - q_wy),
2 * (q_yz + q_wx),
1 - 2 * (q_x2 + q_y2),
],
]
)

@staticmethod
def transformation_euler_angles(roll, pitch, yaw):
"""Returns the transformation Matrix from frame B to frame A, where B
is rotated by the Euler angles roll, pitch and yaw with respect to A.

Parameters
----------
roll : float
The roll angle in degrees.
pitch : float
The pitch angle in degrees.
yaw : float
The yaw angle in degrees.

Returns
-------
Matrix
The transformation matrix from frame B to frame A.
"""
return Matrix.transformation(euler321_to_quaternions(roll, pitch, yaw))


if __name__ == "__main__":
import doctest
Expand Down
Loading
Loading