Skip to main content

Module convert

Module convert 

Source
Expand description

Converting motor files between RASP .eng and RockSim .rse.

Both formats give a motor’s name, maker, casing, masses, delays and thrust curve; the rules for each are in docs/format/eng.md and docs/format/rse.md. What differs is how they say it, and what .rse adds:

.eng.rse
masseskgg
delays6-10-14, P for plugged6,10,14, 1000 for plugged
the curve’s (0, 0) originimplicit, “should not be specified”written out, in every observed file
comments; lines before the headerone <comments> text
type, stated figures, m and cg per pointnoneType, Itot, avgThrust, peakThrust, burn-time, massFrac, Isp, …

eng_to_rse fills what .eng lacks the way the observed .rse files do (the rse page’s writer policy): a (0, 0) origin when the curve starts after ignition; Itot by the trapezoid rule; peakThrust; burn-time, the last time; avgThrust = Itot / burn-time; m, the propellant left, m(t) = m₀ (1 − I(t) / Itot) with m₀ the propellant mass and I the trapezoidal impulse; cg, half the length; both auto-calc flags 1; massFrac = 100 m₀ / initWt; Isp = Itot / (m₀ g₀); and Type="unspecified", which RockSim’s guide requires and the files use when they don’t say.

rse_to_eng drops what .eng can’t hold, each named in a ConvertWarning. hpr uses none of it for a solid motor: it works the mass and center of gravity out from the curve and the masses (SolidMotor::from_envelope). It refuses a hybrid, whose Type a .eng file couldn’t keep, and an engine without delays it can read, since a .eng header must give them. A .eng header is seven fields split on spaces, and OpenRocket refuses more, so a name or a maker of several words is written with _ between them (Estes_Industries,_Inc.).

Round trips. Masses move between kg and g by moving the decimal point in their shortest digits, not by multiplying, so a mass of at most 15 significant digits, in the normal range of a double, comes back bit for bit. One of 16 or 17 digits may not (2 of the 29 bundled .eng files write one, such as 0.0036000000000000003), and a warning says so.

The thrust curve hpr flies comes back bit for bit both ways, and so do the diameter, the length, and the masses above. The rest may come back written differently:

  • delays spelled with commas, spaces, p or 1000 come back in the other spelling, and read as the same delays (DelayList);
  • a name or maker of several words comes back with _ between them, said in a warning;
  • a (0, 0) origin is written in .rse and left out of .eng, so a curve that gives it the other way comes back the usual way;
  • comments lose blank lines and the spaces ending a line, said in a warning; comments after a .eng file’s last motor are dropped, said in a warning;
  • the .rse figures .eng can’t hold are dropped, said in a warning, and filled again by the rules above.

After one conversion, a file converts to the other format and back to the same bytes, but for a .eng motor whose delays name none (-): its .rse file leaves them out, and a .eng header must give them, so converting it back needs them given again.

Structs§

ConvertWarning
Something the other format couldn’t hold as it was.
Converted
A converted file and what the conversion said.

Constants§

RSE_PLUGGED
The delay a .rse file writes for a plugged motor, where .eng writes P.
UNSPECIFIED_TYPE
The Type eng_to_rse writes: a .eng file doesn’t say.

Functions§

eng_to_rse
A .eng file as a .rse file, filled the way RockSim’s files are (see the module’s docs).
g_to_kg
Grams to kilograms, by moving the decimal point as kg_to_g does.
kg_to_g
Kilograms to grams, by moving the decimal point in the mass’s shortest digits rather than multiplying: 0.0041 kg is 4.1 g, where 0.0041 × 1000 is 4.1000000000000005.
rse_to_eng
A .rse file as a .eng file, with what .eng can’t hold named in the warnings.