Skip to content

Conversation

@aZira371
Copy link
Collaborator

@aZira371 aZira371 commented Nov 27, 2025

Pull request type

  • Code changes (bugfix, features)

Checklist

  • Tests for the changes have been added (if needed)
  • Docs have been reviewed and added / updated
  • Lint (black rocketpy/ tests/) has passed locally
  • All tests (pytest tests -m slow --runslow) have passed locally
  • CHANGELOG.md has been updated (if relevant)

Current behavior

The 3-DOF flight simulation keeps a fixed attitude throughout the flight. The quaternion derivatives are always zero, meaning the body axis direction never evolves despite changes in the relative wind direction.
#882

New behavior

Introduces an evolving unit direction vector for the body axis using a quasi-static weathercocking model. The rocket's attitude gradually aligns toward the relative wind direction.

Changes:

  • New weathercock_coeff parameter in Flight.init (default: 1.0)
  • Updated u_dot_generalized_3dof to compute quaternion derivatives proportional to misalignment with relative wind
  • Angular velocity = weathercock_coeff * sin(misalignment_angle)
  • Added example notebook docs/examples/bella_lui_3dof_vs_6dof_comparison.ipynb comparing 6-DOF and 3-DOF simulations

Breaking change

  • No

Additional information

A new jupyter notebook to be added, depicting comparison of 3 dof and 6 dof. It also highlights use of weathercocking coefficient.

@aZira371 aZira371 changed the title Enh/3 dof lateral motion improvement ENH/3-dof lateral motion improvement Nov 27, 2025
@aZira371 aZira371 changed the title ENH/3-dof lateral motion improvement ENH: 3-dof lateral motion improvement Nov 27, 2025
@aZira371 aZira371 self-assigned this Nov 27, 2025
@codecov
Copy link

codecov bot commented Nov 27, 2025

Codecov Report

❌ Patch coverage is 97.14286% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 80.99%. Comparing base (9cf3dd4) to head (3693e5e).
⚠️ Report is 20 commits behind head on develop.

Files with missing lines Patch % Lines
rocketpy/simulation/flight.py 97.14% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #883      +/-   ##
===========================================
+ Coverage    80.27%   80.99%   +0.72%     
===========================================
  Files          104      107       +3     
  Lines        12769    13642     +873     
===========================================
+ Hits         10250    11050     +800     
- Misses        2519     2592      +73     

☔ 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.

@aZira371
Copy link
Collaborator Author

This is a new implementation within 3 dof. Please critique it and suggest improvements!

@aZira371 aZira371 marked this pull request as ready for review November 27, 2025 14:42
@aZira371 aZira371 requested a review from a team as a code owner November 27, 2025 14:42
Copy link

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 introduces a quasi-static weathercocking model for 3-DOF flight simulations to improve lateral motion realism. Previously, the 3-DOF simulation maintained a fixed attitude throughout flight, which was unrealistic. The new implementation allows the rocket's body axis to gradually align with the relative wind direction based on a configurable coefficient.

Key changes:

  • Added weathercock_coeff parameter to control the rate of attitude alignment in 3-DOF simulations
  • Implemented quaternion evolution in u_dot_generalized_3dof using cross-product-based rotation toward relative wind
  • Added comprehensive unit tests validating the weathercocking behavior across different scenarios

Reviewed changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 13 comments.

File Description
rocketpy/simulation/flight.py Added weathercock_coeff parameter (default 1.0) and implemented weathercocking model that computes quaternion derivatives to align body axis with relative wind direction in 3-DOF mode
tests/unit/simulation/test_flight_3dof.py Added 5 new tests covering parameter storage, default values, fixed attitude with zero coefficient, attitude evolution with misalignment, and alignment verification
tests/conftest.py Fixed import ordering to follow alphabetical convention (matplotlib before netCDF4)

Copy link

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

Copilot reviewed 5 out of 5 changed files in this pull request and generated 6 comments.

aZira371 and others added 8 commits November 27, 2025 21:17
- ENH: a new notebook bella_lui_3dof_vs_6dof.ipynb which uses new implementations of weathercocking model on 3dof
- ENH: introduced new weathercock_coeff parameter in Flight.init (default: 1.0)

