Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[modules] Support dual ublox GPS modules #3267

Merged
merged 4 commits into from
May 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 7 additions & 0 deletions conf/airframes/tudelft/rot_wing_v3g.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@
<define name="AIRSPEED_UAVCAN_SEND_ABI" value="0" /> <!-- Read Airspeed for logging but do not use it -->
</module>
<module name="air_data"/>

<configure name="PRIMARY_GPS" value="ublox"/>
<configure name="SECONDARY_GPS" value="ublox2"/>
<module name="gps" type="ublox">
<configure name="UBX_GPS_BAUD" value="B460800"/>
<configure name="UBX2_GPS_BAUD" value="B460800"/>
<define name="USE_GPS_UBX_RTCM" value="TRUE"/>
</module>

Expand Down Expand Up @@ -333,6 +337,9 @@
<define name="USE_AIRSPEED" value="TRUE"/>
<define name="NAV_HYBRID_MAX_DECELERATION" value="0.5"/>
<define name="ROTWING_STATE_USE_ROTATION_REF_MODEL" value="TRUE"/>
<define name="INS_EKF2_FUSION_MODE" value="(MASK_USE_GPS|MASK_USE_GPSYAW)"/>
<define name="INS_EKF2_GPS_YAW_OFFSET" value="0"/>
<define name="MULTI_GPS_MODE" value="PRIMARY_GPS"/>
</section>

<section name="GROUND_DETECT">
Expand Down
7 changes: 7 additions & 0 deletions conf/airframes/tudelft/rot_wing_v3h.xml
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,12 @@
<define name="AIRSPEED_UAVCAN_SEND_ABI" value="0" /> <!-- Read Airspeed for logging but do not use it -->
</module>
<module name="air_data"/>

<configure name="PRIMARY_GPS" value="ublox"/>
<configure name="SECONDARY_GPS" value="ublox2"/>
<module name="gps" type="ublox">
<configure name="UBX_GPS_BAUD" value="B460800"/>
<configure name="UBX2_GPS_BAUD" value="B460800"/>
<define name="USE_GPS_UBX_RTCM" value="TRUE"/>
</module>

Expand Down Expand Up @@ -333,6 +337,9 @@
<define name="USE_AIRSPEED" value="TRUE"/>
<define name="NAV_HYBRID_MAX_DECELERATION" value="0.5"/>
<define name="ROTWING_STATE_USE_ROTATION_REF_MODEL" value="TRUE"/>
<define name="INS_EKF2_FUSION_MODE" value="(MASK_USE_GPS|MASK_USE_GPSYAW)"/>
<define name="INS_EKF2_GPS_YAW_OFFSET" value="0"/>
<define name="MULTI_GPS_MODE" value="PRIMARY_GPS"/>
</section>

<section name="GROUND_DETECT">
Expand Down
6 changes: 5 additions & 1 deletion conf/boards/cube_orangeplus.makefile
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,14 @@ RADIO_CONTROL_SPEKTRUM_PRIMARY_PORT ?= UART3
MODEM_PORT ?= UART2
MODEM_BAUD ?= B57600

# The GPS1 port (UART8 is GPS2)
# The GPS1 port
GPS_PORT ?= UART4
GPS_BAUD ?= B57600

# The GPS2 port
GPS2_PORT ?= UART8
GPS2_BAUD ?= B57600

# InterMCU port connected to the IO processor
INTERMCU_PORT ?= UART6
INTERMCU_BAUD ?= B1500000
Expand Down
50 changes: 34 additions & 16 deletions conf/modules/gps_ublox.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<settings>
<dl_settings>
<dl_settings name="gps_ublox">
<dl_setting MIN="1" MAX="3" STEP="1" values="Hotstart|Warmstart|Coldstart" module="gps/gps_ubx" VAR="gps_ubx.reset" shortname="reset"/>
<dl_setting MIN="1" MAX="3" STEP="1" values="Hotstart|Warmstart|Coldstart" module="gps/gps_ubx" VAR="gps_ubx_reset" shortname="reset"/>
</dl_settings>
</dl_settings>
</settings>
Expand All @@ -36,33 +36,51 @@
<event fun="gps_ubx_event()"/>
<datalink message="HITL_UBX" fun="gps_ubx_parse_HITL_UBX(buf)"/>
<makefile target="ap|fbw">
<configure name="UBX_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/>
<configure name="UBX_GPS_BAUD" default="$(GPS_BAUD)"/>

