RocketPy icon indicating copy to clipboard operation
RocketPy copied to clipboard

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

Open GuilhermeAsura opened this issue 3 weeks ago • 2 comments

Pull request type

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

Checklist

  • [x] Tests for the changes have been added (if needed)
  • [x] Docs have been reviewed and added / updated
  • [x] Lint (black rocketpy/ tests/) has passed locally
  • [x] 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

  • [x] 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 avatar Dec 06 '25 03:12 GuilhermeAsura

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

Gui-FernandesBR avatar Dec 06 '25 14:12 Gui-FernandesBR

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

I'm on it!

GuilhermeAsura avatar Dec 06 '25 15:12 GuilhermeAsura