pub struct FlightBuilder<'a> { /* private fields */ }Expand description
How a flight is launched: which rocket, where, and from what rail. Made by
Flight::builder; FlightBuilder::fly flies it.
Implementations§
Source§impl FlightBuilder<'_>
impl FlightBuilder<'_>
Sourcepub fn inclination_deg(self, inclination_deg: f64) -> Self
pub fn inclination_deg(self, inclination_deg: f64) -> Self
The rail’s angle above the horizon, degrees: 90, the default, is vertical, and 85 leans 5° off it. (OpenRocket’s launch rod angle is measured from the vertical instead: its 5° is 85 here.)
Sourcepub fn heading_deg(self, heading_deg: f64) -> Self
pub fn heading_deg(self, heading_deg: f64) -> Self
The direction the rail leans toward, clockwise from true north, degrees: 0, the default, is north and 90 is east. A wind’s direction is where it blows from, so a rail leaning into a west wind has both at 270. On a vertical rail the heading still turns the rocket about its axis, which way its fins face. That matters to a set of one or two fins, whose lift depends on which way the air meets them; three or more equal fins lift nearly the same whichever way they face.
Sourcepub fn rail(self, rail: Rail) -> Self
pub fn rail(self, rail: Rail) -> Self
The whole rail, in place of the one Flight::builder made: its length, its angles in
radians, the rocket’s roll on it and its friction (Rail).
FlightBuilder::inclination_deg and FlightBuilder::heading_deg, called before or
after, still set its angles.
Sourcepub fn settings(self, settings: FlightSettings) -> Self
pub fn settings(self, settings: FlightSettings) -> Self
The integrator and its limits, in place of the defaults (FlightSettings).
Sourcepub fn separation(self, separation: Separation) -> Self
pub fn separation(self, separation: Separation) -> Self
Flies with separation: at its trigger the stack comes apart at a stage boundary, and
each part flies on to its own landing (Simulation::with_separation, which has the
rules). Every part needs a recovery device on the rocket, each on its own part
(hpr_sim::Device::on_body); for a .ork file, crate::ork::separated_recovery
makes them. Each separated part’s landing is in FlightSummary::body_landings.
Sourcepub fn separations(self, separations: Vec<Separation>) -> Self
pub fn separations(self, separations: Vec<Separation>) -> Self
Flies with separations, in the order they fire, each at a stage boundary further forward
than the one before: a stack that drops its stages one at a time under power
(Simulation::with_separations, which has the rules). As FlightBuilder::separation,
every part needs a device of its own; for a .ork file, crate::ork::separations and
crate::ork::separated_recovery make them. In place of any set before.
Sourcepub fn drag_model(self, model: impl DragModel + 'static) -> Self
pub fn drag_model(self, model: impl DragModel + 'static) -> Self
Flies model’s drag in place of hpr’s drag buildup: a model of your own, from a wind
tunnel, another tool or your flights, or hpr’s own adjusted
(hpr_aero::custom, Simulation::with_drag_model). The model gives the zero-lift
drag coefficient on the rocket’s reference area, by default a circle of its largest body
diameter; unlike a drag table’s, a model’s number isn’t rescaled, so a curve measured on
another area is converted before it is returned. The normal force, center of pressure,
roll and damping stay hpr’s, so the stability margin a Rocket reports doesn’t change.
The last model or table set is the one flown (FlightBuilder::drag_table), and every
flight of this builder shares it.
use hpr::hpr_aero::{AeroError, DragModel, DragQuery};
/// hpr's own drag, 20% higher.
#[derive(Debug)]
struct Rougher;
impl DragModel for Rougher {
fn zero_lift_drag(&self, query: &DragQuery<'_>) -> Result<f64, AeroError> {
Ok(1.2 * query.buildup()?.zero_lift_coefficient)
}
}
let environment = Environment::new(32.99, -106.97, 1400.0)?;
let launch = Flight::builder(&rocket, &environment, 1.8);
let own = launch.fly()?.apogee_m().ok_or("no apogee")?;
let rougher = launch.drag_model(Rougher).fly()?.apogee_m().ok_or("no apogee")?;
assert!(rougher < own);As FlightBuilder::drag_model, with a model already shared: one model, a large table
say, flown by many builders without a copy for each.
Sourcepub fn drag_table(self, table: DragTable) -> Self
pub fn drag_table(self, table: DragTable) -> Self
Flies table’s drag in place of hpr’s drag buildup: another tool’s zero-lift drag
coefficient C_D0 against Mach number, as RocketPy’s power_off_drag and
power_on_drag curves are (DragTable, Simulation::with_drag_table). Its power-on
curve, where it has one, is flown while a motor thrusts, and its power-off curve at every
other time. A table read by DragTable::from_csv interpolates linearly between its Mach
numbers and holds its end values past them; one built from hpr_core::interp::Table1Ds
interpolates and extrapolates as they say. A table on a reference diameter of its own
(DragTable::with_reference_diameter_m) is rescaled to the rocket’s reference area by
the ratio of the two areas, C_D0 · (d_table / d_rocket)². The normal force, center of
pressure, roll and damping stay hpr’s. The last model or table set is the one flown
(FlightBuilder::drag_model). A flight that meets a negative coefficient in the table,
drag that would push the rocket along, stops with an error that says so.
use hpr::hpr_aero::DragTable;
let environment = Environment::new(32.99, -106.97, 1400.0)?;
let launch = Flight::builder(&rocket, &environment, 1.8);
// C_D0 of 0.45 up to Mach 0.8, 0.6 by Mach 1.2; 0.05 less while the motor burns.
let table = DragTable::from_csv(
"mach,cd\n0,0.45\n0.8,0.45\n1.2,0.6\n",
Some("mach,cd\n0,0.40\n0.8,0.40\n1.2,0.55\n"),
)?;
let tabled = launch.clone().drag_table(table).fly()?.apogee_m().ok_or("no apogee")?;
let own = launch.fly()?.apogee_m().ok_or("no apogee")?;
assert_ne!(tabled, own);Sourcepub fn simulation(&self) -> Result<Simulation, Error>
pub fn simulation(&self) -> Result<Simulation, Error>
The Simulation FlightBuilder::fly runs, for what the facade doesn’t offer: user
events, staging, mass shifts and the rest of hpr_sim.
§Errors
Error::NoMotorfor a rocket with no motor.Error::Domainfor an inclination outside(0°, 90°]or a heading that isn’t finite.Error::Simfor whatSimulation::new,Simulation::with_recoveryandSimulation::with_separationsrefuse: a rail that isn’t positive in length, a design with errors in it (hpr_design::checks), a recovery device the flight can’t fly, a separation with a part that carries no device.
Sourcepub fn inputs(&self) -> Result<FlightInputs, Error>
pub fn inputs(&self) -> Result<FlightInputs, Error>
Everything the flight is flown from, as hpr_analysis::montecarlo::FlightInputs: what a
Monte Carlo run disperses (hpr_analysis::montecarlo).
§Errors
Error::NoMotorfor a rocket with no motor.Error::Domainfor an inclination outside(0°, 90°]or a heading that isn’t finite.Error::Simfor a rail that isn’t positive in length or whose friction is negative.
Sourcepub fn fly(&self) -> Result<Flight, Error>
pub fn fly(&self) -> Result<Flight, Error>
Flies the rocket from the rail to the ground.
§Errors
As FlightBuilder::simulation, and Error::Sim for a flight that fails on the way,
such as a model asked about a flow it doesn’t cover.
Sourcepub fn fly_with(&self, observer: &mut dyn Observer) -> Result<Flight, Error>
pub fn fly_with(&self, observer: &mut dyn Observer) -> Result<Flight, Error>
Flies the rocket, showing observer every step of the flight as it goes: a
hpr_sim::Recorder keeps a trajectory, and an Observer of your own can watch for
anything.
§Errors
As FlightBuilder::fly, and whatever observer returns.
Trait Implementations§
Source§impl<'a> Clone for FlightBuilder<'a>
impl<'a> Clone for FlightBuilder<'a>
Source§fn clone(&self) -> FlightBuilder<'a>
fn clone(&self) -> FlightBuilder<'a>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<'a> !RefUnwindSafe for FlightBuilder<'a>
impl<'a> !UnwindSafe for FlightBuilder<'a>
impl<'a> Freeze for FlightBuilder<'a>
impl<'a> Send for FlightBuilder<'a>
impl<'a> Sync for FlightBuilder<'a>
impl<'a> Unpin for FlightBuilder<'a>
impl<'a> UnsafeUnpin for FlightBuilder<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more