Paparazzi UAS  v4.2.2_stable-4-gcc32f65
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
jsbsim_gps.c
Go to the documentation of this file.
1 /* OCaml binding to link the simulator to autopilot functions. */
2 
3 #include <assert.h>
4 #include <math.h>
5 #include <inttypes.h>
6 
8 #include "generated/airframe.h"
9 #include "generated/flight_plan.h"
10 #include "autopilot.h"
11 #include "subsystems/gps.h"
12 #include "estimator.h"
14 #include "math/pprz_geodetic_int.h"
15 
16 // currently needed to get nav_utm_zone0
18 
19 
20 void sim_use_gps_pos(double lat, double lon, double alt, double course, double gspeed, double climb, double time) {
21 
22  gps.fix = 3; // Mode 3D
23  gps.course = course * 1e7;
24  gps.hmsl = alt * 1000.;
25  gps.gspeed = gspeed * 100.;
26  gps.ned_vel.z = -climb * 100.;
27  gps.week = 0; // FIXME
28  gps.tow = time * 1000.;
29 
30  //TODO set alt above ellipsoid and hmsl
31 
32  struct LlaCoor_f lla_f;
33  struct UtmCoor_f utm_f;
34  lla_f.lat = lat;
35  lla_f.lon = lon;
36  utm_f.zone = nav_utm_zone0;
37  utm_of_lla_f(&utm_f, &lla_f);
38  LLA_BFP_OF_REAL(gps.lla_pos, lla_f);
39  gps.utm_pos.east = utm_f.east*100;
40  gps.utm_pos.north = utm_f.north*100;
42 
44 
45 }
46 
48 void sim_update_sv(void) {
49 
50  gps.nb_channels=7;
51  int i;
52  static int time;
53  time++;
54  for(i = 0; i < gps.nb_channels; i++) {
55  gps.svinfos[i].svid = 7 + i;
56  gps.svinfos[i].elev = (cos(((100*i)+time)/100.) + 1) * 45;
57  gps.svinfos[i].azim = (time/gps.nb_channels + 50 * i) % 360;
58  gps.svinfos[i].cno = 40 + sin((time+i*10)/100.) * 10.;
59  gps.svinfos[i].flags = ((time/10) % (i+1) == 0 ? 0x00 : 0x01);
60  gps.svinfos[i].qi = (int)((time / 1000.) + i) % 8;
61  }
62  gps.pdop = gps.sacc = gps.pacc = 500+200*sin(time/100.);
63  gps.num_sv = 7;
64 
65 }
66 
67 void ubxsend_cfg_rst(uint16_t a __attribute__ ((unused)), uint8_t b __attribute__ ((unused))) {
68  return;
69 }
70 
unsigned short uint16_t
Definition: types.h:16
void sim_update_sv(void)
Space vehicle info simulation.
Definition: jsbsim_gps.c:48
struct LlaCoor_i lla_pos
position in LLA (lat,lon: rad*1e7; alt: mm over ellipsoid)
Definition: gps.h:64
struct NedCoor_i ned_vel
speed NED in cm/s
Definition: gps.h:68
int32_t course
GPS heading in rad*1e7 (CW/north)
Definition: gps.h:71
uint32_t sacc
speed accuracy in cm/s
Definition: gps.h:73
uint8_t zone
UTM zone number.
void ubxsend_cfg_rst(uint16_t a __attribute__((unused)), uint8_t b __attribute__((unused)))
Definition: jsbsim_gps.c:67
uint16_t pdop
position dilution of precision scaled by 100
Definition: gps.h:75
uint8_t nav_utm_zone0
Definition: common_nav.c:43
int32_t hmsl
height above mean sea level in mm
Definition: gps.h:66
float lat
in radians
uint8_t fix
status of fix
Definition: gps.h:77
int16_t week
GPS week.
Definition: gps.h:78
uint8_t qi
quality bitfield (GPS receiver specific)
Definition: gps.h:55
vector in Latitude, Longitude and Altitude
Paparazzi floating point math for geodetic calculations.
uint32_t tow
GPS time of week in ms.
Definition: gps.h:79
int16_t azim
azimuth in deg
Definition: gps.h:58
uint8_t zone
UTM zone number.
int16_t gspeed
norm of 2d ground speed in cm/s
Definition: gps.h:69
void sim_use_gps_pos(double lat, double lon, double alt, double course, double gspeed, double climb, double time)
From airborne/autopilot/.
Definition: jsbsim_gps.c:20
float north
in meters
Device independent GPS code (interface)
position in UTM coordinates Units: meters
#define LLA_BFP_OF_REAL(_o, _i)
Paparazzi fixed point math for geodetic calculations.
int32_t north
in centimeters
bool_t gps_available
Definition: gps_sim.c:24
struct SVinfo svinfos[GPS_NB_CHANNELS]
holds information from the Space Vehicles (Satellites)
Definition: gps.h:82
#define TRUE
Definition: imu_chimu.h:144
int32_t east
in centimeters
uint32_t pacc
position accuracy in cm
Definition: gps.h:72
uint8_t flags
bitfield with GPS receiver specific flags
Definition: gps.h:54
unsigned char uint8_t
Definition: types.h:14
int8_t elev
elevation in deg
Definition: gps.h:57
uint8_t svid
Satellite ID.
Definition: gps.h:53
State estimation, fusioning sensors.
struct UtmCoor_i utm_pos
position in UTM (north,east: cm; alt: mm over ellipsoid)
Definition: gps.h:65
float lon
in radians
float east
in meters
__attribute__((always_inline))
Definition: i2c_arch.c:35
struct GpsState gps
global GPS state
Definition: gps.c:31
uint8_t cno
Carrier to Noise Ratio (Signal Strength) in dbHz.
Definition: gps.h:56
void utm_of_lla_f(struct UtmCoor_f *utm, struct LlaCoor_f *lla)
uint8_t nb_channels
Number of scanned satellites.
Definition: gps.h:81
uint8_t num_sv
number of sat in fix
Definition: gps.h:76