Skip to content

feat: Implement 3D flight animation methods using Vedo (Issue #523) - #909

Merged
Gui-FernandesBR merged 1 commit into
RocketPy-Team:developfrom
GuilhermeAsura:feature/add_animation_methods
Jun 27, 2026
Merged

feat: Implement 3D flight animation methods using Vedo (Issue #523)#909
Gui-FernandesBR merged 1 commit into
RocketPy-Team:developfrom
GuilhermeAsura:feature/add_animation_methods

Conversation

@GuilhermeAsura

Copy link
Copy Markdown
Contributor

Pull request type

  • Code changes (bugfix, features)
  • Code maintenance (refactoring, formatting, tests)

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

Currently, the Flight class lacks built-in methods for 3D visualization of the simulation results. Users wishing to visualize the rocket's trajectory or attitude must export data and use external tools or write custom scripts. This addresses Issue #523.

New behavior

This PR integrates 3D visualization capabilities directly into the Flight class using the vedo library.

Key Changes:

  1. New Methods in Flight:
    • animate_trajectory(file_name, start, stop, time_step): Visualizes the 6-DOF translation of the rocket relative to the ground.
    • animate_rotate(file_name, start, stop, time_step): Visualizes the specific attitude (rotation) of the rocket during flight.
  2. Optional Dependency:
    • Added vedo as an optional dependency in pyproject.toml under the [animation] key.
    • Users can install it via pip install rocketpy[animation].
  3. Error Handling:
    • Both methods check for the existence of vedo and raise a descriptive ImportError with installation instructions if it is missing.
  4. Refactoring:
    • Ported original logic from the legacy animate_flight branch to match the current Flight class structure (e.g., removing deprecated postProcess calls).

Breaking change

  • No

Additional information

Acknowledgements

This feature was originally developed by Patrick Sampaio in the animate_flight branch. This PR adapts that work to the modern develop branch structure and newer RocketPy architecture.

Verification

A modular verification suite was added in tests/animation_verification/ to generate a dummy 3D model and test the invocation of the animation methods.

trajectory_animation

@GuilhermeAsura
GuilhermeAsura requested a review from a team as a code owner December 6, 2025 03:50
@Gui-FernandesBR

Copy link
Copy Markdown
Member

@GuilhermeAsura could you please fix tests and linters on CI?

@GuilhermeAsura

Copy link
Copy Markdown
Contributor Author

@GuilhermeAsura could you please fix tests and linters on CI?

I'm on it!

@Gui-FernandesBR
Gui-FernandesBR force-pushed the feature/add_animation_methods branch from 4a29817 to aebdf6a Compare December 9, 2025 00:25
Comment thread rocketpy/simulation/flight.py
Comment thread tests/animation_verification/rocket_stl.py Outdated

@Gui-FernandesBR Gui-FernandesBR left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

the code coverall looks good, but needs refactor.

We can still add it to the next release (this month)

@Gui-FernandesBR Gui-FernandesBR linked an issue Dec 9, 2025 that may be closed by this pull request

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 7 changed files in this pull request and generated 21 comments.

Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
Comment thread rocketpy/simulation/flight.py Outdated
@Gui-FernandesBR

Copy link
Copy Markdown
Member

Before we merge this PR, some points should be addressed:

  • all plotting methods should be defined withing the plots/ folder
  • the vedo package should be added as an optional requirement
  • Unit tests are needed
  • CHANGELOG.md should be updated
  • The code should be formatted and linted
  • All the comments raised by reviewers should be addressed

@codecov

codecov Bot commented Mar 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 87.93103% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.24%. Comparing base (9cf3dd4) to head (a39ec8f).
⚠️ Report is 89 commits behind head on develop.

Files with missing lines Patch % Lines
rocketpy/plots/flight_plots.py 87.93% 14 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff             @@
##           develop     #909      +/-   ##
===========================================
+ Coverage    80.27%   81.24%   +0.96%     
===========================================
  Files          104      113       +9     
  Lines        12769    14814    +2045     
===========================================
+ Hits         10250    12035    +1785     
- Misses        2519     2779     +260     

☔ View full report in Codecov by Harness.
📢 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.

@Gui-FernandesBR

Copy link
Copy Markdown
Member

I am working on this one locally

@Gui-FernandesBR

Copy link
Copy Markdown
Member

@YuroCastroDev we would love to hear feedbacks from this feature. Do you think you could help us?

@Gui-FernandesBR
Gui-FernandesBR force-pushed the feature/add_animation_methods branch from ab5ef3d to 292eadf Compare June 19, 2026 04:23
Implement 3D visualization of flight results in the plots layer using the
optional `vedo` library, addressing issue #523:

- `animate_trajectory`: 6-DOF translation of the rocket relative to ground.
- `animate_rotate`: rocket attitude (rotation) evolution during flight.

`vedo` is added as an optional dependency under the `[animation]` extra
(`pip install rocketpy[animation]`); both methods raise a descriptive
ImportError with install instructions when it is missing. A bundled
`default_rocket.stl` asset and unit tests for the animation methods are
included, along with user docs (flight, installation) and a colab cell.

Originally developed by Patrick Sampaio in the legacy `animate_flight`
branch and adapted to the current Flight architecture.

Co-Authored-By: GuilhermeAsura <gmslazzarini@gmail.com>
Co-Authored-By: Gui-FernandesBR <guilherme_fernandes@usp.br>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Gui-FernandesBR
Gui-FernandesBR force-pushed the feature/add_animation_methods branch from 292eadf to a39ec8f Compare June 27, 2026 12:54
@Gui-FernandesBR
Gui-FernandesBR merged commit 8035949 into RocketPy-Team:develop Jun 27, 2026
7 checks passed
Gui-FernandesBR added a commit that referenced this pull request Jul 19, 2026
- Fold the Unreleased section into v1.13.0 and date it 2026-07-19.
- Drop reverted PR #958 entries (parachute abstract-base breaking change)
  and its revert #1063 - neither ever reached a release.
- Consolidate the 3D flight animation into a single #1066 (PyVista) entry;
  drop the superseded Vedo-based #909.
- Remove duplicate entries (#1066, #1067, #1055 in Added, #1047 in Added)
  and the doubled "ENH: ENH:" / "MNT: MNT:" auto-changelog prefixes.
- Drop non-user-facing meta entries (#1062 changelog cleanup, #1069 CI fix)
  and the test-only entry (#1051), per the changelog's own scope rules.
- Add the missing #1070 (max_time for StochasticFlight) entry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Gui-FernandesBR added a commit that referenced this pull request Jul 19, 2026
The 3D flight animation switched from Vedo (#909) to PyVista (#1066).
pyproject.toml was updated (animation extra = pyvista + imageio-ffmpeg)
but requirements-optional.txt still pinned the now-unused vedo and was
missing the new deps. Drop vedo and add pyvista/imageio-ffmpeg so both
dependency sources agree.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Gui-FernandesBR added a commit that referenced this pull request Jul 19, 2026
… deps sync (#1073)

* DOC: consolidate and clean v1.13.0 changelog for release

- Fold the Unreleased section into v1.13.0 and date it 2026-07-19.
- Drop reverted PR #958 entries (parachute abstract-base breaking change)
  and its revert #1063 - neither ever reached a release.
- Consolidate the 3D flight animation into a single #1066 (PyVista) entry;
  drop the superseded Vedo-based #909.
- Remove duplicate entries (#1066, #1067, #1055 in Added, #1047 in Added)
  and the doubled "ENH: ENH:" / "MNT: MNT:" auto-changelog prefixes.
- Drop non-user-facing meta entries (#1062 changelog cleanup, #1069 CI fix)
  and the test-only entry (#1051), per the changelog's own scope rules.
- Add the missing #1070 (max_time for StochasticFlight) entry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* MNT: sync optional animation deps in requirements-optional.txt

The 3D flight animation switched from Vedo (#909) to PyVista (#1066).
pyproject.toml was updated (animation extra = pyvista + imageio-ffmpeg)
but requirements-optional.txt still pinned the now-unused vedo and was
missing the new deps. Drop vedo and add pyvista/imageio-ffmpeg so both
dependency sources agree.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Gui-FernandesBR added a commit that referenced this pull request Jul 19, 2026
* ENH: `Function` vectorized speed-up and refactor (#1049)

* MNT: deduplicate function arithmetic logic.

ENH: modularize function arithmetic and source dispatch.

MNT: refactor function math modules.

MNT: optimize function math speed.

* MNT: enhance parachute trigger evaluation for speed.

* MNT: improve typing stack on Function evaluation.

* MNT: architecture corrections and optimizations.

* TST: attempt at tests re-run.

* MNT: minor fixes and docstring update.

* DOC: Update Changelog for PR #1049

* ENH: Interactive 3D Flight Trajectory and Attitude Animation. (#1066)

* ENH: Interactive 3D Flight Trajectory and Attitude Animation.

* TST: update actions workflow dependencies for headless run.

* MNT: solve plot animation review comments on styling.

* DOC: Update Changelog for PR #1066

* MNT: Remove unused pylint disable statements. (#1067)

* DOC: Update Changelog for PR #1067

* TST: cover PyVista flight animation helpers and fix docstring

Fixes the two CI failures on the develop -> master sync (PR #1068):

- DOC/build-docs: the ``color_by`` parameter of ``animate_trajectory``
  used the numpydoc ``{...}`` value-set syntax split across two lines,
  which numpydoc rejects ("invalid value set (missing closing brace)").
  Because the docs job builds with ``-W`` (warnings as errors) the build
  failed. Rewrite the type as a single-line prose description.

- codecov/patch and codecov/project: the new PyVista animation subsystem
  in ``_FlightPlots`` was only exercised by a single minimal off-screen
  smoke test, leaving the scene builders and the pure geometry/telemetry
  helpers uncovered. Add unit tests for the render-independent helpers
  (quaternion rotation, polylines, camera paths, option validation, event
  markers, telemetry panels, background palette, etc.) and extend the
  off-screen integration tests to drive the full set of overlays (charts,
  camera tracking, stability markers, playback controls) and the GIF
  export path.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01VW2VidZmPd93dd8xW8BX2J

* DOC: Update Changelog for PR #1069

* ENH: Add optional `max time` to `stochastic_flight` and create `stochastic_flight` objects with attributes in base flight (#1070)

* Add max_time option to stochastic_flight

* Update: use default attributes in flight object for stochastic flights

* Add tests to check attributes

* Refactor implementation

* MNT: pre-release v1.13.0 cleanup — changelog consolidation + optional deps sync (#1073)

* DOC: consolidate and clean v1.13.0 changelog for release

- Fold the Unreleased section into v1.13.0 and date it 2026-07-19.
- Drop reverted PR #958 entries (parachute abstract-base breaking change)
  and its revert #1063 - neither ever reached a release.
- Consolidate the 3D flight animation into a single #1066 (PyVista) entry;
  drop the superseded Vedo-based #909.
- Remove duplicate entries (#1066, #1067, #1055 in Added, #1047 in Added)
  and the doubled "ENH: ENH:" / "MNT: MNT:" auto-changelog prefixes.
- Drop non-user-facing meta entries (#1062 changelog cleanup, #1069 CI fix)
  and the test-only entry (#1051), per the changelog's own scope rules.
- Add the missing #1070 (max_time for StochasticFlight) entry.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* MNT: sync optional animation deps in requirements-optional.txt

The 3D flight animation switched from Vedo (#909) to PyVista (#1066).
pyproject.toml was updated (animation extra = pyvista + imageio-ffmpeg)
but requirements-optional.txt still pinned the now-unused vedo and was
missing the new deps. Drop vedo and add pyvista/imageio-ffmpeg so both
dependency sources agree.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

* DOC: Update Changelog for PR #1073

---------

Co-authored-by: Pedro Henrique Marinho Bressan <87212571+phmbressan@users.noreply.github.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: ZuoRen Chen <180084773+zuorenchen@users.noreply.github.com>
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.

ENH: adds an 3D animation of flight trajectory

3 participants