# Copyright (C) 2016-2021 Swift Navigation Inc.
# Contact: https://support.swiftnav.com
#
# This source is subject to the license found in the file 'LICENSE' which must
# be distributed together with this source. All other rights reserved.
#
# THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
# EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
# WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.

package: swiftnav.sbp.orientation
description: Orientation Messages
stable: False
public: True
definitions:

 - MSG_BASELINE_HEADING:
    id: 0x020F
    short_desc: Heading relative to True North
    desc: >
      This message reports the baseline heading pointing from the base station
      to the rover relative to True North. The full GPS time is given by the
      preceding MSG_GPS_TIME with the matching time-of-week (tow). It is intended
      that time-matched RTK mode is used when the base station is moving.
    fields:
          - tow:
              type: u32
              units: ms
              desc: GPS Time of Week
          - heading:
              type: u32
              units: mdeg
              desc: Heading
          - n_sats:
              type: u8
              desc: Number of satellites used in solution
          - flags:
              type: u8
              desc: Status flags
              fields:
                - 3-7:
                    desc: Reserved
                - 0-2:
                    desc: Fix mode
                    values:
                        - 0: Invalid
                        - 1: Reserved
                        - 2: Differential GNSS (DGNSS)
                        - 3: Float RTK
                        - 4: Fixed RTK

 - MSG_ORIENT_QUAT:
    id: 0x0220
    short_desc: Quaternion 4 component vector
    desc: >
      This message reports the quaternion vector describing the vehicle body frame's orientation
      with respect to a local-level NED frame. The components of the vector should sum to a unit
      vector assuming that the LSB of each component as a value of 2^-31. This message will only
      be available in future INS versions of Swift Products and is not produced by Piksi Multi
      or Duro.
    fields:
          - tow:
              type: u32
              units: ms
              desc: GPS Time of Week
          - w:
              type: s32
              units: 2^-31
              desc: Real component
          - x:
              type: s32
              units: 2^-31
              desc: 1st imaginary component
          - y:
              type: s32
              units: 2^-31
              desc: 2nd imaginary component
          - z:
              type: s32
              units: 2^-31
              desc: 3rd imaginary component
          - w_accuracy:
              type: float
              units: N/A
              desc: Estimated standard deviation of w
          - x_accuracy:
              type: float
              units: N/A
              desc: Estimated standard deviation of x
          - y_accuracy:
              type: float
              units: N/A
              desc: Estimated standard deviation of y
          - z_accuracy:
              type: float
              units: N/A
              desc: Estimated standard deviation of z
          - flags:
              type: u8
              desc: Status flags
              fields:
                - 3-7:
                    desc: Reserved
                - 0-2:
                    desc: INS Navigation mode
                    values:
                        - 0: Invalid
                        - 1: Valid

 - MSG_ORIENT_EULER:
    id: 0x0221
    short_desc: Euler angles
    desc: >
      This message reports the yaw, pitch, and roll angles of the vehicle body frame.
      The rotations should applied intrinsically in the order yaw, pitch, and roll
      in order to rotate the from a frame aligned with the local-level NED frame
      to the vehicle body frame.  This message will only be available in future
      INS versions of Swift Products and is not produced by Piksi Multi or Duro.
    fields:
          - tow:
              type: u32
              units: ms
              desc: GPS Time of Week
          - roll:
              type: s32
              units: microdegrees
              desc: rotation about the forward axis of the vehicle
          - pitch:
              type: s32
              units: microdegrees
              desc: rotation about the rightward axis of the vehicle
          - yaw:
              type: s32
              units: microdegrees
              desc: rotation about the downward axis of the vehicle
          - roll_accuracy:
              type: float
              units: degrees
              desc: Estimated standard deviation of roll
          - pitch_accuracy:
              type: float
              units: degrees
              desc: Estimated standard deviation of pitch
          - yaw_accuracy:
              type: float
              units: degrees
              desc: Estimated standard deviation of yaw
          - flags:
              type: u8
              desc: Status flags
              fields:
                - 3-7:
                    desc: Reserved
                - 0-2:
                    desc: INS Navigation mode
                    values:
                        - 0: Invalid
                        - 1: Valid
 - MSG_ANGULAR_RATE:
    id: 0x0222
    short_desc: Vehicle Body Frame instantaneous angular rates
    desc: >
      This message reports the orientation rates in the vehicle body frame.
      The values represent the measurements a strapped down gyroscope would
      make and are not equivalent to the time derivative of the Euler angles.
      The orientation and origin of the user frame is specified via device settings.
      By convention, the vehicle x-axis is expected to be aligned with the forward
      direction, while the vehicle y-axis is expected to be aligned with the right
      direction, and the vehicle z-axis should be aligned with the down direction.
      This message will only be available in future INS versions of Swift Products
      and is not produced by Piksi Multi or Duro.
    fields:
          - tow:
              type: u32
              units: ms
              desc: GPS Time of Week
          - x:
              type: s32
              units: microdegrees/s
              desc: angular rate about x axis
          - y:
              type: s32
              units: microdegrees/s
              desc: angular rate about y axis
          - z:
              type: s32
              units: microdegrees/s
              desc: angular rate about z axis
          - flags:
              type: u8
              desc: Status flags
              fields:
                - 2-7:
                    desc: Reserved
                - 0-2:
                    desc: INS Navigation mode
                    values:
                        - 0: Invalid
                        - 1: Valid
 - MSG_ORIENT_QUAT_COV:
    id: 0x0223
    short_desc: Quaternion 4 component vector with full attitude covariance
    desc: >
      This message reports the orientation as a unit quaternion together with
      the upper triangle of the symmetric 3x3 attitude covariance matrix and
      a GPS time-of-week time-tag. The reference frame of the quaternion and
      the parameterization of the covariance matrix are both encoded in the
      flags field, allowing additional frames or parameterizations to be added
      later without introducing a new message. By default the quaternion
      describes the orientation of the vehicle body frame with respect to a
      local-level NED frame (matching MSG_ORIENT_QUAT) and the covariance is
      expressed as small-angle rotation errors about the axes of that NED
      frame; in this default case the cov_x_x, cov_y_y, cov_z_z diagonal
      entries correspond to the variance of the rotation error about North,
      East, and Down respectively. The components of the quaternion sum to a
      unit vector assuming that the LSB of each component has a value of
      2^-31.
    fields:
          - tow:
              type: u32
              units: ms
              desc: GPS Time of Week
          - w:
              type: s32
              units: 2^-31
              desc: Real component
          - x:
              type: s32
              units: 2^-31
              desc: 1st imaginary component
          - y:
              type: s32
              units: 2^-31
              desc: 2nd imaginary component
          - z:
              type: s32
              units: 2^-31
              desc: 3rd imaginary component
          - cov_x_x:
              type: float
              units: rad^2
              desc: Estimated variance of the rotation error about the 1st axis of the covariance frame
          - cov_x_y:
              type: float
              units: rad^2
              desc: Estimated covariance of the rotation errors about the 1st and 2nd axes of the covariance frame
          - cov_x_z:
              type: float
              units: rad^2
              desc: Estimated covariance of the rotation errors about the 1st and 3rd axes of the covariance frame
          - cov_y_y:
              type: float
              units: rad^2
              desc: Estimated variance of the rotation error about the 2nd axis of the covariance frame
          - cov_y_z:
              type: float
              units: rad^2
              desc: Estimated covariance of the rotation errors about the 2nd and 3rd axes of the covariance frame
          - cov_z_z:
              type: float
              units: rad^2
              desc: Estimated variance of the rotation error about the 3rd axis of the covariance frame
          - flags:
              type: u8
              desc: Status flags
              fields:
                - 7-7:
                    desc: Reserved
                - 5-6:
                    desc: Covariance parameterization
                    values:
                        - 0: Small-angle rotation errors about the axes of the global frame given by the quaternion frame field
                        - 1: Small-angle rotation errors about the body/vehicle frame axes
                        - 2: Roll/pitch/yaw Euler-angle covariance (radians)
                        - 3: Reserved
                - 3-4:
                    desc: Quaternion reference frame
                    values:
                        - 0: Local-level NED
                        - 1: Local-level ENU
                        - 2: ECEF
                        - 3: Reserved
                - 0-2:
                    desc: INS Navigation mode
                    values:
                        - 0: Invalid
                        - 1: Valid
