#ifndef SBGLOGPARSE_H
#define SBGLOGPARSE_H
#include "sbgbuffer.h"
namespace sbgtc
{
//----------------------------------------------------------------------//
//- Definition of all class id for sbgECom -//
//----------------------------------------------------------------------//
/*!
* Enum that defines all the message classes available.
*/
typedef enum _SbgEComClass
{
SBG_ECOM_CLASS_LOG_ECOM_0 = 0x00, /*!< Class that contains sbgECom protocol input/output log messages. */
SBG_ECOM_CLASS_LOG_ECOM_1 = 0x01, /*!< Class that contains special sbgECom output messages that handle high frequency output. */
SBG_ECOM_CLASS_LOG_NMEA_0 = 0x02, /*!< Class that contains NMEA (and NMEA like) output logs.
Note: This class is only used for identification purpose and does not contain any sbgECom message. */
SBG_ECOM_CLASS_LOG_NMEA_1 = 0x03, /*!< Class that contains proprietary NMEA (and NMEA like) output logs.
Note: This class is only used for identification purpose and does not contain any sbgECom message. */
SBG_ECOM_CLASS_LOG_THIRD_PARTY_0 = 0x04, /*!< Class that contains third party output logs.
Note: This class is only used for identification purpose and does not contain any sbgECom message. */
SBG_ECOM_CLASS_LOG_CMD_0 = 0x10, /*!< Class that contains sbgECom protocol commands. */
SBG_ECOM_CLASS_LOG_ECOM_PRIVATE = 0xFE, /*!< Private output logs - internal use only */
SBG_ECOM_CLASS_CMD_PRIVATE = 0xFF /*!< Private commands - internal use only */
} SbgEComClass;
//----------------------------------------------------------------------//
//- Definition of all messages id for sbgECom -//
//----------------------------------------------------------------------//
/*!
* Enum that defines all the available ECom output logs from the sbgECom library.
*/
typedef enum _SbgEComLog
{
SBG_ECOM_LOG_STATUS = 1, /*!< Status general, clock, com aiding, solution, heave */
SBG_ECOM_LOG_UTC_TIME = 2, /*!< Provides UTC time reference */
SBG_ECOM_LOG_IMU_DATA = 3, /*!< Includes IMU status, acc., gyro, temp delta speeds and delta angles values */
SBG_ECOM_LOG_MAG = 4, /*!< Magnetic data with associated accelerometer on each axis */
SBG_ECOM_LOG_MAG_CALIB = 5, /*!< Magnetometer calibration data (raw buffer) */
SBG_ECOM_LOG_EKF_EULER = 6, /*!< Includes roll, pitch, yaw and their accuracies on each axis */
SBG_ECOM_LOG_EKF_QUAT = 7, /*!< Includes the 4 quaternions values */
SBG_ECOM_LOG_EKF_NAV = 8, /*!< Position and velocities in NED coordinates with the accuracies on each axis */
SBG_ECOM_LOG_SHIP_MOTION = 9, /*!< Heave, surge and sway and accelerations on each axis. */
SBG_ECOM_LOG_GPS1_VEL = 13, /*!< GPS velocities from primary or secondary GPS receiver */
SBG_ECOM_LOG_GPS1_POS = 14, /*!< GPS positions from primary or secondary GPS receiver */
SBG_ECOM_LOG_GPS1_HDT = 15, /*!< GPS true heading from dual antenna system */
SBG_ECOM_LOG_GPS1_RAW = 31, /*!< GPS 1 raw data for post processing. */
SBG_ECOM_LOG_GPS2_VEL = 16, /*!< GPS 2 velocity log data. */
SBG_ECOM_LOG_GPS2_POS = 17, /*!< GPS 2 position log data. */
SBG_ECOM_LOG_GPS2_HDT = 18, /*!< GPS 2 true heading log data. */
SBG_ECOM_LOG_GPS2_RAW = 38, /*!< GPS 2 raw data for post processing. */
SBG_ECOM_LOG_ODO_VEL = 19, /*!< Provides odometer velocity */
SBG_ECOM_LOG_EVENT_A = 24, /*!< Event markers sent when events are detected on sync in A pin */
SBG_ECOM_LOG_EVENT_B = 25, /*!< Event markers sent when events are detected on sync in B pin */
SBG_ECOM_LOG_EVENT_C = 26, /*!< Event markers sent when events are detected on sync in C pin */
SBG_ECOM_LOG_EVENT_D = 27, /*!< Event markers sent when events are detected on sync in D pin */
SBG_ECOM_LOG_EVENT_E = 28, /*!< Event markers sent when events are detected on sync in E pin */
SBG_ECOM_LOG_DVL_BOTTOM_TRACK = 29, /*!< Doppler Velocity Log for bottom tracking data. */
SBG_ECOM_LOG_DVL_WATER_TRACK = 30, /*!< Doppler Velocity log for water layer data. */
SBG_ECOM_LOG_SHIP_MOTION_HP = 32, /*!< Return delayed ship motion such as surge, sway, heave. */
SBG_ECOM_LOG_AIR_DATA = 36, /*!< Air Data aiding such as barometric altimeter and true air speed. */
SBG_ECOM_LOG_USBL = 37, /*!< Raw USBL position data for subsea navigation. */
SBG_ECOM_LOG_IMU_RAW_DATA = 40, /*!< DEPRECATED: Private only log. */
SBG_ECOM_LOG_IMU_SHORT = 44, /*!< Short IMU message recommended for post processing usages. */
SBG_ECOM_LOG_EVENT_OUT_A = 45, /*!< Event marker used to time stamp each generated Sync Out A signal. */
SBG_ECOM_LOG_EVENT_OUT_B = 46, /*!< Event marker used to time stamp each generated Sync Out B signal. */
SBG_ECOM_LOG_DEPTH = 47, /*!< Depth sensor measurement log used for subsea navigation. */
SBG_ECOM_LOG_DIAG = 48, /*!< Diagnostic log. */
SBG_ECOM_LOG_ECOM_NUM_MESSAGES /*!< Helper definition to know the number of ECom messages */
} SbgEComLog;
/*!
* This type defines any message identifier.
* Because message identifiers enum will be different with each class id, we use a generic uint8_t rather than an enum.
*/
typedef uint8_t SbgEComMsgId;
//--------------------------------------------------------------------------------------------------------------------------------------------------------------
/*!
* Solution filter mode enum.
*/
typedef enum _SbgEComSolutionMode
{
SBG_ECOM_SOL_MODE_UNINITIALIZED = 0, /*!< The Kalman filter is not initialized and the returned data are all invalid. */
SBG_ECOM_SOL_MODE_VERTICAL_GYRO = 1, /*!< The Kalman filter only rely on a vertical reference to compute roll and pitch angles. Heading and navigation data drift freely. */
SBG_ECOM_SOL_MODE_AHRS = 2, /*!< A heading reference is available, the Kalman filter provides full orientation but navigation data drift freely. */
SBG_ECOM_SOL_MODE_NAV_VELOCITY = 3, /*!< The Kalman filter computes orientation and velocity. Position is freely integrated from velocity estimation. */
SBG_ECOM_SOL_MODE_NAV_POSITION = 4 /*!< Nominal mode, the Kalman filter computes all parameters (attitude, velocity, position). Absolute position is provided. */
} SbgEComSolutionMode;
/*!
* EKF computed orientation using euler angles.
*/
typedef struct _SbgLogEkfEulerData
{
uint32_t timeStamp; /*!< Time in us since the sensor power up. */
float euler[3]; /*!< Roll, Pitch and Yaw angles in rad. */
float eulerStdDev[3]; /*!< Roll, Pitch and Yaw angles 1 sigma standard deviation in rad. */
uint32_t status; /*!< EKF solution status bitmask and enum. */
} SbgLogEkfEulerData;
/*!
* EFK computed orientation using quaternion.
*/
typedef struct _SbgLogEkfQuatData
{
uint32_t timeStamp; /*!< Time in us since the sensor power up. */
float quaternion[4]; /*!< Orientation quaternion stored in W, X, Y, Z form. */
float eulerStdDev[3]; /*!< Roll, Pitch and Yaw angles 1 sigma standard deviation in rad. */
uint32_t status; /*!< EKF solution status bitmask and enum. */
} SbgLogEkfQuatData;
/*!
* EFK computed navigation data.
*/
typedef struct _SbgLogEkfNavData
{
uint32_t timeStamp; /*!< Time in us since the sensor power up. */
float velocity[3]; /*!< North, East, Down velocity in m.s^-1. */
float velocityStdDev[3]; /*!< North, East, Down velocity 1 sigma standard deviation in m.s^-1. */
double position[3]; /*!< Latitude, Longitude in degrees positive North and East.
Altitude above Mean Sea Level in meters. */
float undulation; /*!< Altitude difference between the geoid and the Ellipsoid in meters (Height above Ellipsoid = altitude + undulation). */
float positionStdDev[3]; /*!< Latitude, longitude and altitude 1 sigma standard deviation in meters. */
uint32_t status; /*!< EKF solution status bitmask and enum. */
} SbgLogEkfNavData;
/*!
* Structure that stores data for the SBG_ECOM_LOG_UTC_TIME message.
*/
typedef struct _SbgLogUtcData
{
uint32_t timeStamp; /*!< Time in us since the sensor power up. */
uint16_t status; /*!< UTC time and clock status information */
uint16_t year; /*!< Year for example: 2013. */
int8_t month; /*!< Month in year [1 .. 12]. */
int8_t day; /*!< Day in month [1 .. 31]. */
int8_t hour; /*!< Hour in day [0 .. 23]. */
int8_t minute; /*!< Minute in hour [0 .. 59]. */
int8_t second; /*!< Second in minute [0 .. 60]. (60 is used only when a leap second is added) */
int32_t nanoSecond; /*!< Nanosecond of current second in ns. */
uint32_t gpsTimeOfWeek; /*!< GPS time of week in ms. */
} SbgLogUtcData;
/*!
* Structure that stores data for the SBG_ECOM_LOG_GPS#_POS message.
*/
typedef struct _SbgLogGpsPos
{
uint32_t timeStamp; /*!< Time in us since the sensor power up. */
uint32_t status; /*!< GPS position status, type and bitmask. */
uint32_t timeOfWeek; /*!< GPS time of week in ms. */
double latitude; /*!< Latitude in degrees, positive north. */
double longitude; /*!< Longitude in degrees, positive east. */
double altitude; /*!< Altitude above Mean Sea Level in meters. */
float undulation; /*!< Altitude difference between the geoid and the Ellipsoid in meters (Height above Ellipsoid = altitude + undulation). */
float latitudeAccuracy; /*!< 1 sigma latitude accuracy in meters. */
float longitudeAccuracy; /*!< 1 sigma longitude accuracy in meters. */
float altitudeAccuracy; /*!< 1 sigma altitude accuracy in meters. */
uint8_t numSvUsed; /*!< Number of space vehicles used to compute the solution (since version 1.4). */
uint16_t baseStationId; /*!< Base station id for differential corrections (0-4095). Set to 0xFFFF if differential corrections are not used (since version 1.4). */
uint16_t differentialAge; /*!< Differential correction age in 0.01 seconds. Set to 0XFFFF if differential corrections are not used (since version 1.4). */
} SbgLogGpsPos;
typedef union _SbgBinaryLogData
{
// SbgLogStatusData statusData; /*!< Stores data for the SBG_ECOM_LOG_STATUS message. */
// SbgLogImuData imuData; /*!< Stores data for the SBG_ECOM_LOG_IMU_DATA message. */
// SbgLogImuShort imuShort; /*!< Stores data for the SBG_ECOM_LOG_IMU_SHORT message. */
SbgLogEkfEulerData ekfEulerData; /*!< Stores data for the SBG_ECOM_LOG_EKF_EULER message. */
SbgLogEkfQuatData ekfQuatData; /*!< Stores data for the SBG_ECOM_LOG_EKF_QUAT message. */
SbgLogEkfNavData ekfNavData; /*!< Stores data for the SBG_ECOM_LOG_EKF_NAV message. */
// SbgLogShipMotionData shipMotionData; /*!< Stores data for the SBG_ECOM_LOG_SHIP_MOTION or SBG_ECOM_LOG_SHIP_MOTION_HP message. */
// SbgLogOdometerData odometerData; /*!< Stores data for the SBG_ECOM_LOG_ODO_VEL message. */
SbgLogUtcData utcData; /*!< Stores data for the SBG_ECOM_LOG_UTC_TIME message. */
SbgLogGpsPos gpsPosData; /*!< Stores data for the SBG_ECOM_LOG_GPS_POS message. */
// SbgLogGpsVel gpsVelData; /*!< Stores data for the SBG_ECOM_LOG_GPS#_VEL message. */
// SbgLogGpsHdt gpsHdtData; /*!< Stores data for the SBG_ECOM_LOG_GPS#_HDT message. */
// SbgLogGpsRaw gpsRawData; /*!< Stores data for the SBG_ECOM_LOG_GPS#_RAW message. */
// SbgLogMag magData; /*!< Stores data for the SBG_ECOM_LOG_MAG message. */
// SbgLogMagCalib magCalibData; /*!< Stores data for the SBG_ECOM_LOG_MAG_CALIB message. */
// SbgLogDvlData dvlData; /*!< Stores data for the SBG_ECOM_LOG_DVL_BOTTOM_TRACK message. */
// SbgLogAirData airData; /*!< Stores data for the SBG_ECOM_LOG_AIR_DATA message. */
// SbgLogUsblData usblData; /*!< Stores data for the SBG_ECOM_LOG_USBL message. */
// SbgLogDepth depthData; /*!< Stores data for the SBG_ECOM_LOG_DEPTH message */
// SbgLogEvent eventMarker; /*!< Stores data for the SBG_ECOM_LOG_EVENT_# message. */
// SbgLogDiagData diagData; /*!< Stores data for the SBG_ECOM_LOG_DIAG message. */
// /* Fast logs */
// SbgLogFastImuData fastImuData; /*!< Stores Fast Imu Data for 1KHz output */
} SbgBinaryLogData;
SbgErrorCode sbgEComBinaryLogParseEkfEulerData(SbgStreamBuffer *pInputStream, SbgLogEkfEulerData *pOutputData);
SbgErrorCode sbgEComBinaryLogParseUtcData(SbgStreamBuffer *pInputStream, SbgLogUtcData *pOutputData);
SbgErrorCode sbgEComBinaryLogParseGpsPosData(SbgStreamBuffer *pInputStream, SbgLogGpsPos *pOutputData);
}
#endif // SBGLOGPARSE_H