31 #include "generated/flight_plan.h"
39 #ifndef EXTERNAL_POSE_SMALL_POS_RES
40 #define EXTERNAL_POSE_SMALL_POS_RES 1.0
43 #ifndef EXTERNAL_POSE_SMALL_SPEED_RES
44 #define EXTERNAL_POSE_SMALL_SPEED_RES 1.0
62 llh_nav0.
lat = NAV_LAT0;
63 llh_nav0.
lon = NAV_LON0;
65 llh_nav0.
alt = NAV_ALT0 + NAV_MSL0;
125 if (DL_EXTERNAL_POSE_ac_id(buf) != AC_ID) {
return; }
127 uint32_t tow = DL_EXTERNAL_POSE_timestamp(buf);
130 enu_pos.
x = DL_EXTERNAL_POSE_enu_x(buf);
131 enu_pos.
y = DL_EXTERNAL_POSE_enu_y(buf);
132 enu_pos.
z = DL_EXTERNAL_POSE_enu_z(buf);
133 enu_speed.
x = DL_EXTERNAL_POSE_enu_xd(buf);
134 enu_speed.
y = DL_EXTERNAL_POSE_enu_yd(buf);
135 enu_speed.
z = DL_EXTERNAL_POSE_enu_zd(buf);
138 body_q.
qi = DL_EXTERNAL_POSE_body_qi(buf);
139 body_q.
qx = DL_EXTERNAL_POSE_body_qy(buf);
140 body_q.
qy = DL_EXTERNAL_POSE_body_qx(buf);
141 body_q.
qz = -DL_EXTERNAL_POSE_body_qz(buf);
153 if (DL_EXTERNAL_POSE_SMALL_ac_id(buf) != AC_ID) {
return; }
155 uint32_t tow = DL_EXTERNAL_POSE_SMALL_timestamp(buf);
157 struct EnuCoor_i enu_pos_cm, enu_speed_cm;
161 uint32_t enu_pos_u = DL_EXTERNAL_POSE_SMALL_enu_pos(buf);
162 enu_pos_cm.
x = (
int32_t)((enu_pos_u >> 21) & 0x7FF);
163 if (enu_pos_cm.
x & 0x400) {
164 enu_pos_cm.
x |= 0xFFFFF800;
166 enu_pos_cm.
y = (
int32_t)((enu_pos_u >> 10) & 0x7FF);
167 if (enu_pos_cm.
y & 0x400) {
168 enu_pos_cm.
y |= 0xFFFFF800;
170 enu_pos_cm.
z = (
int32_t)(enu_pos_u & 0x3FF);
178 uint32_t enu_speed_u = DL_EXTERNAL_POSE_SMALL_enu_speed(buf);
179 enu_speed_cm.
x = (
int32_t)((enu_speed_u >> 21) & 0x7FF);
180 if (enu_speed_cm.
x & 0x400) {
181 enu_speed_cm.
x |= 0xFFFFF800;
183 enu_speed_cm.
y = (
int32_t)((enu_speed_u >> 10) & 0x7FF);
184 if (enu_speed_cm.
y & 0x400) {
185 enu_speed_cm.
y |= 0xFFFFF800;
187 enu_speed_cm.
z = (
int32_t)((enu_speed_u) & 0x3FF);
188 if (enu_speed_cm.
z & 0x200) {
189 enu_speed_cm.
z |= 0xFFFFFC00;
198 float heading = DL_EXTERNAL_POSE_SMALL_heading(buf) / 1e4;
205 if (DL_REMOTE_GPS_LOCAL_ac_id(buf) != AC_ID) {
return; }
207 uint32_t tow = DL_REMOTE_GPS_LOCAL_tow(buf);
210 enu_pos.
x = DL_REMOTE_GPS_LOCAL_enu_x(buf);
211 enu_pos.
y = DL_REMOTE_GPS_LOCAL_enu_y(buf);
212 enu_pos.
z = DL_REMOTE_GPS_LOCAL_enu_z(buf);
214 enu_speed.
x = DL_REMOTE_GPS_LOCAL_enu_xd(buf);
215 enu_speed.
y = DL_REMOTE_GPS_LOCAL_enu_yd(buf);
216 enu_speed.
z = DL_REMOTE_GPS_LOCAL_enu_zd(buf);
218 float course = RadOfDeg(DL_REMOTE_GPS_LOCAL_course(buf));
Main include for ABI (AirBorneInterface).
uint32_t get_sys_time_usec(void)
Get the time in microseconds since startup.
Handling of messages coming from ground and other A/Cs.
Common code for AP and FBW telemetry.
Device independent GPS code (interface)
uint32_t tow
GPS time of week in ms.
int32_t hmsl
height above mean sea level (MSL) in mm
struct LlaCoor_i lla_pos
position in LLA (lat,lon: deg*1e7; alt: mm over ellipsoid)
uint32_t sacc
speed accuracy in cm/s
uint32_t cacc
course accuracy in rad*1e7
int32_t course
GPS course over ground in rad*1e7, [0, 2*Pi]*1e7 (CW/north)
#define GPS_VALID_VEL_ECEF_BIT
#define GPS_VALID_VEL_NED_BIT
struct EcefCoor_i ecef_pos
position in ECEF in cm
#define GPS_VALID_POS_LLA_BIT
uint32_t last_3dfix_ticks
cpu time ticks at last valid 3D fix
struct EcefCoor_i ecef_vel
speed ECEF in cm/s
uint16_t pdop
position dilution of precision scaled by 100
#define GPS_FIX_NONE
No GPS fix.
#define GPS_VALID_POS_ECEF_BIT
#define GPS_VALID_HMSL_BIT
struct NedCoor_i ned_vel
speed NED in cm/s
uint32_t last_msg_time
cpu time in sec at last received GPS message
uint32_t last_3dfix_time
cpu time in sec at last valid 3D fix
uint32_t pacc
position accuracy in cm
uint16_t gspeed
norm of 2d ground speed in cm/s
uint8_t valid_fields
bitfield indicating valid fields (GPS_VALID_x_BIT)
uint8_t comp_id
id of current gps
#define GPS_FIX_3D
3D GPS fix
uint16_t speed_3d
norm of 3d speed in cm/s
#define GPS_VALID_COURSE_BIT
uint32_t last_msg_ticks
cpu time ticks at last received GPS message
uint8_t num_sv
number of sat in fix
data structure for GPS information
void gps_datalink_parse_EXTERNAL_POSE(uint8_t *buf)
Parse the full EXTERNAL_POSE message and publish as GPS through ABI.
void gps_datalink_parse_REMOTE_GPS_LOCAL(uint8_t *buf)
void gps_datalink_init(void)
GPS initialization.
#define EXTERNAL_POSE_SMALL_POS_RES
struct GpsState gps_datalink
#define EXTERNAL_POSE_SMALL_SPEED_RES
static void gps_datalink_publish(uint32_t tow, struct EnuCoor_f *enu_pos, struct EnuCoor_f *enu_speed, float course)
Publish the GPS data.
static struct LtpDef_i ltp_def
void gps_datalink_parse_EXTERNAL_POSE_SMALL(uint8_t *buf)
Parse the EXTERNAL_POSE_SMALL message and publish as GPS through ABI.
#define FLOAT_VECT3_NORM(_v)
void float_eulers_of_quat(struct FloatEulers *e, struct FloatQuat *q)
euler rotation 'ZYX'
#define FLOAT_VECT2_NORM(_v)
int32_t lat
in degrees*1e7
int32_t hmsl
Height above mean sea level in mm.
int32_t alt
in millimeters above WGS84 reference ellipsoid
int32_t lon
in degrees*1e7
void ecef_of_enu_vect_i(struct EcefCoor_i *ecef, struct LtpDef_i *def, struct EnuCoor_i *enu)
Rotate a vector from ENU to ECEF.
#define VECT3_NED_OF_ENU(_o, _i)
void ecef_of_enu_point_i(struct EcefCoor_i *ecef, struct LtpDef_i *def, struct EnuCoor_i *enu)
Convert a point in local ENU to ECEF.
void lla_of_ecef_i(struct LlaCoor_i *out, struct EcefCoor_i *in)
Convert a ECEF to LLA.
void ltp_def_from_lla_i(struct LtpDef_i *def, struct LlaCoor_i *lla)
vector in East North Up coordinates
vector in Latitude, Longitude and Altitude
definition of the local (flat earth) coordinate system
Inertial Measurement Unit interface.
vector in East North Up coordinates Units: meters
volatile uint32_t nb_sec
full seconds since startup
volatile uint32_t nb_sec_rem
remainder of seconds since startup in CPU_TICKS
int int32_t
Typedef defining 32 bit int type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.