Expand description
Where a rocket flies, from what rail, and what a flight tells you.
An Environment is the launch site (latitude, longitude,
elevation), the atmosphere and the wind: the 1976 US Standard Atmosphere and calm air until
you change them.
Flight::builder takes the rocket, the environment and the
rail’s length; its methods lean the rail
(inclination_deg,
heading_deg) and set the integrator
(settings). fly flies it
to the ground.
A Flight has the numbers most asked for (apogee, top speed, rail exit
speed, landing) as methods, and every metric in its
summary. Heights are the center of gravity’s, above the
launch site; the rocket starts on the rail, so the first height isn’t zero.
To keep the path, pass an observer to fly_with: a
Recorder keeps a row of the channels you ask for at a steady
interval and at every event.
use hpr::hpr_sim::{Channel, Recorder};
use hpr::{Environment, Flight};
// Spaceport America, 1,400 m up, with 5 m/s of wind from the west.
let environment = Environment::new(32.99, -106.97, 1400.0)?.with_constant_wind(5.0, 270.0)?;
// Height every half second, and at each event.
let mut recorder = Recorder::new(vec![Channel::Time, Channel::HeightAboveGround], Some(0.5))
.map_err(hpr::Error::Sim)?;
let flight = Flight::builder(&rocket, &environment, 1.8)
.inclination_deg(85.0)
.heading_deg(270.0)
.fly_with(&mut recorder)?;
let highest = recorder.rows().iter().map(|row| row[1]).fold(0.0, f64::max);
assert_eq!(Some(highest), flight.apogee_m());The site’s Flight metrics page defines each metric, and Recording a trajectory each channel.