Add CSV export example

Signed-off-by: Christopher Rabotin's avatarChristopher Rabotin <christopher.rabotin@gmail.com>
parent b063563b
......@@ -3,3 +3,4 @@
Cargo.lock
tests/Papers
node_modules/
*.csv
\ No newline at end of file
......@@ -37,13 +37,21 @@ The [LICENSE](./LICENSE) will be strictly enforced once this toolkit reaches pro
_Note:_ Some of these features may only be made available only through a commercial license in the future.
# Who am I?
A astrodynamics engineer with a heavy background in software. Nyx relies on the fallbacks of
An astrodynamics engineer with a heavy background in software. Nyx relies on the fallbacks of
[smd](https://github.com/ChristopherRabotin/smd), a library I wrote in Go while researching at the University
of Colorado at Boulder. I work for Advanced Space ([we do cool stuff](http://advanced-space.com/)), but this code is mostly developed on my leisure time.
of Colorado at Boulder. I work for Advanced Space ([we do really cool stuff](http://advanced-space.com/)).
# Examples
Refer to the tests for short examples.
## Exporting states to a CSV file
Refer to the test `qlaw_as_ruggiero_case_f` in `tests/prop/closedloop_multi_oe_ruggiero.rs`.
Or just run it as:
`cargo test qlaw_as_ruggiero_case_f --release -- --nocapture`
And check the file called `rugg_case_f.csv`
## Orbital Determination - Estimation plots of a Halo orbit using a classical Kalman filter
**Note:** the Kalman Filtering capabilities have been validated against JPL Monte using a proprietary scenario.
......
......@@ -6,7 +6,7 @@ use self::hifitime::{Epoch, SECONDS_PER_DAY};
use self::nyx::celestia::{bodies, Cosm, Geoid, State};
use self::nyx::dynamics::celestial::CelestialDynamics;
use self::nyx::dynamics::propulsion::{Propulsion, Thruster};
use self::nyx::dynamics::spacecraft::Spacecraft;
use self::nyx::dynamics::spacecraft::{Spacecraft, SpacecraftState};
use self::nyx::dynamics::thrustctrl::{Achieve, Ruggiero};
use self::nyx::dynamics::Dynamics;
use self::nyx::propagators::events::{EventKind, EventTrackers, OrbitalEvent, SCEvent};
......@@ -360,6 +360,12 @@ fn qlaw_as_ruggiero_case_f() {
components of a spacecraft before defining the spacecraft itself.
*/
// We'll export this trajectory as a POC. Adding the needed crates here
extern crate csv;
use std::sync::mpsc;
use std::sync::mpsc::{Receiver, Sender};
use std::{io, thread};
let cosm = Cosm::from_xb("./de438s");
let earth = cosm.geoid_from_id(bodies::EARTH);
......@@ -395,7 +401,20 @@ fn qlaw_as_ruggiero_case_f() {
let mut sc = Spacecraft::with_prop(dynamics, prop_subsys, dry_mass, fuel_mass);
println!("{:o}", orbit);
let (tx, rx): (Sender<SpacecraftState>, Receiver<SpacecraftState>) = mpsc::channel();
// Set up the writing channel
thread::spawn(move || {
let mut wtr = csv::Writer::from_path("./rugg_case_f.csv").expect("could not create file");
while let Ok(rx_state) = rx.recv() {
// Serialize only the orbital state
wtr.serialize(rx_state.orbit)
.expect("could not serialize state");
}
});
let mut prop = Propagator::new::<RK4Fixed>(&mut sc, &PropOpts::with_fixed_step(10.0));
prop.tx_chan = Some(&tx);
prop.until_time_elapsed(prop_time);
let final_state = prop.dynamics.celestial.state();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment