Paparazzi UAS  v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
gps_intermcu.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2022 Gautier Hattenberger <gautier.hattenberger@enac.fr>
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
27 #include "modules/core/abi.h"
28 #include "pprzlink/intermcu_msg.h"
29 
30 struct GpsState gps_imcu;
31 
34 {
36  gps_imcu.pdop = 0;
37  gps_imcu.sacc = 0;
38  gps_imcu.pacc = 0;
39  gps_imcu.cacc = 0;
41 }
42 
44 {
45  uint32_t now_ts = get_sys_time_usec();
46 
47  gps_imcu.ecef_pos.x = DL_IMCU_REMOTE_GPS_ecef_x(buf);
48  gps_imcu.ecef_pos.y = DL_IMCU_REMOTE_GPS_ecef_y(buf);
49  gps_imcu.ecef_pos.z = DL_IMCU_REMOTE_GPS_ecef_z(buf);
51 
52  gps_imcu.lla_pos.alt = DL_IMCU_REMOTE_GPS_alt(buf);
53  gps_imcu.hmsl = DL_IMCU_REMOTE_GPS_hmsl(buf);
55 
56  gps_imcu.ecef_vel.x = DL_IMCU_REMOTE_GPS_ecef_xd(buf);
57  gps_imcu.ecef_vel.y = DL_IMCU_REMOTE_GPS_ecef_yd(buf);
58  gps_imcu.ecef_vel.z = DL_IMCU_REMOTE_GPS_ecef_zd(buf);
60 
61  gps_imcu.course = DL_IMCU_REMOTE_GPS_course(buf);
62  gps_imcu.gspeed = DL_IMCU_REMOTE_GPS_gspeed(buf);
64 
65  gps_imcu.pacc = DL_IMCU_REMOTE_GPS_pacc(buf);
66  gps_imcu.sacc = DL_IMCU_REMOTE_GPS_sacc(buf);
67  gps_imcu.num_sv = DL_IMCU_REMOTE_GPS_numsv(buf);
68  gps_imcu.fix = DL_IMCU_REMOTE_GPS_fix(buf);
69 
70  // set gps msg time
73  if (gps_imcu.fix >= GPS_FIX_3D) {
76  }
77 
78  AbiSendMsgGPS(GPS_IMCU_ID, now_ts, &gps_imcu);
79 }
80 
Main include for ABI (AirBorneInterface).
#define GPS_IMCU_ID
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
Definition: sys_time_arch.c:71
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
uint32_t sacc
speed accuracy in cm/s
Definition: gps.h:103
uint32_t cacc
course accuracy in rad*1e7
Definition: gps.h:104
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
Definition: gps.h:99
#define GPS_VALID_VEL_ECEF_BIT
Definition: gps.h:51
struct EcefCoor_i ecef_pos
position in ECEF in cm
Definition: gps.h:91
uint32_t last_3dfix_ticks
cpu time ticks at last valid 3D fix
Definition: gps.h:114
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
Definition: gps.h:95
uint16_t pdop
position dilution of precision scaled by 100
Definition: gps.h:105
#define GPS_FIX_NONE
No GPS fix.
Definition: gps.h:42
#define GPS_VALID_POS_ECEF_BIT
Definition: gps.h:48
#define GPS_VALID_HMSL_BIT
Definition: gps.h:53
uint32_t last_msg_time
cpu time in sec at last received GPS message
Definition: gps.h:117
uint32_t last_3dfix_time
cpu time in sec at last valid 3D fix
Definition: gps.h:115
uint32_t pacc
position accuracy in cm
Definition: gps.h:100
uint16_t gspeed
norm of 2d ground speed in cm/s
Definition: gps.h:97
uint8_t valid_fields
bitfield indicating valid fields (GPS_VALID_x_BIT)
Definition: gps.h:88
uint8_t comp_id
id of current gps
Definition: gps.h:89
#define GPS_FIX_3D
3D GPS fix
Definition: gps.h:44
#define GPS_VALID_COURSE_BIT
Definition: gps.h:54
uint32_t last_msg_ticks
cpu time ticks at last received GPS message
Definition: gps.h:116
uint8_t num_sv
number of sat in fix
Definition: gps.h:106
uint8_t fix
status of fix
Definition: gps.h:107
data structure for GPS information
Definition: gps.h:87
struct GpsState gps_imcu
Definition: gps_intermcu.c:30
void gps_intermcu_init(void)
GPS initialization.
Definition: gps_intermcu.c:33
void gps_intermcu_parse_IMCU_REMOTE_GPS(uint8_t *buf)
Definition: gps_intermcu.c:43
GPS system based on intermcu.
int32_t alt
in millimeters above WGS84 reference ellipsoid
int32_t z
in centimeters
int32_t x
in centimeters
int32_t y
in centimeters
volatile uint32_t nb_sec
full seconds since startup
Definition: sys_time.h:72
volatile uint32_t nb_sec_rem
remainder of seconds since startup in CPU_TICKS
Definition: sys_time.h:73
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
Definition: vl53l1_types.h:78
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
Definition: vl53l1_types.h:98