<file name="gps_ubx.c"/>

<!-- GPS Ublox 1 -->
<configure name="UBX_GPS_PORT" default="$(GPS_PORT)" case="upper|lower"/>
<configure name="UBX_GPS_BAUD" default="$(GPS_BAUD)"/>
<define name="USE_$(UBX_GPS_PORT_UPPER)"/>
<define name="UBX_GPS_LINK" value="$(UBX_GPS_PORT_LOWER)"/>
<define name="UBX_GPS_PORT" value="$(UBX_GPS_PORT_LOWER)"/>
<define name="$(UBX_GPS_PORT_UPPER)_BAUD" value="$(UBX_GPS_BAUD)"/>

<!-- GPS Ublox 2 -->
<configure name="UBX2_GPS_PORT" default="$(GPS2_PORT)" case="upper|lower"/>
<configure name="UBX2_GPS_BAUD" default="$(GPS2_BAUD)"/>
<define name="USE_$(UBX2_GPS_PORT_UPPER)" cond="ifneq ($(UBX2_GPS_PORT)$(SECONDARY_GPS),)"/>
<define name="UBX2_GPS_PORT" value="$(UBX2_GPS_PORT_LOWER)" cond="ifneq ($(UBX2_GPS_PORT)$(SECONDARY_GPS),)"/>
<define name="$(UBX2_GPS_PORT_UPPER)_BAUD" value="$(UBX2_GPS_BAUD)" cond="ifneq ($(UBX2_GPS_BAUD)$(SECONDARY_GPS),)"/>
<define name="GPS_UBX_NB" value="2" cond="ifneq ($(UBX2_GPS_PORT)$(SECONDARY_GPS),)"/>

<raw>
ifdef SECONDARY_GPS
ifneq (,$(findstring $(SECONDARY_GPS), ublox))
# this is the secondary GPS
$(TARGET).CFLAGS += -DGPS_SECONDARY_TYPE_H=\"modules/gps/gps_ubx.h\"
$(TARGET).CFLAGS += -DSECONDARY_GPS=GPS_UBX
else
$(TARGET).CFLAGS += -DGPS_TYPE_H=\"modules/gps/gps_ubx.h\"
$(TARGET).CFLAGS += -DPRIMARY_GPS=GPS_UBX
endif
ifneq (,$(findstring ublox2, $(SECONDARY_GPS)))
# this is the secondary GPS
$(TARGET).CFLAGS += -DGPS_SECONDARY_TYPE_H=\"modules/gps/gps_ubx.h\"
$(TARGET).CFLAGS += -DSECONDARY_GPS=GPS_UBX2
else ifneq (,$(findstring ublox, $(SECONDARY_GPS)))
# this is the secondary GPS
$(TARGET).CFLAGS += -DGPS_SECONDARY_TYPE_H=\"modules/gps/gps_ubx.h\"
$(TARGET).CFLAGS += -DSECONDARY_GPS=GPS_UBX
endif

ifneq (,$(findstring ublox2, $(PRIMARY_GPS)))
$(TARGET).CFLAGS += -DGPS_TYPE_H=\"modules/gps/gps_ubx.h\"
$(TARGET).CFLAGS += -DPRIMARY_GPS=GPS_UBX2
else ifneq (,$(findstring ublox, $(PRIMARY_GPS)))
$(TARGET).CFLAGS += -DGPS_TYPE_H=\"modules/gps/gps_ubx.h\"
$(TARGET).CFLAGS += -DPRIMARY_GPS=GPS_UBX
endif
else
# plain old single GPS usage
$(TARGET).CFLAGS += -DGPS_TYPE_H=\"modules/gps/gps_ubx.h\"
# plain old single GPS usage
$(TARGET).CFLAGS += -DGPS_TYPE_H=\"modules/gps/gps_ubx.h\"
endif
</raw>
<test>
<define name="PRIMARY_GPS" value="GPS_UBX"/>
<define name="USE_UART2"/>
<define name="UBX_GPS_LINK" value="uart2"/>
<define name="UBX_GPS_PORT" value="uart2"/>
</test>
</makefile>
</module>
Expand Down
2 changes: 1 addition & 1 deletion conf/modules/gps_ubx_ucenter.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Warning: you still need to tell the driver, which paparazzi port you use.
<file name="gps_ubx_ucenter.c"/>
<define name="GPS_UBX_UCENTER"/>
<test>
<define name="UBX_GPS_LINK" value="uart2"/>
<define name="UBX_GPS_PORT" value="uart2"/>
<define name="USE_UART2"/>
</test>
</makefile>
Expand Down
4 changes: 4 additions & 0 deletions sw/airborne/modules/core/abi_sender_ids.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,10 @@
#define GPS_DW1000_ID 15
#endif

