Attitude Ephemeris Message (CCSDS 504.0-B-2)
README.md

aem #

Attitude Ephemeris Messages (CCSDS 504.0-B-2) for OCaml.

An Attitude Ephemeris Message (AEM) records where a spacecraft points over
time: a list of segments, each naming the object and its reference frames,
followed by time-tagged attitudes. An attitude is a rotation from one frame
to another, so a segment names both (REF_FRAME_A and REF_FRAME_B),
typically an inertial frame such as EME2000, fixed against the distant
stars, and the spacecraft's body frame, and says which way the rotation
goes (ATTITUDE_DIR, A2B or B2A). Flight dynamics tools exchange these
files in the KVN (Keyword=Value Notation) text format. aem parses and
prints that format, with attitudes either as quaternions (scalar last, the
QC convention) or as three Euler angles in degrees.

Three angles give an attitude only with the axes they turn about and the
order of the turns, for example 3-2-1 (about Z, then Y, then X). The
standard puts that sequence in the segment's metadata, under the
EULER_ROT_SEQ keyword. aem does not read that keyword yet, so a caller
that uses Euler angles must know the sequence from the mission.

The reference is CCSDS 504.0-B-2,
Attitude Data Messages. The XML form of the standard is not supported.

Installation #

Install with opam:

$ opam install aem

If opam cannot find the package, it has probably not reached the public
opam-repository yet. Add the overlay repository, then install it:

$ opam repo add samoht https://tangled.org/gazagnaire.org/opam-overlay.git
$ opam update
$ opam install aem

Usage #

let dump kvn_text =
  match Aem.of_string kvn_text with
  | Ok aem ->
      Printf.printf "Object: %s\n"
        (List.hd aem.segments).metadata.object_name;
      let seg = List.hd aem.segments in
      let att = seg.data.(0) in
      (match att.attitude with
       | Aem.Quaternion q ->
           Printf.printf "Quaternion: (%.6f, %.6f, %.6f, %.6f)\n"
             q.q1 q.q2 q.q3 q.qc
       | Aem.Euler e ->
           Printf.printf "Euler: (%.6f, %.6f, %.6f)\n"
             e.angle_1 e.angle_2 e.angle_3)
  | Error e -> Fmt.epr "%a\n" Kvn.pp_error e

API overview #

  • type t: an AEM file, a header and a list of segments.
  • type segment: the metadata and the array of attitude data points of
    one segment.
  • type attitude_data: an epoch and a quaternion or Euler angles.
  • of_string: parse KVN text; its error is a Kvn.error.
  • to_string: print a message back as KVN text.

Licence #

ISC