29#include "generated/airframe.h"
30#include "generated/flight_plan.h"
34#include "pprzlink/dl_protocol.h"
35#include "pprzlink/messages.h"
41#if TRAFFIC_INFO_USE_LOG
47#ifndef TRAFFIC_INFO_FILE_PATH
48#define TRAFFIC_INFO_FILE_PATH /data/ftp/internal_000/acinfo
76 struct pprzlink_msg msg;
79 msg.sender_id = AC_ID;
80 msg.receiver_id = PPRZLINK_MSG_BROADCAST;
82 pprzlink_msg_send_ACINFO_LLA(&msg,
84 &lla->
lat, &lla->
lon, &alt,
85 &itow, &speed, &climb, &ac_id);
87#if TRAFFIC_INFO_USE_LOG
91 LogWrite(
pprzLogFile,
"S,%d,%d,%.7f,%.7f,%.3f,%.3f,%.3f,%.3f,%d,0\n",
92 msg.sender_id, msg.receiver_id,
93 DegOfRad(lla_f->
lat), DegOfRad(lla_f->
lon), lla_f->
alt,
94 enu_f->
x, enu_f->
y, enu_f->
z,
111#if PERIODIC_TELEMETRY
132 uint8_t sender_id = SenderIdOfPprzMsg(buf);
133 uint8_t msg_id = IdOfPprzMsg(buf);
134 uint8_t class_id = pprzlink_get_msg_class_id(buf);
138#if PPRZLINK_DEFAULT_VER == 2
139 if (class_id == DL_telemetry_CLASS_ID) {
145 uint32_t multiplex_speed = DL_GPS_SMALL_multiplex_speed(buf);
154 if (gspeed & 0x400) {
164 DL_GPS_SMALL_lat(buf),
165 DL_GPS_SMALL_lon(buf),
166 (
int32_t)DL_GPS_SMALL_alt(buf) * 10,
174 itow = DL_GPS_itow(buf);
176 DL_GPS_utm_east(buf),
177 DL_GPS_utm_north(buf),
179 DL_GPS_utm_zone(buf),
187 itow = DL_GPS_LLA_itow(buf);
192 DL_GPS_LLA_course(buf),
193 DL_GPS_LLA_speed(buf),
194 DL_GPS_LLA_climb(buf),
201 .x = DL_GPS_INT_ecef_x(buf),
202 .y = DL_GPS_INT_ecef_y(buf),
203 .z = DL_GPS_INT_ecef_z(buf),
206 .x = DL_GPS_INT_ecef_xd(buf),
207 .y = DL_GPS_INT_ecef_yd(buf),
208 .z = DL_GPS_INT_ecef_zd(buf),
218 itow = DL_GPS_INT_tow(buf);
233 }
else if (class_id == DL_datalink_CLASS_ID) {
236 sender_id = DL_ACINFO_ac_id(buf);
237 itow = DL_ACINFO_itow(buf);
239 DL_ACINFO_utm_east(buf),
240 DL_ACINFO_utm_north(buf),
241 DL_ACINFO_alt(buf) * 10,
242 DL_ACINFO_utm_zone(buf),
243 DL_ACINFO_course(buf),
244 DL_ACINFO_speed(buf),
245 DL_ACINFO_climb(buf),
249 case DL_ACINFO_LLA: {
250 sender_id = DL_ACINFO_LLA_ac_id(buf);
251 itow = DL_ACINFO_LLA_itow(buf);
253 DL_ACINFO_LLA_lat(buf),
254 DL_ACINFO_LLA_lon(buf),
255 DL_ACINFO_LLA_alt(buf) * 10,
256 DL_ACINFO_LLA_course(buf),
257 DL_ACINFO_LLA_speed(buf),
258 DL_ACINFO_LLA_climb(buf),
268#if TRAFFIC_INFO_USE_LOG
272 LogWrite(
pprzLogFile,
"R,%d,%d,%.7f,%.7f,%.3f,%.3f,%.3f,%.3f,%d,%d\n",
274 DegOfRad(lla_f->
lat), DegOfRad(lla_f->
lon), lla_f->
alt,
275 enu_f->
x, enu_f->
y, enu_f->
z,
299 if (utm_zone == my_zone) {
307 struct UtmCoor_i utm = {.east = utm_east, .north = utm_north, .alt =
alt, .zone = utm_zone};
435 else if (
state.ned_initialized_i)
445 ti_acs[ac_nr].enu_pos_i = enu;
452 }
else if (
state.utm_initialized_f)
535 else if (
state.ned_initialized_i)
548 ti_acs[ac_nr].enu_pos_i = enu;
552 }
else if (
state.utm_initialized_f)
604#if TRAFFIC_INFO_USE_LOG
611#if TRAFFIC_INFO_USE_LOG
Handling of messages coming from ground and other A/Cs.
static struct uart_periph * dev
struct GpsState gps
global GPS state
uint32_t gps_tow_from_sys_ticks(uint32_t sys_ticks)
Convert time in sys_time ticks to GPS time of week.
#define GPS_VALID_POS_LLA_BIT
#define GPS_VALID_HMSL_BIT
#define AC_INFO_VEL_ENU_I
bool parse_acinfo_dl(uint8_t *buf)
Parse all datalink or telemetry messages that contain global position of other acs Messages currently...
#define AC_INFO_POS_LLA_I
#define AC_INFO_VEL_ENU_F
void set_ac_info_utm(uint8_t id, uint32_t utm_east, uint32_t utm_north, uint32_t alt, uint8_t utm_zone, uint16_t course, uint16_t gspeed, uint16_t climb, uint32_t itow)
Set Aircraft info.
void acInfoCalcPositionUtm_f(uint8_t ac_id)
void traffic_info_log_stop(void)
#define AC_INFO_POS_LLA_F
void acInfoCalcPositionEnu_f(uint8_t ac_id)
void acInfoCalcVelocityEnu_f(uint8_t ac_id)
void acInfoCalcPositionUtm_i(uint8_t ac_id)
void acInfoCalcPositionLla_i(uint8_t ac_id)
void acInfoCalcPositionLla_f(uint8_t ac_id)
void set_ac_info_lla(uint8_t id, int32_t lat, int32_t lon, int32_t alt, int16_t course, uint16_t gspeed, int16_t climb, uint32_t itow)
Set Aircraft info.
static struct LlaCoor_i * acInfoGetPositionLla_i(uint8_t ac_id)
Get position from LLA coordinates (int).
#define AC_INFO_POS_ENU_F
#define AC_INFO_POS_UTM_F
#define AC_INFO_POS_UTM_I
#define AC_INFO_POS_ENU_I
void traffic_info_init(void)
#define AC_INFO_VEL_LOCAL_F
struct acInfo ti_acs[NB_ACS]
uint8_t ti_acs_id[NB_ACS_ID]
static struct LlaCoor_f * acInfoGetPositionLla_f(uint8_t ac_id)
Get position from LLA coordinates (float).
static struct EnuCoor_f * acInfoGetPositionEnu_f(uint8_t ac_id)
Get position in local ENU coordinates (float).
void acInfoCalcPositionEnu_i(uint8_t ac_id)
void acInfoCalcVelocityEnu_i(uint8_t ac_id)
static struct UtmCoor_f * acInfoGetPositionUtm_f(uint8_t ac_id)
Get position from UTM coordinates (float).
void traffic_info_log_start(void)
#define FLOAT_VECT2_NORM(_v)
#define SPEEDS_BFP_OF_REAL(_ef, _ei)
#define SPEEDS_FLOAT_OF_BFP(_ef, _ei)
#define POS_BFP_OF_REAL(_af)
#define LLA_COPY(_pos1, _pos2)
#define ENU_OF_UTM_DIFF(_pos, _utm1, _utm2)
#define UTM_COPY(_u1, _u2)
int32_t lat
in degrees*1e7
int32_t alt
in millimeters (above WGS84 reference ellipsoid or above MSL)
int32_t alt
in millimeters above WGS84 reference ellipsoid
uint8_t zone
UTM zone number.
int32_t lon
in degrees*1e7
#define ENU_FLOAT_OF_BFP(_o, _i)
void lla_of_utm_i(struct LlaCoor_i *lla, struct UtmCoor_i *utm)
Convert a UTM to LLA.
#define ENU_BFP_OF_REAL(_o, _i)
#define LLA_BFP_OF_REAL(_o, _i)
void ltp_def_from_ecef_i(struct LtpDef_i *def, struct EcefCoor_i *ecef)
#define UTM_BFP_OF_REAL(_o, _i)
void enu_of_lla_point_i(struct EnuCoor_i *enu, struct LtpDef_i *def, struct LlaCoor_i *lla)
Convert a point from LLA to local ENU.
void ned_of_ecef_vect_i(struct NedCoor_i *ned, struct LtpDef_i *def, struct EcefCoor_i *ecef)
Rotate a vector from ECEF to NED.
#define VECT3_FLOAT_OF_CM(_o, _i)
#define LLA_FLOAT_OF_BFP(_o, _i)
void utm_of_lla_i(struct UtmCoor_i *utm, struct LlaCoor_i *lla)
Convert a LLA to UTM.
#define UTM_FLOAT_OF_BFP(_o, _i)
vector in EarthCenteredEarthFixed coordinates
vector in East North Up coordinates
vector in Latitude, Longitude and Altitude
definition of the local (flat earth) coordinate system
vector in North East Down coordinates
position in UTM coordinates
static int32_t wgs84_ellipsoid_to_geoid_i(int32_t lat, int32_t lon)
Get WGS84 ellipsoid/geoid separation.
static struct LlaCoor_f * stateGetPositionLla_f(void)
Get position in LLA coordinates (float).
static struct LtpDef_f * stateGetNedOrigin_f(void)
Get the coordinate NED frame origin (float).
static struct LlaCoor_i * stateGetPositionLla_i(void)
Get position in LLA coordinates (int).
static struct UtmCoor_f * stateGetUtmOrigin_f(void)
Get the coordinate UTM frame origin (int).
static struct EnuCoor_f * stateGetPositionEnu_f(void)
Get position in local ENU coordinates (float).
static struct LtpDef_i * stateGetNedOrigin_i(void)
Get the coordinate NED frame origin (int).
static float stateGetHorizontalSpeedNorm_f(void)
Get norm of horizontal ground speed (float).
static float stateGetHorizontalSpeedDir_f(void)
Get dir of horizontal ground speed (float).
static struct EnuCoor_f * stateGetSpeedEnu_f(void)
Get ground speed in local ENU coordinates (float).
static FILE * pprzLogFile
Generic definitions and tools for logging on ChibiOS or Linux.
#define LogOpen(_file, _path, _name)
#define LogFileIsOpen(_file)
void lla_of_utm_f(struct LlaCoor_f *lla, struct UtmCoor_f *utm)
void enu_of_lla_point_f(struct EnuCoor_f *enu, struct LtpDef_f *def, struct LlaCoor_f *lla)
void utm_of_lla_f(struct UtmCoor_f *utm, struct LlaCoor_f *lla)
float alt
in meters (normally above WGS84 reference ellipsoid)
uint8_t zone
UTM zone number.
vector in East North Up coordinates Units: meters
vector in Latitude, Longitude and Altitude
vector in North East Down coordinates Units: meters
Constants UTM (Mercator) projections.
API to get/set the generic vehicle states.
volatile uint32_t nb_tick
SYS_TIME_TICKS since startup.
int16_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint16_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
static void send_acinfo_lla(struct transport_tx *trans, struct link_device *dev)
static void update_geoid_height(void)
Update estimate of the geoid height Requires an available hsml and/or lla measurement,...
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
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.