Skip to content

Fixed sensor.accelerometer gravity sign for consider_gravity = True case - #1175

Open
vapsik wants to merge 1 commit into
RocketPy-Team:developfrom
vapsik:develop-gravity_fix
Open

Fixed sensor.accelerometer gravity sign for consider_gravity = True case#1175
vapsik wants to merge 1 commit into
RocketPy-Team:developfrom
vapsik:develop-gravity_fix

Conversation

@vapsik

@vapsik vapsik commented Aug 16, 2026

Copy link
Copy Markdown

Issue

In the case of consider_gravity = True the current sensor.accelerometer sensor accounts for gravity vector incorrectly — $$a_{ \text{inertial} } = a_{\text{ENU}} + g$$ but since the gravity vector has components $g = (0,0,-9.8)$ in ENU frame then it must be $$a_{ \text{inertial} } = a_{\text{ENU}} - g$$.

A simple example showcasing the current implementation being incorrect is with a stationary state (1) and airless free-falling rocket (2) - both with ENU-aligned accelerometers: 1) during stationary phase where $a_{\text{ENU}} = 0$ the consider_gravity = True accelerometer reading shows $a_{ \text{inertial} } = (0,0,-9.8)$ where as real IMU would show $a_{ \text{inertial} } = (0,0,+9.8)$ as normal force upward from the ground must negate the effect of gravity for achieving the stationary state. 2) as a rocket goes into (airless) free fall real IMU would show inertial acceleration of 0 (weightless) but with current implementation in free fall or near apogee before parachute opening the consider_gravity = True accelerometer shows total acceleration of nearly 19.6 showcasing the wrong gravity sign usage.

Changes

In accelerometer.py changed inertial_acceleration = Vector(u_dot[3:6]) + gravity into inertial_acceleration = Vector(u_dot[3:6]) - gravity.

Test file showcasing the bugs (made with Claude)

repro_gravity_bug.py

@vapsik
vapsik requested a review from a team as a code owner August 16, 2026 10:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant