Skip to content

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

Open
GuilhermeAsura wants to merge 18 commits into
RocketPy-Team:developfrom
GuilhermeAsura:feature/add_animation_methods
Open

feat: Implement 3D flight animation methods using Vedo (Issue #523)#909
GuilhermeAsura wants to merge 18 commits into
RocketPy-Team:developfrom
GuilhermeAsura:feature/add_animation_methods

Conversation

@GuilhermeAsura
Copy link
Copy Markdown

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
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
Copy link
Copy Markdown
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.

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
Copy link
Copy Markdown
Contributor

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.

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

Copy link
Copy Markdown
Contributor

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

- Implemented 3D flight trajectory and attitude animations in the Flight plots layer.
- Added methods `animate_trajectory` and `animate_rotate` to visualize rocket flight.
- Included validation for animation inputs and error handling for missing STL files.
- Updated documentation to reflect new animation features and installation requirements.
- Added optional dependency for `vedo` in `requirements-optional.txt`.
- Created a default STL model for the rocket.
- Removed outdated animation verification tests and replaced them with unit tests for new animation methods.
@Gui-FernandesBR Gui-FernandesBR self-assigned this Mar 14, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 14, 2026

Codecov Report

❌ Patch coverage is 87.93103% with 14 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.16%. Comparing base (9cf3dd4) to head (c3afff0).
⚠️ Report is 72 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.16%   +0.89%     
===========================================
  Files          104      113       +9     
  Lines        12769    14658    +1889     
===========================================
+ Hits         10250    11897    +1647     
- Misses        2519     2761     +242     

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

@Gui-FernandesBR
Copy link
Copy Markdown
Member

I am working on this one locally

Gui-FernandesBR and others added 3 commits May 26, 2026 21:57
Reference vedo classes directly instead of capitalized local aliases
(invalid-name), drop useless returns, and silence too-many-statements
on the animate methods to match the file convention. Lint now scores
10/10 and ruff is clean.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Keep the PR scoped to the animation feature; requests/pytz pinning was
unrelated.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.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