Paparazzi UAS v7.1_unstable
Paparazzi is a free software Unmanned Aircraft System.
Loading...
Searching...
No Matches
gps_ubx.c File Reference
#include "modules/gps/gps_ubx.h"
#include "modules/core/abi.h"
#include "pprzlink/dl_protocol.h"
#include "led.h"
#include <math.h>
#include "ubx_protocol.h"
Include dependency graph for gps_ubx.c:

Go to the source code of this file.

Macros

#define USE_GPS_UBX_RTCM   0
#define DEBUG_PRINT(...)
#define UNINIT   0
 Includes macros generated from ubx.xml.
#define GOT_SYNC1   1
#define GOT_SYNC2   2
#define GOT_CLASS   3
#define GOT_ID   4
#define GOT_LEN1   5
#define GOT_LEN2   6
#define GOT_PAYLOAD   7
#define GOT_CHECKSUM1   8
#define RXM_RTCM_VERSION   0x02
#define NAV_RELPOSNED_VERSION   0x01
#define NAV_DAHEADING_VERSION   0x02
#define NAV_DAHEADING_REF_ID   0xFFFF
 RELPOS reference id used for the dual-antenna heading.
#define GPS_UBX_HEADING_BASELINE   0.
 Distance between the two antennas of a heading receiver [m] (dual-antenna or moving base), 0 to not check it.
#define GPS_UBX_HEADING_BASELINE_TOL   0.4
 Largest difference between the measured and the configured antenna distance [m].
#define GPS_UBX_HEADING_BASELINE_MAX   10.
 Longest antenna distance for which a heading is used when GPS_UBX_HEADING_BASELINE is not set [m] (as PX4).
#define GPS_UBX_ERR_NONE   0
#define GPS_UBX_ERR_OVERRUN   1
#define GPS_UBX_ERR_MSG_TOO_LONG   2
#define GPS_UBX_ERR_CHECKSUM   3
#define GPS_UBX_ERR_UNEXPECTED   4
#define GPS_UBX_ERR_OUT_OF_SYNC   5
#define UTM_HEM_NORTH   0
#define UTM_HEM_SOUTH   1
#define GPS_UBX_BOOTRESET   0
#define CFG_RST_Reset_Hardware   0x00
#define CFG_RST_Reset_Controlled   0x01
#define CFG_RST_Reset_Controlled_GPS_only   0x02
#define CFG_RST_Reset_Controlled_GPS_stop   0x08
#define CFG_RST_Reset_Controlled_GPS_start   0x09
#define CFG_RST_BBR_Hotstart   0x0000
#define CFG_RST_BBR_Warmstart   0x0001
#define CFG_RST_BBR_Coldstart   0xffff
#define gps_ubx_ucenter_event()

Functions

void gps_ubx_parse (struct GpsUbx *gubx, uint8_t c)
void gps_ubx_msg (struct GpsUbx *gubx)
void gps_ubx_init (void)
void gps_ubx_event (void)
void gps_ubx_parse_HITL_UBX (uint8_t *buf)
static void gps_ubx_parse_nav_pvt (struct GpsUbx *gubx)
static void gps_ubx_parse_nav_sol (struct GpsUbx *gubx)
static void gps_ubx_parse_nav_posecef (struct GpsUbx *gubx)
static void gps_ubx_parse_nav_posllh (struct GpsUbx *gubx)
static void gps_ubx_parse_nav_posutm (struct GpsUbx *gubx)
static void gps_ubx_parse_velecef (struct GpsUbx *gubx)
static void gps_ubx_parse_nav_velned (struct GpsUbx *gubx)
static void gps_ubx_parse_nav_svinfo (struct GpsUbx *gubx)
static void gps_ubx_parse_nav_sat (struct GpsUbx *gubx)
static void gps_ubx_parse_nav_status (struct GpsUbx *gubx)
static bool gps_ubx_heading_baseline_ok (double distance)
 A receiver can report a fixed and valid heading on a wrong carrier phase solution (seen indoors with the antennas tens of meters apart).
