pathfinder-for-autonomous-navigation / psim

Six DOF flight simulator and related GNC implementations.
MIT License
4 stars 6 forks source link

Single Orbit Simulation in Python #244

Closed kylekrol closed 3 years ago

kylekrol commented 3 years ago

Overview

There is a lot of stuff going down in this PR so i am going to take it commit by commit.

Updated lin Pointer

This is pretty self explanatory. The reason for the update was to avoid naming collisions on MacOS with the Bazel BUILD file and some file Python's setup tools likes to create.

Build System Updates

There we a lot of build system updates this time around but here are the highlights:

GNC Updates to the Fixed Step Size Integrators

Per the section header. The integrators were updated to also take a void pointer to allow the end user to pass arbitrary data to the integration step. This will be useful for more complex PSim implementations.

PSim Bugs

We were missing a return statement in a few assignment operators and was why build issues were seen on MacOS.

Earth Ephemeris Model

This is the first model that will pretty much run in every simulation and is just downstream of the time model. It's responsible for outputing information about Earth's attitude and angular rate (i.e. all the information that's needed to transform between ECI and ECEF).

The interface was initially implemented here using existing GNC functions but should be revisited later per #236.

Point Mass Orbit Model

This is a generic interface for a point mass orbit propagator. The orbit propagator can work in whatever frame it wants to and a vector transformer should be added later to abstract away this fact - these will be touched on later.

The orbit propagator implemented here just relies on GNC functions.

Vector Transform Functions

The general idea here is to add a layer of abstraction that abstracts away the particular frame and orbit model, environment model, et cetera is operating in. These models take in a vector vector.lookup.name and output the vector in different frames: vector.lookup.eci, ...

Environment Models

This model generates magnetic field and sun vector truth values for a satellite and should be supplemented with vector transformers.

Single Orbit Simulation

Simply created a model list here with the proper arguments to create a simple simulation of a single point mass orbiting Earth.

Python!!!

If you aren't familiar, I would highly recommend taking a look through the pybind11 docs here. It's a super slick way to interface C++ with Python and it's what's being used here for PSim.

In short, the PSim configuration and single orbit simulations were wrapped and made available to Python. A simple model was thrown together and you can run the simulation currently with the following:

bazel run //python:single_orbit

You should get these plots! This was tested on Arch Linux and MacOS.

Screen Shot 2020-09-26 at 8 55 18 PM

There is plenty more work to be done to clean up the Python side of things a little bit.

kylekrol commented 3 years ago

Commit by commit this should be pretty easy to do! Up until 8415076 are "original" commits on this PR.