Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
nps_sensor_gps.c
Go to the documentation of this file.
1#include "nps_sensor_gps.h"
2
3#include <stdio.h>
4#include "generated/airframe.h"
5#include "nps_fdm.h"
6#include "nps_random.h"
7#include "nps_sensors_utils.h"
8#include "nps_sensors.h"
9
31
32/*
33 * WARNING!
34 * noise and bias is currently added in ECEF frame
35 * If noise or bias is not the same for all axes this has to be done in LTP!!
36 *
37 */
38
39void nps_sensor_gps_run_step(struct NpsSensorGps *gps, double time)
40{
41 if (time < gps->next_update) {
42 return;
43 }
44
45 /*
46 * simulate speed sensor
47 */
50 /* add a gaussian noise */
52
53 /* store that for later and retrieve a previously stored data */
54 UpdateSensorLatency(time, &cur_speed_reading, &gps->speed_history, gps->speed_latency, &gps->ecef_vel);
55
56
57 /*
58 * simulate position sensor
59 */
60 /* compute gps error readings */
62 VECT3_COPY(pos_error, gps->pos_bias_initial);
63 /* add a gaussian noise */
64 double_vect3_add_gaussian_noise(&pos_error, &gps->pos_noise_std_dev);
65 /* update random walk bias and add it to error*/
66 double_vect3_update_random_walk(&gps->pos_bias_random_walk_value, &gps->pos_bias_random_walk_std_dev, NPS_GPS_DT, 5.);
67 VECT3_ADD(pos_error, gps->pos_bias_random_walk_value);
68
69 /* add error to current pos reading */
73
74 /* store that for later and retrieve a previously stored data */
75 UpdateSensorLatency(time, &cur_pos_reading, &gps->pos_history, gps->pos_latency, &gps->ecef_pos);
76
77
78 /*
79 * simulate lla pos
80 */
81 /* convert current ecef reading to lla */
84
85 /* store that for later and retrieve a previously stored data */
86 UpdateSensorLatency(time, &cur_lla_reading, &gps->lla_history, gps->pos_latency, &gps->lla_pos);
87
88 double cur_hmsl_reading = fdm.hmsl;
89 UpdateSensorLatency_Single(time, &cur_hmsl_reading, &gps->hmsl_history, gps->pos_latency, &gps->hmsl);
90
91 gps->next_update += NPS_GPS_DT;
92#ifndef NPS_NO_GPS
93 gps->data_available = TRUE;
94#endif
95}
96
struct GpsState gps
global GPS state
Definition gps.c:74
int32_t hmsl
height above mean sea level (MSL) in mm
Definition gps.h:94
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
Definition gps.h:92
struct EcefCoor_i ecef_pos
position in ECEF in cm
Definition gps.h:91
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
Definition gps.h:95
#define FLOAT_VECT3_ZERO(_v)
#define VECT3_ASSIGN(_a, _x, _y, _z)
#define VECT3_COPY(_a, _b)
#define VECT3_ADD(_a, _b)
void lla_of_ecef_d(struct LlaCoor_d *lla, struct EcefCoor_d *ecef)
vector in EarthCenteredEarthFixed coordinates
vector in Latitude, Longitude and Altitude
uint16_t foo
Definition main_demo5.c:58
double hmsl
Definition nps_fdm.h:56
struct EcefCoor_d ecef_pos
Definition nps_fdm.h:53
struct EcefCoor_d ecef_ecef_vel
velocity in ECEF frame, wrt ECEF frame
Definition nps_fdm.h:64
struct NpsFdm fdm
Holds all necessary NPS FDM state information.
void double_vect3_add_gaussian_noise(struct DoubleVect3 *vect, struct DoubleVect3 *std_dev)
Definition nps_random.c:34
void double_vect3_update_random_walk(struct DoubleVect3 *rw, struct DoubleVect3 *std_dev, double dt, double thau)
Definition nps_random.c:65
void nps_sensor_gps_init(struct NpsSensorGps *gps, double time)
void nps_sensor_gps_run_step(struct NpsSensorGps *gps, double time)
void UpdateSensorLatency(double time, gpointer cur_reading, GSList **history, double latency, gpointer sensor_reading)
void UpdateSensorLatency_Single(double time, gpointer cur_reading, GSList **history, double latency, gpointer sensor_reading)
#define TRUE
Definition std.h:4
#define FALSE
Definition std.h:5