static void gps_ubx_parse_nav_relposned (struct GpsUbx *gubx)
static void gps_ubx_parse_nav_daheading (struct GpsUbx *gubx)
void gps_ubx_read_message (struct GpsUbx *gubx)
static void ubx_send_1byte (struct link_device *dev, uint8_t byte)
void ubx_header (struct link_device *dev, uint8_t nav_id, uint8_t msg_id, uint16_t len)
void ubx_trailer (struct link_device *dev)
void ubx_send_bytes (struct link_device *dev, uint8_t len, uint8_t *bytes)
void ubx_send_cfg_rst (struct link_device *dev, uint16_t bbr, UNUSED uint8_t reset_mode)
void gps_ubx_periodic_check (void)
void gps_ublox_write (struct link_device *dev, uint8_t *buff, uint32_t n)

Variables

struct GpsUbx gps_ubx [GPS_UBX_NB] = {0}
uint8_t gps_ubx_reset = 0

Macro Definition Documentation

◆ CFG_RST_BBR_Coldstart

#define CFG_RST_BBR_Coldstart   0xffff

Definition at line 134 of file gps_ubx.c.

Referenced by gps_ubx_event().

◆ CFG_RST_BBR_Hotstart

#define CFG_RST_BBR_Hotstart   0x0000

Definition at line 132 of file gps_ubx.c.

Referenced by gps_ubx_event().

◆ CFG_RST_BBR_Warmstart

#define CFG_RST_BBR_Warmstart   0x0001

Definition at line 133 of file gps_ubx.c.

Referenced by gps_ubx_event().

◆ CFG_RST_Reset_Controlled

#define CFG_RST_Reset_Controlled   0x01

Definition at line 127 of file gps_ubx.c.

Referenced by gps_ubx_event().

◆ CFG_RST_Reset_Controlled_GPS_only

#define CFG_RST_Reset_Controlled_GPS_only   0x02

Definition at line 128 of file gps_ubx.c.

◆ CFG_RST_Reset_Controlled_GPS_start

#define CFG_RST_Reset_Controlled_GPS_start   0x09

Definition at line 130 of file gps_ubx.c.

◆ CFG_RST_Reset_Controlled_GPS_stop

#define CFG_RST_Reset_Controlled_GPS_stop   0x08

Definition at line 129 of file gps_ubx.c.

◆ CFG_RST_Reset_Hardware

#define CFG_RST_Reset_Hardware   0x00

Definition at line 126 of file gps_ubx.c.

◆ DEBUG_PRINT

#define DEBUG_PRINT ( ...)
Value:
{}

Definition at line 50 of file gps_ubx.c.

Referenced by gps_ubx_event().

◆ GOT_CHECKSUM1

#define GOT_CHECKSUM1   8

Definition at line 65 of file gps_ubx.c.

◆ GOT_CLASS

#define GOT_CLASS   3

Definition at line 60 of file gps_ubx.c.

Referenced by gps_ubx_parse(), and ubx_process().

◆ GOT_ID

#define GOT_ID   4

Definition at line 61 of file gps_ubx.c.

◆ GOT_LEN1

#define GOT_LEN1   5

Definition at line 62 of file gps_ubx.c.

◆ GOT_LEN2

#define GOT_LEN2   6

Definition at line 63 of file gps_ubx.c.

◆ GOT_PAYLOAD

#define GOT_PAYLOAD   7

Definition at line 64 of file gps_ubx.c.

◆ GOT_SYNC1

#define GOT_SYNC1   1

Definition at line 58 of file gps_ubx.c.

◆ GOT_SYNC2

#define GOT_SYNC2   2

Definition at line 59 of file gps_ubx.c.

◆ GPS_UBX_BOOTRESET

#define GPS_UBX_BOOTRESET   0

Definition at line 123 of file gps_ubx.c.

Referenced by gps_ubx_init().

◆ GPS_UBX_ERR_CHECKSUM

#define GPS_UBX_ERR_CHECKSUM   3

Definition at line 90 of file gps_ubx.c.

Referenced by gps_ubx_parse(), and ubx_process().

◆ GPS_UBX_ERR_MSG_TOO_LONG

#define GPS_UBX_ERR_MSG_TOO_LONG   2

Definition at line 89 of file gps_ubx.c.

Referenced by gps_ubx_parse(), and ubx_process().

◆ GPS_UBX_ERR_NONE

#define GPS_UBX_ERR_NONE   0

Definition at line 87 of file gps_ubx.c.

Referenced by gps_ubx_init().

◆ GPS_UBX_ERR_OUT_OF_SYNC

#define GPS_UBX_ERR_OUT_OF_SYNC   5

Definition at line 92 of file gps_ubx.c.

Referenced by gps_ubx_parse(), and ubx_process().

◆ GPS_UBX_ERR_OVERRUN

#define GPS_UBX_ERR_OVERRUN   1

Definition at line 88 of file gps_ubx.c.

Referenced by gps_ubx_parse(), and gps_ubx_parse_HITL_UBX().

◆ GPS_UBX_ERR_UNEXPECTED

#define GPS_UBX_ERR_UNEXPECTED   4

Definition at line 91 of file gps_ubx.c.

Referenced by gps_ubx_parse(), and ubx_process().

◆ GPS_UBX_HEADING_BASELINE

#define GPS_UBX_HEADING_BASELINE   0.

Distance between the two antennas of a heading receiver [m] (dual-antenna or moving base), 0 to not check it.

Definition at line 74 of file gps_ubx.c.

Referenced by gps_ubx_heading_baseline_ok().

◆ GPS_UBX_HEADING_BASELINE_MAX

#define GPS_UBX_HEADING_BASELINE_MAX   10.

Longest antenna distance for which a heading is used when GPS_UBX_HEADING_BASELINE is not set [m] (as PX4).

Definition at line 84 of file gps_ubx.c.

Referenced by gps_ubx_heading_baseline_ok().

◆ GPS_UBX_HEADING_BASELINE_TOL

#define GPS_UBX_HEADING_BASELINE_TOL   0.4

Largest difference between the measured and the configured antenna distance [m].

Definition at line 79 of file gps_ubx.c.

Referenced by gps_ubx_heading_baseline_ok().

◆ gps_ubx_ucenter_event

#define gps_ubx_ucenter_event ( void)
Value:
{}

Definition at line 762 of file gps_ubx.c.

Referenced by gps_ubx_msg().

◆ NAV_DAHEADING_REF_ID

#define NAV_DAHEADING_REF_ID   0xFFFF

RELPOS reference id used for the dual-antenna heading.

Definition at line 70 of file gps_ubx.c.

Referenced by gps_ubx_parse_nav_daheading().

◆ NAV_DAHEADING_VERSION

#define NAV_DAHEADING_VERSION   0x02

Definition at line 69 of file gps_ubx.c.

Referenced by gps_ubx_parse_nav_daheading().

◆ NAV_RELPOSNED_VERSION

#define NAV_RELPOSNED_VERSION   0x01

Definition at line 68 of file gps_ubx.c.

Referenced by gps_ubx_parse_nav_relposned().

◆ RXM_RTCM_VERSION

#define RXM_RTCM_VERSION   0x02

Definition at line 67 of file gps_ubx.c.

◆ UNINIT

#define UNINIT   0

Includes macros generated from ubx.xml.

Definition at line 57 of file gps_ubx.c.

◆ USE_GPS_UBX_RTCM

#define USE_GPS_UBX_RTCM   0

Definition at line 29 of file gps_ubx.c.

◆ UTM_HEM_NORTH

#define UTM_HEM_NORTH   0

Definition at line 94 of file gps_ubx.c.

◆ UTM_HEM_SOUTH

#define UTM_HEM_SOUTH   1

Definition at line 95 of file gps_ubx.c.

Referenced by gps_ubx_parse_nav_posutm().

Function Documentation

◆ gps_ublox_write()

void gps_ublox_write ( struct link_device * dev,
uint8_t * buff,
uint32_t n )

Definition at line 809 of file gps_ubx.c.

References dev.

◆ gps_ubx_event()

void gps_ubx_event ( void )

◆ gps_ubx_heading_baseline_ok()

bool gps_ubx_heading_baseline_ok ( double distance)
static

A receiver can report a fixed and valid heading on a wrong carrier phase solution (seen indoors with the antennas tens of meters apart).

The measured antenna distance shows it, while the INS can't tell.

Definition at line 454 of file gps_ubx.c.

References GPS_UBX_HEADING_BASELINE, GPS_UBX_HEADING_BASELINE_MAX, and GPS_UBX_HEADING_BASELINE_TOL.

Referenced by gps_ubx_parse_nav_daheading(), and gps_ubx_parse_nav_relposned().

Here is the caller graph for this function:

◆ gps_ubx_init()

void gps_ubx_init ( void )

◆ gps_ubx_msg()

◆ gps_ubx_parse()

◆ gps_ubx_parse_HITL_UBX()

void gps_ubx_parse_HITL_UBX ( uint8_t * buf)

This code simulates gps_ubx.c:parse_ubx()

Definition at line 185 of file gps_ubx.c.

References gps_ubx, and GPS_UBX_ERR_OVERRUN.

◆ gps_ubx_parse_nav_daheading()

◆ gps_ubx_parse_nav_posecef()

void gps_ubx_parse_nav_posecef ( struct GpsUbx * gubx)
static

◆ gps_ubx_parse_nav_posllh()

void gps_ubx_parse_nav_posllh ( struct GpsUbx * gubx)
static

◆ gps_ubx_parse_nav_posutm()

void gps_ubx_parse_nav_posutm ( struct GpsUbx * gubx)
static

◆ gps_ubx_parse_nav_pvt()

◆ gps_ubx_parse_nav_relposned()

◆ gps_ubx_parse_nav_sat()

void gps_ubx_parse_nav_sat ( struct GpsUbx * gubx)
static

◆ gps_ubx_parse_nav_sol()

◆ gps_ubx_parse_nav_status()

void gps_ubx_parse_nav_status ( struct GpsUbx * gubx)
static

Definition at line 438 of file gps_ubx.c.

References GpsState::fix, GPS_FIX_3D, GpsUbx::msg_buf, GpsUbx::state, GpsUbx::status_flags, and GpsState::tow.

Referenced by gps_ubx_read_message().

Here is the caller graph for this function:

◆ gps_ubx_parse_nav_svinfo()

void gps_ubx_parse_nav_svinfo ( struct GpsUbx * gubx)
static

Definition at line 382 of file gps_ubx.c.

References SVinfo::azim, SVinfo::cno, SVinfo::elev, SVinfo::flags, GPS_NB_CHANNELS, Min, GpsUbx::msg_buf, GpsState::nb_channels, SVinfo::qi, GpsUbx::state, SVinfo::svid, and GpsState::svinfos.

Referenced by gps_ubx_read_message().

Here is the caller graph for this function:

◆ gps_ubx_parse_nav_velned()

void gps_ubx_parse_nav_velned ( struct GpsUbx * gubx)
static

◆ gps_ubx_parse_velecef()

void gps_ubx_parse_velecef ( struct GpsUbx * gubx)
static

◆ gps_ubx_periodic_check()

void gps_ubx_periodic_check ( void )

Definition at line 797 of file gps_ubx.c.

References gps_periodic_check(), gps_ubx, GPS_UBX_NB, and state.

Here is the call graph for this function:

◆ gps_ubx_read_message()

◆ ubx_header()

void ubx_header ( struct link_device * dev,
uint8_t nav_id,
uint8_t msg_id,
uint16_t len )

Definition at line 717 of file gps_ubx.c.

References dev, gps_ubx, GPS_UBX_NB, and ubx_send_1byte().

Here is the call graph for this function:

◆ ubx_send_1byte()

void ubx_send_1byte ( struct link_device * dev,
uint8_t byte )
static

Definition at line 705 of file gps_ubx.c.

References dev, gps_ubx, and GPS_UBX_NB.

Referenced by ubx_header(), and ubx_send_bytes().

Here is the caller graph for this function:

◆ ubx_send_bytes()

void ubx_send_bytes ( struct link_device * dev,
uint8_t len,
uint8_t * bytes )

Definition at line 746 of file gps_ubx.c.

References dev, and ubx_send_1byte().

Here is the call graph for this function:

◆ ubx_send_cfg_rst()

void ubx_send_cfg_rst ( struct link_device * dev,
uint16_t bbr,
UNUSED uint8_t reset_mode )

Definition at line 754 of file gps_ubx.c.

References dev, and UNUSED.

Referenced by gps_ubx_event().

Here is the caller graph for this function:

◆ ubx_trailer()

void ubx_trailer ( struct link_device * dev)

Definition at line 734 of file gps_ubx.c.

References dev, gps_ubx, and GPS_UBX_NB.

Variable Documentation

◆ gps_ubx

◆ gps_ubx_reset

uint8_t gps_ubx_reset = 0

Definition at line 98 of file gps_ubx.c.

Referenced by gps_ubx_event(), and gps_ubx_init().