Paparazzi UAS  v5.0.5_stable-7-g4b8bbb7
Paparazzi is a free software Unmanned Aircraft System.
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules 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"
13 #include "math/pprz_geodetic_int.h"
14 
15 // currently needed to get nav_utm_zone0
17 
18 
19 void sim_use_gps_pos(double lat, double lon, double alt, double course, double gspeed, double climb, double time) {
20 
21  gps.fix = 3; // Mode 3D
22  gps.course = course * 1e7;
23  gps.hmsl = alt * 1000.;
24  gps.gspeed = gspeed * 100.;
25  gps.ned_vel.z = -climb * 100.;
26  gps.week = 0; // FIXME
27  gps.tow = time * 1000.;
28 
29  //TODO set alt above ellipsoid and hmsl
30 
31  struct LlaCoor_f lla_f;
32  struct UtmCoor_f utm_f;
33  lla_f.lat = lat;
34  lla_f.lon = lon;
35  utm_f.zone = nav_utm_zone0;
36  utm_of_lla_f(&utm_f, &lla_f);
37  LLA_BFP_OF_REAL(gps.lla_pos, lla_f);
38  gps.utm_pos.east = utm_f.east*100;
39  gps.utm_pos.north = utm_f.north*100;
41 
43 
44 }
45 
47 void sim_update_sv(void) {
48 
49  gps.nb_channels=7;
50  int i;
51  static int time;
52  time++;
53  for(i = 0; i < gps.nb_channels; i++) {
54  gps.svinfos[i].svid = 7 + i;
55  gps.svinfos[i].elev = (cos(((100*i)+time)/100.) + 1) * 45;
56  gps.svinfos[i].azim = (time/gps.nb_channels + 50 * i) % 360;
57  gps.svinfos[i].cno = 40 + sin((time+i*10)/100.) * 10.;
58  gps.svinfos[i].flags = ((time/10) % (i+1) == 0 ? 0x00 : 0x01);
59  gps.svinfos[i].qi = (int)((time / 1000.) + i) % 8;
60  }
61  gps.pdop = gps.sacc = gps.pacc = 500+200*sin(time/100.);
62  gps.num_sv = 7;
63 
64 }
65 
66 void ubxsend_cfg_rst(uint16_t a __attribute__ ((unused)), uint8_t b __attribute__ ((unused))) {
67  return;
68 }
69 
unsigned short uint16_t
Definition: types.h:16
void sim_update_sv(void)
Space vehicle info simulation.
Definition: jsbsim_gps.c:47
struct LlaCoor_i lla_pos
position in LLA (lat,lon: rad*1e7; alt: mm over ellipsoid)
Definition: gps.h:65
struct NedCoor_i ned_vel
speed NED in cm/s
Definition: gps.h:69
void ubxsend_cfg_rst(uint16_t a, uint8_t b)
Definition: jsbsim_gps.c:66
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
Definition: gps.h:72
uint32_t sacc
speed accuracy in cm/s
Definition: gps.h:74
uint8_t zone
UTM zone number.
uint16_t pdop
position dilution of precision scaled by 100
Definition: gps.h:76
uint8_t nav_utm_zone0
Definition: common_nav.c:44
int32_t hmsl
height above mean sea level in mm
Definition: gps.h:67
float lat
in radians
uint8_t fix
status of fix
Definition: gps.h:78
int16_t week
GPS week.
Definition: gps.h:79
uint8_t qi
quality bitfield (GPS receiver specific)
Definition: gps.h:56
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:80
int32_t z
Down.
int16_t azim
azimuth in deg
Definition: gps.h:59
uint8_t zone
UTM zone number.
int16_t gspeed
norm of 2d ground speed in cm/s
Definition: gps.h:70
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:19
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:83
#define TRUE
Definition: imu_chimu.h:144
int32_t east
in centimeters
uint32_t pacc
position accuracy in cm
Definition: gps.h:73
uint8_t flags
bitfield with GPS receiver specific flags
Definition: gps.h:55
unsigned char uint8_t
Definition: types.h:14
int8_t elev
elevation in deg
Definition: gps.h:58
uint8_t svid
Satellite ID.
Definition: gps.h:54
struct UtmCoor_i utm_pos
position in UTM (north,east: cm; alt: mm over ellipsoid)
Definition: gps.h:66
float lon
in radians
float east
in meters
struct GpsState gps
global GPS state
Definition: gps.c:33
uint8_t cno
Carrier to Noise Ratio (Signal Strength) in dbHz.
Definition: gps.h:57
void utm_of_lla_f(struct UtmCoor_f *utm, struct LlaCoor_f *lla)
uint8_t nb_channels
Number of scanned satellites.
Definition: gps.h:82
uint8_t num_sv
number of sat in fix
Definition: gps.h:77