Skip to main content

design

Function design 

Source
pub fn design(file: &OrkFile) -> Imported<Design>
Expand description

Reads the design in a .ork file: the rocket (rocket) and its motors (motors), with thrust curves from the archive’s thrustcurves/*.rse entries or the bundled catalog.

let xml = br#"<?xml version="1.0" encoding="UTF-8"?>
<openrocket version="1.10" creator="OpenRocket 24.12">
  <rocket><name>Sounder</name>
    <motorconfiguration configid="c1" default="true"><name>F15</name></motorconfiguration>
    <subcomponents><stage><name>Sustainer</name><subcomponents>
      <nosecone><name>Nose</name><id>nose</id>
        <material type="bulk" density="1000.0">Plastic</material>
        <length>0.15</length><thickness>0.002</thickness><shape>ogive</shape>
        <aftradius>0.0165</aftradius></nosecone>
      <bodytube><name>Body</name><id>body</id>
        <material type="bulk" density="680.0">Cardboard</material>
        <length>0.6</length><thickness>0.001</thickness><radius>0.0165</radius>
        <motormount><ignitionevent>automatic</ignitionevent><ignitiondelay>0.0</ignitiondelay>
          <overhang>0.005</overhang>
          <motor configid="c1"><type>single</type><manufacturer>Estes</manufacturer>
            <designation>F15</designation><diameter>0.029</diameter><length>0.114</length>
            <delay>4.0</delay></motor>
        </motormount></bodytube>
    </subcomponents></stage></subcomponents></rocket>
</openrocket>"#;

let read = hpr_io::ork::read(xml)?;
let design = hpr_io::ork::design(&read.value).value;

// The F15 has no curve in this file, so it comes from the bundled catalog...
let motor = &design.motors.configurations[0].motors[0];
assert!(matches!(motor.curve, hpr_io::ork::Curve::Catalog { .. }));
assert_eq!(motor.delay, Some(hpr_motor::Delay::Seconds(4.0)));
let impulse_ns = motor.curve.motor().expect("a curve").curve().total_impulse_ns();
assert!((impulse_ns - 49.61).abs() < 0.01, "{impulse_ns}");

// ...and it ignites at launch, so the configuration is one the rocket flies.
let assembly = design.rocket.assemble("c1")?;
assert_eq!(assembly.motors[0].mount, "body");