Skip to content

BUG: Unecessary Gyroscope Rotation and Wrong Acceleremoter Rotation #811

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 7 commits into from
Apr 26, 2025

Conversation

MateusStano
Copy link
Member

Pull request type

  • Code changes (bugfix, features)

Description

Some rotations were wrong in the sensors class:

  • The gyroscope receives an angular velocity described in the body frame. There was an extra rotation being made. That was removed since it is not needed
  • The accelerometer receives an acceleration vector described in the inertial frame. This vector was then wrongly rotated from body to inertial, when it should be inertial to body. This was fixed by adding a .transpose
  • Acceleration and velocity attributes described in the body frame were created in the flight class for clarity

I also took the chance to improve/correct some of the docs strings of some Flight attributes

@MateusStano MateusStano requested a review from a team as a code owner April 24, 2025 18:43
@MateusStano MateusStano self-assigned this Apr 24, 2025
@Gui-FernandesBR Gui-FernandesBR requested a review from Copilot April 24, 2025 18:45
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes bugs in sensor rotation handling and clarifies sensor behavior by correcting the rotation transformations and updating docstrings for clarity. Key changes include:

  • Removing an extra rotation for gyroscopes and correcting the accelerometer’s rotation direction.
  • Updating tests to use the new sensor rotation naming and comparing individual sensor outputs.
  • Refining flight class documentation to clearly reflect the inertial and body frame conventions.

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.

File Description
tests/unit/test_sensor.py Updated test cases to compare against the new rotation_sensor_to_body and adjusted transposition.
tests/integration/test_sensor.py Separated axis comparisons for accelerometer and gyroscope to match the fixed sensor rotations.
rocketpy/simulation/flight.py Revised docstrings for flight attributes and added body frame functions for clarity.
rocketpy/sensors/sensor.py, gyroscope.py, accelerometer.py, sensors_prints.py Replaced rotation_matrix with rotation_sensor_to_body and adjusted related matrix operations.
Comments suppressed due to low confidence (4)

rocketpy/simulation/flight.py:2176

  • The docstring for Flight.alpha2 incorrectly refers to the x direction. Since yaw acceleration typically corresponds to the y-axis, please update this to reflect the correct axis.
Angular acceleration of the rocket in the x direction of the rocket's body frame as a function of time, in rad/s. Sometimes referred to as yaw acceleration.

rocketpy/simulation/flight.py:2184

  • The docstring for Flight.alpha3 incorrectly refers to the x direction. Roll acceleration should be associated with the z-axis, so please update the description accordingly.
Angular acceleration of the rocket in the x direction of the rocket's body frame as a function of time, in rad/s. Sometimes referred to as roll acceleration.

rocketpy/simulation/flight.py:2215

  • For Flight.M2, the description should likely refer to the y-axis (not the x-axis) to correctly match its intended behavior.
Aerodynamic moment acting along the x-axis of the rocket's body frame as a function of time. Expressed in Newtons (N).

rocketpy/simulation/flight.py:2222

  • For Flight.M3, the description should likely refer to the z-axis (not the x-axis) to correctly reflect its role, so please update the docstring.
Aerodynamic moment acting along the x-axis of the rocket's body frame as a function of time. Expressed in Newtons (N).

Copy link
Member

@Gui-FernandesBR Gui-FernandesBR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM,

Nice work solving the BUG so promptly. Thanks, @MateusStano !!

@github-project-automation github-project-automation bot moved this from Backlog to Next Version in LibDev Roadmap Apr 24, 2025
Copy link

codecov bot commented Apr 24, 2025

Codecov Report

Attention: Patch coverage is 97.56098% with 1 line in your changes missing coverage. Please review.

Project coverage is 79.83%. Comparing base (4df0b38) to head (43cf778).
Report is 18 commits behind head on develop.

Files with missing lines Patch % Lines
rocketpy/sensors/sensor.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #811      +/-   ##
===========================================
+ Coverage    79.11%   79.83%   +0.71%     
===========================================
  Files           96       97       +1     
  Lines        11575    11930     +355     
===========================================
+ Hits          9158     9524     +366     
+ Misses        2417     2406      -11     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@MateusStano MateusStano merged commit 7ee0872 into develop Apr 26, 2025
10 checks passed
@MateusStano MateusStano deleted the bug/wrong-rotation-gyroscope branch April 26, 2025 15:28
@github-project-automation github-project-automation bot moved this from Next Version to Closed in LibDev Roadmap Apr 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Closed
Development

Successfully merging this pull request may close these issues.

2 participants