[fbw_gps] GPS in FBW/FTD (e.g. geofencing) (#1876)

* [FBW_GPS] Run GPS driver in FBW, e.g. for geofencing

* [FBW_GPS] convert all GPS modules to run in FBW
This commit is contained in:
Christophe De Wagter
2016-11-02 11:13:16 +01:00
committed by Felix Ruess
parent 07da2174e2
commit 56a2eb21e0
16 changed files with 197 additions and 56 deletions
+11 -5
View File
@@ -202,7 +202,6 @@
<modules> <modules>
<module name="gps" type="ubx_ucenter"/>
<!-- <!--
<module name="adc_generic"> <module name="adc_generic">
<configure name="ADC_CHANNEL_GENERIC1" value="ADC_1" /> <configure name="ADC_CHANNEL_GENERIC1" value="ADC_1" />
@@ -248,6 +247,12 @@
<configure name="INTERMCU_PORT" value="UART5"/> <configure name="INTERMCU_PORT" value="UART5"/>
</module> </module>
<module name="gps" type="ublox">
<configure name="GPS_PORT" value="UART1"/>
</module>
<module name="gps" type="ubx_ucenter"/>
<module name="control"/> <module name="control"/>
<module name="navigation"/> <module name="navigation"/>
</target> </target>
@@ -272,6 +277,11 @@
<target name="sim" board="pc"> <target name="sim" board="pc">
<module name="control"/> <module name="control"/>
<module name="navigation"/> <module name="navigation"/>
<module name="gps" type="ublox">
<configure name="GPS_PORT" value="UART1"/>
</module>
</target> </target>
<configure name="FLASH_MODE" value="JTAG"/> <configure name="FLASH_MODE" value="JTAG"/>
@@ -296,10 +306,6 @@
<!-- Sensors --> <!-- Sensors -->
<module name="imu" type="aspirin_v2.1"/> <module name="imu" type="aspirin_v2.1"/>
<module name="gps" type="ublox">
<configure name="GPS_PORT" value="UART1"/>
</module>
<module name="ahrs" type="float_dcm"/> <module name="ahrs" type="float_dcm"/>
<module name="ins" type="alt_float"/> <module name="ins" type="alt_float"/>
@@ -27,6 +27,12 @@ ifneq ($(RADIO_CONTROL_LED),none)
$(TARGET).CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED) $(TARGET).CFLAGS += -DRADIO_CONTROL_LED=$(RADIO_CONTROL_LED)
endif endif
ifneq (,$(findstring $(SECONDARY_GPS), imcu))
# this is the secondary GPS
$(TARGET).CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/intermcu/intermcu_ap.h\"
$(TARGET).CFLAGS += -DSECONDARY_GPS=GPS_IMCU -DIMCU_GPS
endif
ap.srcs += subsystems/intermcu/intermcu_ap.c ap.srcs += subsystems/intermcu/intermcu_ap.c
ap.srcs += pprzlink/src/pprz_transport.c ap.srcs += pprzlink/src/pprz_transport.c
$(TARGET).srcs += subsystems/radio_control.c $(TARGET).srcs += subsystems/radio_control.c
+9 -6
View File
@@ -17,23 +17,26 @@
<periodic fun="gps_datalink_periodic_check()" freq="1." autorun="TRUE"/> <periodic fun="gps_datalink_periodic_check()" freq="1." autorun="TRUE"/>
<datalink message="REMOTE_GPS" fun="gps_datalink_parse_REMOTE_GPS()"/> <datalink message="REMOTE_GPS" fun="gps_datalink_parse_REMOTE_GPS()"/>
<datalink message="REMOTE_GPS_SMALL" fun="gps_datalink_parse_REMOTE_GPS_SMALL()"/> <datalink message="REMOTE_GPS_SMALL" fun="gps_datalink_parse_REMOTE_GPS_SMALL()"/>
<makefile target="ap"> <makefile target="ap|fbw">
<file name="gps_datalink.c" dir="subsystems/gps"/> <file name="gps_datalink.c" dir="subsystems/gps"/>
<raw> <raw>
ifdef SECONDARY_GPS ifdef SECONDARY_GPS
ifneq (,$(findstring $(SECONDARY_GPS), datalink)) ifneq (,$(findstring $(SECONDARY_GPS), datalink))
# this is the secondary GPS # this is the secondary GPS
ap.CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/gps/gps_datalink.h\" $(TARGET).CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/gps/gps_datalink.h\"
ap.CFLAGS += -DSECONDARY_GPS=GPS_DATALINK $(TARGET).CFLAGS += -DSECONDARY_GPS=GPS_DATALINK
else else
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_datalink.h\" $(TARGET).CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_datalink.h\"
ap.CFLAGS += -DPRIMARY_GPS=GPS_DATALINK $(TARGET).CFLAGS += -DPRIMARY_GPS=GPS_DATALINK
endif endif
else else
# plain old single GPS usage # plain old single GPS usage
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_datalink.h\" $(TARGET).CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_datalink.h\"
endif endif
</raw> </raw>
</makefile> </makefile>
<makefile target="fbw">
<define name="USE_GPS"/>
</makefile>
</module> </module>
+9 -6
View File
@@ -18,7 +18,7 @@
<init fun="gps_nmea_init()"/> <init fun="gps_nmea_init()"/>
<periodic fun="gps_nmea_periodic_check()" freq="1." autorun="TRUE"/> <periodic fun="gps_nmea_periodic_check()" freq="1." autorun="TRUE"/>
<event fun="gps_nmea_event()"/> <event fun="gps_nmea_event()"/>
<makefile target="ap"> <makefile target="ap|fbw">
<configure name="FURUNO_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/> <configure name="FURUNO_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/>
<configure name="FURUNO_GPS_BAUD" default="$(GPS_BAUD)"/> <configure name="FURUNO_GPS_BAUD" default="$(GPS_BAUD)"/>
@@ -35,16 +35,19 @@
ifdef SECONDARY_GPS ifdef SECONDARY_GPS
ifneq (,$(findstring $(SECONDARY_GPS), nmea furuno)) ifneq (,$(findstring $(SECONDARY_GPS), nmea furuno))
# this is the secondary GPS # this is the secondary GPS
ap.CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/gps/gps_nmea.h\" $(TARGET).CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/gps/gps_nmea.h\"
ap.CFLAGS += -DSECONDARY_GPS=GPS_NMEA $(TARGET).CFLAGS += -DSECONDARY_GPS=GPS_NMEA
else else
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_nmea.h\" $(TARGET).CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_nmea.h\"
ap.CFLAGS += -DPRIMARY_GPS=GPS_NMEA $(TARGET).CFLAGS += -DPRIMARY_GPS=GPS_NMEA
endif endif
else else
# plain old single GPS usage # plain old single GPS usage
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_nmea.h\" $(TARGET).CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_nmea.h\"
endif endif
</raw> </raw>
</makefile> </makefile>
<makefile target="fbw">
<define name="USE_GPS"/>
</makefile>
</module> </module>
+9 -6
View File
@@ -18,7 +18,7 @@
<init fun="gps_mtk_init()"/> <init fun="gps_mtk_init()"/>
<periodic fun="gps_mtk_periodic_check()" freq="1." autorun="TRUE"/> <periodic fun="gps_mtk_periodic_check()" freq="1." autorun="TRUE"/>
<event fun="gps_mtk_event()"/> <event fun="gps_mtk_event()"/>
<makefile target="ap"> <makefile target="ap|fbw">
<configure name="MTK_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/> <configure name="MTK_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/>
<configure name="MTK_GPS_BAUD" default="$(GPS_BAUD)"/> <configure name="MTK_GPS_BAUD" default="$(GPS_BAUD)"/>
@@ -31,16 +31,19 @@
ifdef SECONDARY_GPS ifdef SECONDARY_GPS
ifneq (,$(findstring $(SECONDARY_GPS), mtk mediatek)) ifneq (,$(findstring $(SECONDARY_GPS), mtk mediatek))
# this is the secondary GPS # this is the secondary GPS
ap.CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/gps/gps_mtk.h\" $(TARGET).CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/gps/gps_mtk.h\"
ap.CFLAGS += -DSECONDARY_GPS=GPS_MTK $(TARGET).CFLAGS += -DSECONDARY_GPS=GPS_MTK
else else
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_mtk.h\" $(TARGET).CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_mtk.h\"
ap.CFLAGS += -DPRIMARY_GPS=GPS_MTK $(TARGET).CFLAGS += -DPRIMARY_GPS=GPS_MTK
endif endif
else else
# plain old single GPS usage # plain old single GPS usage
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_mtk.h\" $(TARGET).CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_mtk.h\"
endif endif
</raw> </raw>
</makefile> </makefile>
<makefile target="fbw">
<define name="USE_GPS"/>
</makefile>
</module> </module>
+9 -6
View File
@@ -18,7 +18,7 @@
<init fun="gps_nmea_init()"/> <init fun="gps_nmea_init()"/>
<periodic fun="gps_nmea_periodic_check()" freq="1." autorun="TRUE"/> <periodic fun="gps_nmea_periodic_check()" freq="1." autorun="TRUE"/>
<event fun="gps_nmea_event()"/> <event fun="gps_nmea_event()"/>
<makefile target="ap"> <makefile target="ap|fbw">
<configure name="NMEA_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/> <configure name="NMEA_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/>
<configure name="NMEA_GPS_BAUD" default="$(GPS_BAUD)"/> <configure name="NMEA_GPS_BAUD" default="$(GPS_BAUD)"/>
@@ -31,16 +31,19 @@
ifdef SECONDARY_GPS ifdef SECONDARY_GPS
ifneq (,$(findstring $(SECONDARY_GPS), nmea)) ifneq (,$(findstring $(SECONDARY_GPS), nmea))
# this is the secondary GPS # this is the secondary GPS
ap.CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/gps/gps_nmea.h\" $(TARGET).CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/gps/gps_nmea.h\"
ap.CFLAGS += -DSECONDARY_GPS=GPS_NMEA $(TARGET).CFLAGS += -DSECONDARY_GPS=GPS_NMEA
else else
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_nmea.h\" $(TARGET).CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_nmea.h\"
ap.CFLAGS += -DPRIMARY_GPS=GPS_NMEA $(TARGET).CFLAGS += -DPRIMARY_GPS=GPS_NMEA
endif endif
else else
# plain old single GPS usage # plain old single GPS usage
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_nmea.h\" $(TARGET).CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_nmea.h\"
endif endif
</raw> </raw>
</makefile> </makefile>
<makefile target="fbw">
<define name="USE_GPS"/>
</makefile>
</module> </module>
+9 -6
View File
@@ -18,7 +18,7 @@
<init fun="gps_piksi_init()"/> <init fun="gps_piksi_init()"/>
<periodic fun="gps_piksi_periodic_check()" freq="1." autorun="TRUE"/> <periodic fun="gps_piksi_periodic_check()" freq="1." autorun="TRUE"/>
<event fun="gps_piksi_event()"/> <event fun="gps_piksi_event()"/>
<makefile target="ap"> <makefile target="ap|fbw">
<configure name="PIKSI_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/> <configure name="PIKSI_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/>
<configure name="PIKSI_GPS_BAUD" default="B115200"/> <configure name="PIKSI_GPS_BAUD" default="B115200"/>
@@ -34,16 +34,19 @@
ifdef SECONDARY_GPS ifdef SECONDARY_GPS
ifneq (,$(findstring $(SECONDARY_GPS), piksi)) ifneq (,$(findstring $(SECONDARY_GPS), piksi))
# this is the secondary GPS # this is the secondary GPS
ap.CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/gps/gps_piksi.h\" $(TARGET).CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/gps/gps_piksi.h\"
ap.CFLAGS += -DSECONDARY_GPS=GPS_PIKSI $(TARGET).CFLAGS += -DSECONDARY_GPS=GPS_PIKSI
else else
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_piksi.h\" $(TARGET).CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_piksi.h\"
ap.CFLAGS += -DPRIMARY_GPS=GPS_PIKSI $(TARGET).CFLAGS += -DPRIMARY_GPS=GPS_PIKSI
endif endif
else else
# plain old single GPS usage # plain old single GPS usage
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_piksi.h\" $(TARGET).CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_piksi.h\"
endif endif
</raw> </raw>
</makefile> </makefile>
<makefile target="fbw">
<define name="USE_GPS"/>
</makefile>
</module> </module>
+9 -6
View File
@@ -18,7 +18,7 @@
<init fun="gps_sirf_init()"/> <init fun="gps_sirf_init()"/>
<periodic fun="gps_sirf_periodic_check()" freq="1." autorun="TRUE"/> <periodic fun="gps_sirf_periodic_check()" freq="1." autorun="TRUE"/>
<event fun="gps_sirf_event()"/> <event fun="gps_sirf_event()"/>
<makefile target="ap"> <makefile target=target="ap|fbw">
<configure name="SIRF_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/> <configure name="SIRF_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/>
<configure name="SIRF_GPS_BAUD" default="$(GPS_BAUD)"/> <configure name="SIRF_GPS_BAUD" default="$(GPS_BAUD)"/>
@@ -31,16 +31,19 @@
ifdef SECONDARY_GPS ifdef SECONDARY_GPS
ifneq (,$(findstring $(SECONDARY_GPS), sirf)) ifneq (,$(findstring $(SECONDARY_GPS), sirf))
# this is the secondary GPS # this is the secondary GPS
ap.CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/gps/gps_sirf.h\" $(TARGET).CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/gps/gps_sirf.h\"
ap.CFLAGS += -DSECONDARY_GPS=GPS_SIRF $(TARGET).CFLAGS += -DSECONDARY_GPS=GPS_SIRF
else else
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_sirf.h\" $(TARGET).CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_sirf.h\"
ap.CFLAGS += -DPRIMARY_GPS=GPS_SIRF $(TARGET).CFLAGS += -DPRIMARY_GPS=GPS_SIRF
endif endif
else else
# plain old single GPS usage # plain old single GPS usage
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_sirf.h\" $(TARGET).CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_sirf.h\"
endif endif
</raw> </raw>
</makefile> </makefile>
<makefile target="fbw">
<define name="USE_GPS"/>
</makefile>
</module> </module>
+9 -6
View File
@@ -18,7 +18,7 @@
<init fun="gps_skytraq_init()"/> <init fun="gps_skytraq_init()"/>
<periodic fun="gps_skytraq_periodic_check()" freq="1." autorun="TRUE"/> <periodic fun="gps_skytraq_periodic_check()" freq="1." autorun="TRUE"/>
<event fun="gps_skytraq_event()"/> <event fun="gps_skytraq_event()"/>
<makefile target="ap"> <makefile target="ap|fbw">
<configure name="SKYTRAQ_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/> <configure name="SKYTRAQ_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/>
<configure name="SKYTRAQ_GPS_BAUD" default="$(GPS_BAUD)"/> <configure name="SKYTRAQ_GPS_BAUD" default="$(GPS_BAUD)"/>
@@ -31,16 +31,19 @@
ifdef SECONDARY_GPS ifdef SECONDARY_GPS
ifneq (,$(findstring $(SECONDARY_GPS), skytraq)) ifneq (,$(findstring $(SECONDARY_GPS), skytraq))
# this is the secondary GPS # this is the secondary GPS
ap.CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/gps/gps_skytraq.h\" $(TARGET).CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/gps/gps_skytraq.h\"
ap.CFLAGS += -DSECONDARY_GPS=GPS_SKYTRAQ $(TARGET).CFLAGS += -DSECONDARY_GPS=GPS_SKYTRAQ
else else
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_skytraq.h\" $(TARGET).CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_skytraq.h\"
ap.CFLAGS += -DPRIMARY_GPS=GPS_SKYTRAQ $(TARGET).CFLAGS += -DPRIMARY_GPS=GPS_SKYTRAQ
endif endif
else else
# plain old single GPS usage # plain old single GPS usage
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_skytraq.h\" $(TARGET).CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_skytraq.h\"
endif endif
</raw> </raw>
</makefile> </makefile>
<makefile target="fbw">
<define name="USE_GPS"/>
</makefile>
</module> </module>
+9 -6
View File
@@ -18,7 +18,7 @@
<init fun="gps_ubx_init()"/> <init fun="gps_ubx_init()"/>
<periodic fun="gps_ubx_periodic_check()" freq="1." autorun="TRUE"/> <periodic fun="gps_ubx_periodic_check()" freq="1." autorun="TRUE"/>
<event fun="gps_ubx_event()"/> <event fun="gps_ubx_event()"/>
<makefile target="ap"> <makefile target="ap|fbw">
<configure name="UBX_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/> <configure name="UBX_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/>
<configure name="UBX_GPS_BAUD" default="$(GPS_BAUD)"/> <configure name="UBX_GPS_BAUD" default="$(GPS_BAUD)"/>
@@ -31,17 +31,20 @@
ifdef SECONDARY_GPS ifdef SECONDARY_GPS
ifneq (,$(findstring $(SECONDARY_GPS), ublox)) ifneq (,$(findstring $(SECONDARY_GPS), ublox))
# this is the secondary GPS # this is the secondary GPS
ap.CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/gps/gps_ubx.h\" $(TARGET).CFLAGS += -DGPS_SECONDARY_TYPE_H=\"subsystems/gps/gps_ubx.h\"
ap.CFLAGS += -DSECONDARY_GPS=GPS_UBX $(TARGET).CFLAGS += -DSECONDARY_GPS=GPS_UBX
else else
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_ubx.h\" $(TARGET).CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_ubx.h\"
ap.CFLAGS += -DPRIMARY_GPS=GPS_UBX $(TARGET).CFLAGS += -DPRIMARY_GPS=GPS_UBX
endif endif
else else
# plain old single GPS usage # plain old single GPS usage
ap.CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_ubx.h\" $(TARGET).CFLAGS += -DGPS_TYPE_H=\"subsystems/gps/gps_ubx.h\"
endif endif
</raw> </raw>
</makefile> </makefile>
<makefile target="fbw">
<define name="USE_GPS"/>
</makefile>
</module> </module>
+1 -1
View File
@@ -18,7 +18,7 @@
<periodic fun="gps_ubx_i2c_periodic()" freq="10."/> <periodic fun="gps_ubx_i2c_periodic()" freq="10."/>
<event fun="GpsUbxi2cEvent()"/> <event fun="GpsUbxi2cEvent()"/>
<makefile target="ap"> <makefile target="ap|fbw">
<configure name="GPS_UBX_I2C_DEV" default="i2c1" case="upper|lower"/> <configure name="GPS_UBX_I2C_DEV" default="i2c1" case="upper|lower"/>
<define name="USE_$(GPS_UBX_I2C_DEV_UPPER)"/> <define name="USE_$(GPS_UBX_I2C_DEV_UPPER)"/>
<define name="GPS_UBX_I2C_DEV" value="$(GPS_UBX_I2C_DEV_LOWER)"/> <define name="GPS_UBX_I2C_DEV" value="$(GPS_UBX_I2C_DEV_LOWER)"/>
+1 -1
View File
@@ -40,7 +40,7 @@ Warning: you still need to tell the driver, which paparazzi port you use.
</header> </header>
<init fun="gps_ubx_ucenter_init()"/> <init fun="gps_ubx_ucenter_init()"/>
<periodic fun="gps_ubx_ucenter_periodic()" start="gps_ubx_ucenter_init()" freq="4." autorun="TRUE"/> <periodic fun="gps_ubx_ucenter_periodic()" start="gps_ubx_ucenter_init()" freq="4." autorun="TRUE"/>
<makefile target="ap"> <makefile target="ap|fbw">
<file name="gps_ubx_ucenter.c"/> <file name="gps_ubx_ucenter.c"/>
<define name="GPS_UBX_UCENTER"/> <define name="GPS_UBX_UCENTER"/>
</makefile> </makefile>
+4
View File
@@ -178,6 +178,10 @@
#define GPS_VECTORNAV_ID 13 #define GPS_VECTORNAV_ID 13
#endif #endif
#ifndef GPS_IMCU_ID
#define GPS_IMCU_ID 14
#endif
/* /*
* IDs of IMU sensors (accel, gyro) * IDs of IMU sensors (accel, gyro)
*/ */
+1 -1
View File
@@ -77,7 +77,7 @@ struct GpsState gps;
struct GpsTimeSync gps_time_sync; struct GpsTimeSync gps_time_sync;
#ifdef SECONDARY_GPS #ifdef SECONDARY_GPS
static uint8_t current_gps_id = 0; static uint8_t current_gps_id = GpsId(PRIMARY_GPS);
#endif #endif
uint8_t multi_gps_mode; uint8_t multi_gps_mode;
@@ -47,6 +47,13 @@ uint8_t imcu_msg_buf[128] __attribute__((aligned)); ///< The InterMCU message b
static struct fbw_status_t fbw_status; static struct fbw_status_t fbw_status;
static inline void intermcu_parse_msg(void (*rc_frame_handler)(void)); static inline void intermcu_parse_msg(void (*rc_frame_handler)(void));
#if IMCU_GPS
#include "std.h"
#include "subsystems/abi.h"
#include "subsystems/gps.h"
static struct GpsState gps_imcu;
#endif
#if PERIODIC_TELEMETRY #if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h" #include "subsystems/datalink/telemetry.h"
@@ -65,6 +72,15 @@ void intermcu_init(void)
{ {
pprz_transport_init(&intermcu.transport); pprz_transport_init(&intermcu.transport);
#if IMCU_GPS
gps_imcu.fix = GPS_FIX_NONE;
gps_imcu.pdop = 0;
gps_imcu.sacc = 0;
gps_imcu.pacc = 0;
gps_imcu.cacc = 0;
gps_imcu.comp_id = GPS_IMCU_ID;
#endif
#if PERIODIC_TELEMETRY #if PERIODIC_TELEMETRY
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_FBW_STATUS, send_status); register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_FBW_STATUS, send_status);
#endif #endif
@@ -79,6 +95,10 @@ void intermcu_periodic(void)
} else { } else {
intermcu.time_since_last_frame++; intermcu.time_since_last_frame++;
} }
#if IMCU_GPS
RunOnceEvery(PERIODIC_FREQUENCY, gps_periodic_check(&gps_imcu));
#endif
} }
/* Enable or disable the communication of the InterMCU */ /* Enable or disable the communication of the InterMCU */
@@ -151,6 +171,44 @@ static inline void intermcu_parse_msg(void (*rc_frame_handler)(void))
telemetry_intermcu_on_msg(0, msg, size); telemetry_intermcu_on_msg(0, msg, size);
break; break;
} }
#if IMCU_GPS
case DL_IMCU_REMOTE_GPS: {
uint32_t now_ts = get_sys_time_usec();
gps_imcu.ecef_pos.x = DL_IMCU_REMOTE_GPS_ecef_x(imcu_msg_buf);
gps_imcu.ecef_pos.y = DL_IMCU_REMOTE_GPS_ecef_y(imcu_msg_buf);
gps_imcu.ecef_pos.z = DL_IMCU_REMOTE_GPS_ecef_z(imcu_msg_buf);
SetBit(gps_imcu.valid_fields, GPS_VALID_POS_ECEF_BIT);
gps_imcu.lla_pos.alt = DL_IMCU_REMOTE_GPS_alt(imcu_msg_buf);
gps_imcu.hmsl = DL_IMCU_REMOTE_GPS_hmsl(imcu_msg_buf);
SetBit(gps_imcu.valid_fields, GPS_VALID_HMSL_BIT);
gps_imcu.ecef_vel.x = DL_IMCU_REMOTE_GPS_ecef_xd(imcu_msg_buf);
gps_imcu.ecef_vel.y = DL_IMCU_REMOTE_GPS_ecef_yd(imcu_msg_buf);
gps_imcu.ecef_vel.z = DL_IMCU_REMOTE_GPS_ecef_zd(imcu_msg_buf);
SetBit(gps_imcu.valid_fields, GPS_VALID_VEL_ECEF_BIT);
gps_imcu.course = DL_IMCU_REMOTE_GPS_course(imcu_msg_buf);
gps_imcu.gspeed = DL_IMCU_REMOTE_GPS_gspeed(imcu_msg_buf);
SetBit(gps_imcu.valid_fields, GPS_VALID_COURSE_BIT);
gps_imcu.pacc = DL_IMCU_REMOTE_GPS_pacc(imcu_msg_buf);
gps_imcu.sacc = DL_IMCU_REMOTE_GPS_sacc(imcu_msg_buf);
gps_imcu.num_sv = DL_IMCU_REMOTE_GPS_numsv(imcu_msg_buf);
gps_imcu.fix = DL_IMCU_REMOTE_GPS_fix(imcu_msg_buf);
// set gps msg time
gps_imcu.last_msg_ticks = sys_time.nb_sec_rem;
gps_imcu.last_msg_time = sys_time.nb_sec;
if (gps_imcu.fix >= GPS_FIX_3D) {
gps_imcu.last_3dfix_ticks = sys_time.nb_sec_rem;
gps_imcu.last_3dfix_time = sys_time.nb_sec;
}
AbiSendMsgGPS(GPS_IMCU_ID, now_ts, &gps_imcu);
break;
}
#endif #endif
@@ -66,10 +66,26 @@ static void intermcu_parse_msg(void (*commands_frame_handler)(void));
static void checkPx4RebootCommand(unsigned char b); static void checkPx4RebootCommand(unsigned char b);
#endif #endif
#ifdef USE_GPS
#ifndef IMCU_GPS_ID
#define IMCU_GPS_ID GPS_MULTI_ID
#endif
#include "subsystems/abi.h"
#include "subsystems/gps.h"
static abi_event gps_ev;
static void gps_cb(uint8_t sender_id, uint32_t stamp, struct GpsState *gps_s);
#endif
void intermcu_init(void) void intermcu_init(void)
{ {
pprz_transport_init(&intermcu.transport); pprz_transport_init(&intermcu.transport);
#if USE_GPS
AbiBindMsgGPS(IMCU_GPS_ID, &gps_ev, gps_cb);
#endif
#ifdef BOARD_PX4IO #ifdef BOARD_PX4IO
px4bl_tid = sys_time_register_timer(10.0, NULL); px4bl_tid = sys_time_register_timer(10.0, NULL);
#endif #endif
@@ -205,6 +221,33 @@ void InterMcuEvent(void (*frame_handler)(void))
} }
} }
#if USE_GPS
static void gps_cb(uint8_t sender_id __attribute__((unused)),
uint32_t stamp __attribute__((unused)),
struct GpsState *gps_s) {
pprz_msg_send_IMCU_REMOTE_GPS(&(intermcu.transport.trans_tx), intermcu.device, INTERMCU_FBW,
&gps_s->ecef_pos.x,
&gps_s->ecef_pos.y,
&gps_s->ecef_pos.z,
&gps_s->lla_pos.alt,
&gps_s->hmsl,
&gps_s->ecef_vel.x,
&gps_s->ecef_vel.y,
&gps_s->ecef_vel.z,
&gps_s->course,
&gps_s->gspeed,
&gps_s->pacc,
&gps_s->sacc,
&gps_s->num_sv,
&gps_s->fix);
}
void gps_periodic_check(struct GpsState *gps_s) {
if (sys_time.nb_sec - gps_s->last_msg_time > GPS_TIMEOUT) {
gps_s->fix = GPS_FIX_NONE;
}
}
#endif
/* SOME STUFF FOR PX4IO BOOTLOADER (TODO: move this code) */ /* SOME STUFF FOR PX4IO BOOTLOADER (TODO: move this code) */
#ifdef BOARD_PX4IO #ifdef BOARD_PX4IO