feat: Implement 3D flight animation methods using Vedo (Issue #523)
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.mdhas 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:
- 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.
- Optional Dependency:
- Added
vedoas an optional dependency inpyproject.tomlunder the[animation]key. - Users can install it via
pip install rocketpy[animation].
- Added
- Error Handling:
- Both methods check for the existence of
vedoand raise a descriptiveImportErrorwith installation instructions if it is missing.
- Both methods check for the existence of
- Refactoring:
- Ported original logic from the legacy
animate_flightbranch to match the currentFlightclass structure (e.g., removing deprecatedpostProcesscalls).
- Ported original logic from the legacy
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.
@GuilhermeAsura could you please fix tests and linters on CI?
@GuilhermeAsura could you please fix tests and linters on CI?
I'm on it!