sbp_utils.c
Go to the documentation of this file.
00001 /*
00002  * Copyright (C) 2014 Swift Navigation Inc.
00003  * Contact: Fergus Noble <fergus@swift-nav.com>
00004  *
00005  * This source is subject to the license found in the file 'LICENSE' which must
00006  * be be distributed together with this source. All other rights reserved.
00007  *
00008  * THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND,
00009  * EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
00010  * WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
00011  */
00012 
00013 #include <math.h>
00014 
00015 #include "constants.h"
00016 #include "sbp_utils.h"
00017 
00025 void sbp_make_gps_time(sbp_gps_time_t *t_out, gps_time_t *t_in, u8 flags)
00026 {
00027   t_out->wn = t_in->wn;
00028   t_out->tow = round(t_in->tow * 1e3);
00029   t_out->ns = round((t_in->tow - t_out->tow*1e-3) * 1e9);
00030   t_out->flags = flags;
00031 }
00032 
00033 void sbp_make_pos_llh(sbp_pos_llh_t *pos_llh, gnss_solution *soln, u8 flags)
00034 {
00035   pos_llh->tow = round(soln->time.tow * 1e3);
00036   pos_llh->lat = soln->pos_llh[0] * R2D;
00037   pos_llh->lon = soln->pos_llh[1] * R2D;
00038   pos_llh->height = soln->pos_llh[2];
00039   /* TODO: fill in accuracy fields. */
00040   pos_llh->h_accuracy = 0;
00041   pos_llh->v_accuracy = 0;
00042   pos_llh->n_sats = soln->n_used;
00043   pos_llh->flags = flags;
00044 }
00045 
00046 void sbp_make_pos_ecef(sbp_pos_ecef_t *pos_ecef, gnss_solution *soln, u8 flags)
00047 {
00048   pos_ecef->tow = round(soln->time.tow * 1e3);
00049   pos_ecef->x = soln->pos_ecef[0];
00050   pos_ecef->y = soln->pos_ecef[1];
00051   pos_ecef->z = soln->pos_ecef[2];
00052   /* TODO: fill in accuracy field. */
00053   pos_ecef->accuracy = 0;
00054   pos_ecef->n_sats = soln->n_used;
00055   pos_ecef->flags = flags;
00056 }
00057 
00058 void sbp_make_vel_ned(sbp_vel_ned_t *vel_ned, gnss_solution *soln, u8 flags)
00059 {
00060   vel_ned->tow = round(soln->time.tow * 1e3);
00061   vel_ned->n = round(soln->vel_ned[0] * 1e3);
00062   vel_ned->e = round(soln->vel_ned[1] * 1e3);
00063   vel_ned->d = round(soln->vel_ned[2] * 1e3);
00064   /* TODO: fill in accuracy fields. */
00065   vel_ned->h_accuracy = 0;
00066   vel_ned->v_accuracy = 0;
00067   vel_ned->n_sats = soln->n_used;
00068   vel_ned->flags = flags;
00069 }
00070 
00071 void sbp_make_vel_ecef(sbp_vel_ecef_t *vel_ecef, gnss_solution *soln, u8 flags)
00072 {
00073   vel_ecef->tow = round(soln->time.tow * 1e3);
00074   vel_ecef->x = round(soln->vel_ecef[0] * 1e3);
00075   vel_ecef->y = round(soln->vel_ecef[1] * 1e3);
00076   vel_ecef->z = round(soln->vel_ecef[2] * 1e3);
00077   /* TODO: fill in accuracy field. */
00078   vel_ecef->accuracy = 0;
00079   vel_ecef->n_sats = soln->n_used;
00080   vel_ecef->flags = flags;
00081 }
00082 
00083 void sbp_make_dops(sbp_dops_t *dops_out, dops_t *dops_in)
00084 {
00085   dops_out->pdop = round(dops_in->pdop * 100);
00086   dops_out->gdop = round(dops_in->gdop * 100);
00087   dops_out->tdop = round(dops_in->tdop * 100);
00088   dops_out->hdop = round(dops_in->hdop * 100);
00089   dops_out->vdop = round(dops_in->vdop * 100);
00090 }
00091 
00092 void sbp_make_baseline_ecef(sbp_baseline_ecef_t *baseline_ecef, gps_time_t *t,
00093                             u8 n_sats, double b_ecef[3], u8 flags) {
00094   baseline_ecef->tow = round(t->tow * 1e3);
00095   baseline_ecef->x = round(1e3 * b_ecef[0]);
00096   baseline_ecef->y = round(1e3 * b_ecef[1]);
00097   baseline_ecef->z = round(1e3 * b_ecef[2]);
00098   baseline_ecef->accuracy = 0;
00099   baseline_ecef->n_sats = n_sats;
00100   baseline_ecef->flags = flags;
00101 }
00102 
00103 void sbp_make_baseline_ned(sbp_baseline_ned_t *baseline_ned, gps_time_t *t,
00104                            u8 n_sats, double b_ned[3], u8 flags) {
00105   baseline_ned->tow = round(t->tow * 1e3);
00106   baseline_ned->n = round(1e3 * b_ned[0]);
00107   baseline_ned->e = round(1e3 * b_ned[1]);
00108   baseline_ned->d = round(1e3 * b_ned[2]);
00109   baseline_ned->h_accuracy = 0;
00110   baseline_ned->v_accuracy = 0;
00111   baseline_ned->n_sats = n_sats;
00112   baseline_ned->flags = flags;
00113 }
00114 


swiftnav
Author(s):
autogenerated on Sat Jun 8 2019 18:55:58