- ENH: updated u_dot_generalized_3dof to compute quaternion derivatives proportional to misalignment with relative wind

- ENH: angular velocity = weathercock_coeff * sin(misalignment_angle)
- ENH: unit tests added for weathercocking to check whether weathercock_coeff=0 results in fixed attitude (no quaternion change).

- MNT: format and lint updates for new additions
- DOC: added 3 dof and 6 dof comparison analysis to three_dof_simulation.rst

- DOC: updated iusers/index.rst to build three_dof_simulation.rst

- MNT: deleted the bella_lui_3dof_vs_6dof_comparison.ipynb as the doc now covers this section
- MNT: corrected doc string to represent correct orientation

- MNT: improved tolerance of check on quaternion derivative which should be ideally very small when axes are aligned
…cocking

- BUG: implemented a dot product check to ensure that singularity bug is avoided when rocket body and wind velocity are anti aligned to make rocket statically stable (in u_dot_generalized_3dof)

- MNT: removed redundant double assignment of e0 and w0 vectors within u_dot_generalized_3dof

- MNT: format correction to test_flight_3dof.py
- MNT: 3 dof documentation only referred in users section/getting started

- MNT: correction of docstring in flight.py

- MNT: corrected unit_vector call when defining rotation axis in u_dot_generalized_3dof

- MNT:  docstring correction in test_flight_3dof.py

- ENH: test coverage added for anti alignment case in weathercock model to test_flight_3dof.py
@Gui-FernandesBR Gui-FernandesBR force-pushed the enh/3-dof-lateral-motion-improvement branch from 5f33d7f to fc4228c Compare November 28, 2025 00:17
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.

overall the code looks clean. I see a few things that concerns me, so I listed below.

- MNT: fixed default weathercock_coeff value in flight.py to match 3 dof behaviour by default

- MNT: corrected fixtures and docstrings in test_flight_3dof.py
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.

@aZira371 overall I'm pretty confident with this PR.

You can already update the CHANGELOG to include this PR.

Let's wait a few more days to see if there's any other comment from copilot, Stano ou Bressan. If not, I will proceed with merging this one already.

Great job!!

Copy link

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

Copilot reviewed 6 out of 6 changed files in this pull request and generated 17 comments.

aZira371 and others added 10 commits December 1, 2025 14:52
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- MNT: correction of docstring now that fixtures are used.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
- MNT: perp_axis singularity value error implemented to handle edge case for perp_axis being parallel to body axis in weathercocking model of 3 dof.
Copy link

Copilot AI commented Dec 3, 2025

@aZira371 I've opened a new pull request, #902, to work on those changes. Once the pull request is ready, I'll request review from you.

* Initial plan

* DOC: Add note about motor file paths in 3-DOF comparison section

Co-authored-by: aZira371 <99824864+aZira371@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: aZira371 <99824864+aZira371@users.noreply.github.com>
Copy link

Copilot AI commented Dec 3, 2025

@aZira371 I've opened a new pull request, #903, to work on those changes. Once the pull request is ready, I'll request review from you.

Copilot AI and others added 3 commits December 4, 2025 03:34
…lized_3dof (#903)

* Initial plan

* Refactor: eliminate quaternion derivative code duplication in u_dot_generalized_3dof

Co-authored-by: aZira371 <99824864+aZira371@users.noreply.github.com>

* Improve comment clarity in weathercocking aligned case

Co-authored-by: aZira371 <99824864+aZira371@users.noreply.github.com>

---------

Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: aZira371 <99824864+aZira371@users.noreply.github.com>
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

@Gui-FernandesBR Gui-FernandesBR merged commit 14b9984 into develop Dec 3, 2025
10 checks passed
@Gui-FernandesBR Gui-FernandesBR deleted the enh/3-dof-lateral-motion-improvement branch December 3, 2025 22:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Enhancement New feature or request, including adjustments in current codes Flight Flight Class related features

Projects

No open projects
Status: Backlog

Development

Successfully merging this pull request may close these issues.

ENH: implementation of quasi static attitude variation to improve lateral motion of 3 DOF ENH: 3-DOF simulation

3 participants