schwehr / generic-sensor-format

Sonar Generic Sensor Format (gsf) codec
Other
13 stars 8 forks source link

Attitude table (4-14) mixes in memory and disk formats #75

Open schwehr opened 9 years ago

schwehr commented 9 years ago

This table is misleading:

Field Name Description Field Type Count
BASE_TIME Full time of the first attitude measurement I 2*4
NUM_MEASUREMENTS Number of attitude measurements in this record (N). I 2
ATTITUDE_TIME Array of attitude measurement times, offset from the base time I N*2
PITCH Array of pitch measurements I N*2
ROLL Array of roll measurements I N*2
HEAVE Array of heave measurements I N*2
HEADING Array of heading measurements U N*2
**Table 4-14** Attitude Record Definition.

Field Name | Description | Field Type | Count
-----------|-------------|------------|------
BASE_TIME | Full time of the first attitude measurement | I | 2*4
NUM_MEASUREMENTS | Number of attitude measurements in this record (N). | I | 2
ATTITUDE_TIME | Array of attitude measurement times, offset from the base time | I | N*2
PITCH | Array of pitch measurements | I | N*2
ROLL | Array of roll measurements | I | N*2
HEAVE | Array of heave measurements | I | N*2
HEADING | Array of heading measurements | U | N*2

gsf.h:

typedef struct t_gsfAttitude
{
    short            num_measurements;      /* Number of attitude measurements in this record. */
    struct timespec *attitude_time;         /* Seconds and nanoseconds. */
    double          *pitch;                 /* Degrees. ‐180.00 to +180.00. */
    double          *roll;                  /* Degrees. ‐180.00 to +180.00. */
    double          *heave;                 /* Meters. */
    /* Stored as uint16 in the file. */
    double          *heading;               /* Degrees. 0.00 to 360.00. */
}
gsfAttitude;

gsf_dec.c:

    /* Now loop to decode the attitude measurements. */
    for (i = 0; i < attitude->num_measurements; i++)
    {
        /* Next two byte integer contains the time offset. */
        memcpy(&stemp, p, 2);
        time_offset = ((double) ntohs (stemp)) / 1000.0;
        p += 2;

        LocalAddTimes (&basetime, time_offset, &attitude->attitude_time[i]);

        /* Next two byte integer contains the pitch. */
        memcpy(&stemp, p, 2);
        signed_short = (signed) ntohs(stemp);
        attitude->pitch[i] = ((double) signed_short) / 100.0;
        p += 2;