Astrodynamics C++ library where I am implementing my learnings in the field
- N-body problem simulation
- Numerical integration methods: Euler, RK4, RK45
- Time handling since 1972: TAI, TT, GPST, UTC.
- TLE satellite data parsing from Celestrak.
- Conversion between cartesian, keplerian elements, spherical coordinates.
- Ground tracks can be retrieved with some effort using Earth Rotation Angle.
- Built-in mathematical operations
Important
The library can only be used in a Linux environment.
- Add the GitHub repository as a submodule to your project.
git submodule add https://github.com/gabri-aero/astrosimcpp
- Link the library to your CMake project.
add_subdirectory(astrosimcpp)
target_link_libraries(_core PRIVATE astrosim)
You could also build the library yourself.
- Clone the GitHub repository
git clone https://github.com/gabri-aero/astrosimcpp
- Build the library
cd astrosimcpp
mkdir build
cd build
cmake ..
Note
Direct installation is not yet supported.
CSpice is automatically downloaded into the external
folder. Moreover, default kernels are also retrieved from NASA's NAIF website and stored into data/kernels
directory. In case you want to use your custom kernels you can add them into this folder and then load them as follows:
#include <spice/Spice.hpp>
spice::load_kernel('tnosat_v001_53092511_jpl005_20220908.bsp')
More information on SPICE kernels can be found in the NAIF JPL webesite: https://naif.jpl.nasa.gov/naif/toolkit.html.
An example to conduct a three body simulation is provided.
// Import necessary header files
#include <bodies/Body.hpp>
#include <propagator/Propagator.hpp>
// Define bodies
double au = 1.49e11;
Body sun("SUN", 1.989e30, {0, 0, 0, 0, 0, 0});
Body earth("EARTH", 5.972e24, {au, 0, 0, 0, sqrt(sun.get_mu()/au), 0});
Body mars("MARS", 6.419e23, {1.52*au, 0, 0, 0, sqrt(sun.get_mu()/(1.52*au)), 0});
// Create propagation start and end epochs
Epoch start(2024, 1, 1, 0, 0, 0);
Epoch end(2025, 1, 1, 0, 0, 0);
// Create propagator
Propagator propagator(start, end);
// Add bodies to the propagator
propagator.add_bodies(sun, earth, mars);
// Create integrator
double day = 3600;
auto integrator = std::make_shared<RK4>(1*day);
// Add integrator to propagator
propagator.set_integrator(integrator);
// Run simulation
propagator.run();
// Retrieve bodies trajectories
auto sun_trajectory = propagator.get_trajectory(sun);
auto mars_trajectory = propagator.get_trajectory(mars);
auto earth_trajectory = propagator.get_trajectory(earth);
The following features are intended to be added in upcoming versions:
- Planetary ephemeris
- Body child classes to handle satellites and natural bodies
- Maneuvers
- Event handling
- Orbital perturbations
- UT1 time
-
D. A. Vallado, “Fundamentals of Astrodynamics and Applications,” 2013.
-
O. Montenbruck and E. Gill, Satellite Orbits. Springer Berlin Heidelberg, 2000.
-
H. D. Curtis, Orbital Mechanics for Engineering Students. 2010.
-
IAU SOFA - Standards of Fundamental Astronomy: https://iausofa.org/
-
International Earth Rotation and Reference Systems Service: https://www.iers.org/
-
Acton, C.H.; "Ancillary Data Services of NASA's Navigation and Ancillary Information Facility;" Planetary and Space Science, Vol. 44, No. 1, pp. 65-70, 1996. DOI 10.1016/0032-0633(95)00107-7
-
Charles Acton, Nathaniel Bachman, Boris Semenov, Edward Wright; A look toward the future in the handling of space science mission geometry; Planetary and Space Science (2017); DOI 10.1016/j.pss.2017.02.013