#ifndef GPS_UBX2_ID
#define GPS_UBX2_ID 16
#endif

/*
* IDs of IMU sensors (accel, gyro)
*/
Expand Down
22 changes: 0 additions & 22 deletions sw/airborne/modules/gps/gps.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ PRINT_CONFIG_VAR(SECONDARY_GPS)
struct GpsState gps;
struct GpsTimeSync gps_time_sync;
struct GpsRelposNED gps_relposned;
struct RtcmMan rtcm_man;

#ifdef SECONDARY_GPS
static uint8_t current_gps_id = GpsId(PRIMARY_GPS);
Expand Down Expand Up @@ -175,17 +174,6 @@ static void send_gps_rtk(struct transport_tx *trans, struct link_device *dev)
&gps_relposned.gnssFixOK);
}

static void send_gps_rxmrtcm(struct transport_tx *trans, struct link_device *dev)
{
pprz_msg_send_GPS_RXMRTCM(trans, dev, AC_ID,
&rtcm_man.Cnt105,
&rtcm_man.Cnt177,
&rtcm_man.Cnt187,
&rtcm_man.Crc105,
&rtcm_man.Crc177,
&rtcm_man.Crc187);
}

static void send_gps_int(struct transport_tx *trans, struct link_device *dev)
{
#if PPRZLINK_DEFAULT_VER == 2 && GPS_POS_BROADCAST
Expand Down Expand Up @@ -364,22 +352,12 @@ void gps_init(void)
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_GPS_SOL, send_gps_sol);
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_SVINFO, send_svinfo);
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_GPS_RTK, send_gps_rtk);
register_periodic_telemetry(DefaultPeriodic, PPRZ_MSG_ID_GPS_RXMRTCM, send_gps_rxmrtcm);
#endif

/* Register preflight checks */
#if PREFLIGHT_CHECKS
preflight_check_register(&gps_pfc, gps_preflight);
#endif

// Initializing counter variables to count the number of Rtcm msgs in the input stream(for each msg type)
rtcm_man.Cnt105 = 0;
rtcm_man.Cnt177 = 0;
rtcm_man.Cnt187 = 0;
// Initializing counter variables to count the number of messages that failed Crc Check
rtcm_man.Crc105 = 0;
rtcm_man.Crc177 = 0;
rtcm_man.Crc187 = 0;
}

uint32_t gps_tow_from_sys_ticks(uint32_t sys_ticks)
Expand Down
14 changes: 3 additions & 11 deletions sw/airborne/modules/gps/gps.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,8 @@ struct GpsRelposNED {
int8_t relPosHPN;
int8_t relPosHPE;
int8_t relPosHPD;
float relPosLength;
float relPosHeading;
uint32_t accN;
uint32_t accE;
uint32_t accD;
Expand All @@ -141,17 +143,7 @@ struct GpsRelposNED {
uint8_t diffSoln;
uint8_t gnssFixOK;
};

struct RtcmMan {
uint16_t RefStation;
uint16_t MsgType; // Counter variables to count the number of Rtcm msgs in the input stream(for each msg type)
uint32_t Cnt105;
uint32_t Cnt177;
uint32_t Cnt187; // Counter variables to count the number of messages that failed Crc Check
uint32_t Crc105;
uint32_t Crc177;
uint32_t Crc187;
};
extern struct GpsRelposNED gps_relposned;

/** global GPS state */
extern struct GpsState gps;
Expand Down