Skip to content

Commit

Permalink
Merge pull request #28 from amilcarlucas/pr-always-send-accuracy-info…
Browse files Browse the repository at this point in the history
…rmation

Always deliver horizontal and vertical accuracy if position is known
  • Loading branch information
egorf authored Jul 12, 2017
2 parents 65fb56e + ba5a7d9 commit f86e78d
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/erb.c
Original file line number Diff line number Diff line change
Expand Up @@ -127,22 +127,22 @@ static void buildver(char *payload, struct erb_ver version, const uint32_t time,
static void buildpos(char *payload, struct erb_pos position, const uint32_t time,
const sol_t *sol)
{
float stdX,stdY,stdZ;
float stdX2,stdY2,stdZ2;
double pos[3];

ecef2pos(sol->rr, pos);
/* if fix or float, then get std X/Y/Z */
stdX = (sol->stat == SOLQ_FIX || sol->stat == SOLQ_FLOAT) ? SQRT(sol->qr[0]) : 0;
stdY = (sol->stat == SOLQ_FIX || sol->stat == SOLQ_FLOAT) ? SQRT(sol->qr[1]) : 0;
stdZ = (sol->stat == SOLQ_FIX || sol->stat == SOLQ_FLOAT) ? SQRT(sol->qr[2]) : 0;
/* if position available, then get std^2 X/Y/Z */
stdX2 = (sol->stat != SOLQ_NONE && sol->stat != SOLQ_DR && sol->qr[0] > 0) ? sol->qr[0] : 0;
stdY2 = (sol->stat != SOLQ_NONE && sol->stat != SOLQ_DR && sol->qr[1] > 0) ? sol->qr[1] : 0;
stdZ2 = (sol->stat != SOLQ_NONE && sol->stat != SOLQ_DR && sol->qr[2] > 0) ? sol->qr[2] : 0;

position.timeGPS = time;
position.lng = pos[1] * R2D;
position.lat = pos[0] * R2D;
position.altEl = pos[2];
position.altMsl = pos[2] - geoidh(pos);
position.accHor = 1000 * SQRT(stdX * stdX + stdY * stdY);
position.accVer = 1000 * stdZ;
position.accHor = 1000 * SQRT(stdX2 + stdY2); /* convert float [m] to int32 [mm] */
position.accVer = 1000 * SQRT(stdZ2); /* convert float [m] to int32 [mm] */

memcpy(payload, &position, LENGTH_POS);
}
Expand Down

0 comments on commit f86e78d

Please sign in to comment.