Skip to content

Commit

Permalink
Cast M10SPG altitude to float
Browse files Browse the repository at this point in the history
  • Loading branch information
AngusJull committed Jun 2, 2024
1 parent ea14a47 commit 2f855fc
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/collectors/m10spg_clctr.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ typedef struct {
int32_t I32; /**< The message payload, interpreted as a int32_t */
uint8_t U8; /**< The message payload, interpreted as a uint8_t */
vec2d_t VEC2D; /**< The message payload, interpreted as a vec2d_t */
float FLOAT; /**< The message payload, interpreted as a float */
};
} __attribute__((packed)) message_t;

Expand Down Expand Up @@ -76,7 +77,7 @@ void *m10spg_collector(void *args) {
fprintf(stderr, "M10SPG couldn't send message: %s.\n", strerror(errno));
}
msg.type = TAG_ALTITUDE_SEA;
msg.I32 = buf.pos.hMSL;
msg.FLOAT = ((float)buf.pos.hMSL / ALT_SCALE_TO_METERS);
if (mq_send(sensor_q, (char *)&msg, sizeof(msg), 0) == -1) {
fprintf(stderr, "M10SPG couldn't send message: %s.\n", strerror(errno));
}
Expand Down
11 changes: 8 additions & 3 deletions src/drivers/m10spg/ubx_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,14 @@ typedef struct {
uint32_t vAcc; /**< Vertical accuracy measurement in millimeters */
} UBXNavPositionPayload;

/** A conversion constant to go from the scale of the UBX lat/lon (1E-7deg) to regular degrees */
#define LAT_SCALE_TO_DEGREES 10000000
#define LON_SCALE_TO_DEGREES 10000000
/** A conversion constant to go from the scale of UBX latitude (1E-7deg) to regular degrees */
#define LAT_SCALE_TO_DEGREES 1e7f

/** A conversion constant to go from the scale of UBX longitude (1E-7deg) to regular degrees */
#define LON_SCALE_TO_DEGREES 1e7f

/** A conversion constant to go from the scale of UBX altitude (mm) to meters */
#define ALT_SCALE_TO_METERS 1e3f

/** A struct representing the UBX-NAV-VELNED (velocity) payload */
typedef struct {
Expand Down

0 comments on commit 2f855fc

Please sign in to comment.