一、GNSS定位

卫星导航系统由空间段、地面段和用户段三部分组成,可在全球范围内全天候、全天时为各类用户提供高精度、高可靠定位、导航、授时服务,并且具备短报文通信能力,已经初步具备区域导航、定位和授时能力,定位精度为分米、厘米级别,测速精度0.2米/秒,授时精度10纳秒。

GNSS误差因素

  • 与卫星有关
    • 卫星轨道误差
    • 卫星钟差
    • 相对论效应
  • 与传播途径相关
    • 电离层(折射)延迟
    • 对流程(折射)延迟
    • 多路径效应
  • 与接收设备有关
    • 接收机天线相位中心的偏移和变化
    • 接收机钟差
    • 接收机内部噪声
  • 其他影响
    • 地球潮汐
    • 负荷潮

二、原理解析

2.1 RTK差分定位

在利用GPS进行定位时,会受到各种各样因素的影响,为了消除这些误差源,必须使用两台以上的GPS接收机同步工作。GPS静态测量的方法是各个接收机独立观测,然后用后处理软件进行差分解算。那么对于RTK测量来说,仍然是差分解算,只不过是实时的差分计算。

实时动态差分法(Real-time kinematic,RTK,载波相位差分技术):基准站通过数据链将其载波观测量及站坐标信息一同传送给用户站。

用户站接收GPS卫星的载波相位与来自基准站的载波相位,组成相位差分观测值进行处理,计算后给出厘米级的定位结果。

RTK系统主要由三部分组成:

  • 基准站(差分源)
  • 差分数据通信链(网络,电台,3G/4G等)
  • 用户站(终端)

RTK精度影响:

  • 移动站和基站观测到的共同卫星数:RTK精确定位要求要求移动站与基站观测到5颗以上同样的多频段卫星才能实现RTK固定解,观测到越多的卫星就能越快速的得到RTK固定解。
  • 移动站和基站距离:移动站与基站之间的距离有要求,低纬度地区的基站有效覆盖距离小,高纬度地区的距离远;随着移动站与基站的距离增加,误差会越来越大。

RTK解的形式

  • 单点解:是RTK在工作的时候移动站和基准站互相不能联系,接收机未使用任何差分改正信息计算的3D坐标
  • 差分解:是有信号,但由于各种原因,比如卫星数量太少或移动站位置太差,导致交汇数据精确度非常低,一般偏差有几米或者十几二十米
  • 浮点解:精度相对高一点,但其精度一般是不可靠的,定位精度可接近于固定解或到达20-30cm,在城市中获取的一般是浮点解
  • 固定解:是最精确的数据,精度一般在3-5cm

2.2 Ntrip协议

在这里插入图片描述

  • ntrip server:通过某种途径获得到RTK差分信息,然后传送给 Ntrip Caster
  • Ntrip Caster:接收Ntrip Server的差分数据,给ntrip client发送GPS差分数据
  • ntrip client: 向Ntrip Caster申请GPS差分数据,最终实现RTK定位

2.3 NMEA 0183协议

NMEA 0183是美国国家海洋电子协会(National Marine Electronics Association )为海用电子设备制定的标准格式。目前已成了GPS导航设备统一的RTCM(Radio Technical Commission for Maritime services)标准协议。

  • 发送次序:$GPZDA;$GPGGA;$GPGLL;$GPVTG;$GPGSA;$GPGSV*3;$GPRMC

  • 协议采用ASCII码,其串行通信默认参数为:波特率4800bps,数据位8bit,开始位1bit,停止位1bit,无奇偶校验。

三、坐标系

GIS处理的是空间信息,而所有对空间信息的量算都是基于某个坐标系统的,因此GIS中坐标系统的定义是GIS系统的基础,正确理解GIS中的坐标系统就变得尤为重要。

坐标系统又可分为两大类:地理坐标系统、投影坐标系统。

GIS中的坐标系定义由基准面和地图投影两组参数确定,而基准面的定义则由特定椭球体及其对应的转换参数确定,因此欲正确定义GIS系统坐标系,首先必须弄清地球椭球体(Ellipsoid),大地基准面(Datum)及地图投影(Projection)三者的基本概念及它们之间的关系。

详细参考:空间坐标与投影系统系列(一):空间坐标和地图投影

四、应用

计算机(联网)通过Ntrip获取基站的差分信号,然后通过串口喂给北斗板卡,北斗板卡根据接收到的差分信号解算出定位信息并上发,系统通过NMEA 0183协议解析。

4.1 RTKLIB

RTKLIB包含Ntrip协议,用于获取差分信号。

RTKLIB有部分参数在rtklib 2.4.3 b33才支持,win上有编译好的GUI版本,Lnux上有qt版本,但需要手动编译。

安装

apt安装,此处安装并非最新版本,部分参数不支持

sudo apt update
sudo apt install rtklib

源码安装

  • rtklib 2.4.3 p13 stable

git clone https://github.com/tomojitakasu/RTKLIB.git
cd RTKLIB/app
sudo bash makeall.sh
  • rtklib 2.4.3 b33 beta

原作者版本的编译生成cui没问题,生成文件在/usr/local/bin,可直接命令行调用,但qt的gui编译失败,更换JensReimann/rtklib_2.4.3版本,这一版本对qt部分内容进行了修正。

  • tomojitakasu版本(原始作者)
sudo apt-get update
sudo apt install build-essential
sudo apt-get install libpng-dev
sudo apt-get install qt5-default libqt5serialport5-dev

git clone -b rtklib_2.4.3 https://github.com/tomojitakasu/RTKLIB.git
cd RTKLIB/app
sudo make makeall
  • JensReimann版本

安装依赖库

sudo apt-get update
sudo apt install build-essential
sudo apt-get install libpng-dev
sudo apt-get install qt5-default libqt5serialport5-dev 
sudo apt-get install qtwebengine5-dev

编译

qmake
make
    • 编译好后cui命令行调用的在/usr/local/bin下,GUI程序在对应qt目录下。

使用

http://www.rtklib.com/prog/manual_2.4.2.pdf P99,下面参数是rtklib 2.4.3 b33版本的,手册为旧版本说明,参数不全


str2str -in stream[#...] 
		-out stream[#...] [-out stream[#...]...] [options] # 可以多个out,多路输出

OPTIONS

-in stream[#format] input stream path and format 
-out stream[#format] output stream path and format

stream path

serial       : serial://port[:brate[:bsize[:parity[:stopb[:fctr]]]]]
tcp server   : tcpsvr://:port
tcp client   : tcpcli://addr[:port]
ntrip client : ntrip://[user[:passwd]@]addr[:port][/mntpnt]
ntrip server : ntrips://[:passwd@]addr[:port]/mntpnt[:str] (only out)
ntrip caster server: ntripc_s://[:passwd@][:port] (only in)
ntrip caster client: ntripc_c://[user:passwd@][:port]/mntpnt (only out)
file         : [file://]path[::T][::+start][::xseppd][::S=swap]

format

rtcm2        : RTCM 2 (only in)
rtcm3        : RTCM 3
nov          : NovAtel OEMV/4/6,OEMStar (only in)
oem3         : NovAtel OEM3 (only in)
ubx          : ublox LEA-4T/5T/6T (only in)
ss2          : NovAtel Superstar II (only in)
hemis        : Hemisphere Eclipse/Crescent (only in)
stq          : SkyTraq S1315F (only in)
gw10         : Furuno GW10 (only in)
javad        : Javad (only in)
nvs          : NVS BINR (only in)
binex        : BINEX (only in)
rt17         : Trimble RT17 (only in)
sbf          : Septentrio SBF (only in)
cmr          : CMR/CMR+ (only in)
tersus       : TERSUS (only in)

其余辅助命令

-msg \"type[(tint)][,type[(tint)]...]\"
                  rtcm message types and output intervals (s)
-sta sta          station id
-opt opt          receiver dependent options
-s  msec          timeout time (ms) [10000]
-r  msec          reconnect interval (ms) [10000]
-n  msec          nmea request cycle (m) [0]
-f  sec           file swap margin (s) [30]
-c  file          input commands file [no]
-c1 file          output 1 commands file [no]
-c2 file          output 2 commands file [no]
-c3 file          output 3 commands file [no]
-c4 file          output 4 commands file [no]
-p  lat lon hgt   station position (latitude/longitude/height) (deg,m)
-px x y z         station position (x/y/z-ecef) (m)
-a  antinfo       antenna info (separated by ,)
-i  rcvinfo       receiver info (separated by ,)
-o  e n u         antenna offset (e,n,u) (m)
-l  local_dir     ftp/http local directory []
-x  proxy_addr    http/ntrip proxy address [no]
-b  str_no        relay back messages from output str to input str [no]
-t  level         trace level [0]
-ft file          ntrip souce table file []
-fl file          log file [str2str.trace]
-h                print help

4.2 ROS

消息格式

  • sensor_msgs/NavSatFix
# Navigation Satellite fix for any Global Navigation Satellite System
#
# Specified using the WGS 84 reference ellipsoid

# header.stamp specifies the ROS time for this measurement (the
#        corresponding satellite time may be reported using the
#        sensor_msgs/TimeReference message).
#
# header.frame_id is the frame of reference reported by the satellite
#        receiver, usually the location of the antenna.  This is a
#        Euclidean frame relative to the vehicle, not a reference
#        ellipsoid.
Header header

# satellite fix status information
NavSatStatus status

# Latitude [degrees]. Positive is north of equator; negative is south.
float64 latitude

# Longitude [degrees]. Positive is east of prime meridian; negative is west.
float64 longitude

# Altitude [m]. Positive is above the WGS 84 ellipsoid
# (quiet NaN if no altitude is available).
float64 altitude

# Position covariance [m^2] defined relative to a tangential plane
# through the reported position. The components are East, North, and
# Up (ENU), in row-major order.
#
# Beware: this coordinate system exhibits singularities at the poles.

float64[9] position_covariance

# If the covariance of the fix is known, fill it in completely. If the
# GPS receiver provides the variance of each measurement, put them
# along the diagonal. If only Dilution of Precision is available,
# estimate an approximate covariance from that.

uint8 COVARIANCE_TYPE_UNKNOWN = 0
uint8 COVARIANCE_TYPE_APPROXIMATED = 1
uint8 COVARIANCE_TYPE_DIAGONAL_KNOWN = 2
uint8 COVARIANCE_TYPE_KNOWN = 3

uint8 position_covariance_type
  • sensor_msgs/NavSatStatus

  • # Navigation Satellite fix status for any Global Navigation Satellite System
    
    # Whether to output an augmented fix is determined by both the fix
    # type and the last time differential corrections were received.  A
    # fix is valid when status >= STATUS_FIX.
    
    int8 STATUS_NO_FIX =  -1        # unable to fix position
    int8 STATUS_FIX =      0        # unaugmented fix
    int8 STATUS_SBAS_FIX = 1        # with satellite-based augmentation
    int8 STATUS_GBAS_FIX = 2        # with ground-based augmentation
    
    int8 status
    
    # Bits defining which Global Navigation Satellite System signals were
    # used by the receiver.
    
    uint16 SERVICE_GPS =     1
    uint16 SERVICE_GLONASS = 2
    uint16 SERVICE_COMPASS = 4      # includes BeiDou.
    uint16 SERVICE_GALILEO = 8
    
    uint16 service
    

nmea_navsat_driver

解析NMEA协议输出ROS标准定位信息。







  • nmea_topic_serial_reader

通过串口读入nmea数据,发布nmea_sentence (nmea_msgs/Sentence)

~port (string, default: /dev/ttyUSB0)
The device path
~baud (int, default: 4800)
The baud rate to receive NMEA data.
~frame_id (string, default: gps)
The frame_id for the header of the nmea_msgs/Sentence and output message. Will be resolved with tf_prefix if defined.
  • nmea_topic_driver

订阅nmea_sentence (nmea_msgs/Sentence),解析出GPS数据fix(sensor_msgs/NavSatFix)

~time_ref_source (string, default: <the value of ~frame_id>)
The value to use as the source in the sensor_msgs/TimeReference.
~useRMC (bool, default: False)
Whether to generate position fixes from GGA sentences or RMC sentences. If True, fixes will be generated from RMC. If False, fixes will be generated based on the GGA senten

程序解析数据后输出GNSS的经纬度等,时间time_reference,速度vel,部分GGA数据因格式ROS数据格式原因不会解析上发,其中解析形式映射如下

# GGA
# -1,0  STATUS_NO_FIX
# 1     STATUS_FIX
# 2     STATUS_SBAS_FIX
# 4,5,9 STATUS_GBAS_FIX
  • nmea_serial_driver

在实际使用中nmea_serial_driver会因为上发的nmea数据不完整而报错并结束程序,分别独立进行读入和解析更好

直接通过串口读取nmea数据解析发布GPS数据,相当于上面两个一起使用

~port (string, default: /dev/ttyUSB0)
The device path
~baud (int, default: 4800)
The baud rate to receive NMEA data.
~frame_id (string, default: gps)
The frame_id for the header of the sensor_msgs/NavSatFix and geometry_msgs/TwistStamped output messages. Will be resolved with tf_prefix if defined.
~time_ref_source (string, default: <the value of ~frame_id>)
The value to use as the source in the sensor_msgs/TimeReference.
~useRMC (bool, default: False)
Whether to generate position fixes from GGA sentences or RMC sentences. If True, fixes will be generated from RMC. If False, fixes will be generated based on the GGA sentences. Using GGA sentences allows for approximated covariance output while RMC provides velocity information.

gps_common

utm_odometry_node

utm_odometry_node converts latitude-longitude readings into UTM odometry

  • Subscribed Topicsfix (sensor_msgs/NavSatFix): GPS measurement and status

  • Published Topics

    odom (nav_msgs/Odometry): UTM-encoded position

  • Parameters

    ~rot_covariance (double, default: 99999): Variance (in meters) to specify for rotational measurements

    ~frame_id (string, default: Copy frame_id from fix message): Frame to specify in header of outgoing Odometry message

    ~child_frame_id (string): Child frame to specify in header of outgoing Odometry message

五、工程问题

5.1 GPS数据频率

GPS数据整体频率不高,无差分自动上发数据为10Hz左右,通过Ntrip获取的差分数据间隔一般在1-5s(一般设置为1Hz),差分数据用于修正定位误差,过快的频率没必要且会影响解算,但长时间无差分数据会影响定位精度。

5.2 速度获取

速度并不是通过获取两点距离除以时间获得,而是通过多普勒效应 。

The use of GPS in automotive testing is now well established, and Racelogic has been a market leader and innovator for over a decade. GPS systems have revolutionised the accuracy and convenience of testing, development, and validation within the industry. Why and how is it so effective?

There is a common misconception that speed measured via GPS is done so as a function of position against time. If this were the case, GPS velocity would be just about unusable, because GPS position relies on precise measurements of the distance from the receiver to the satellite, and therefore suffers from numerous effects - such as atmospheric interference - which delays the signal.

Fortunately, velocity isn’t measured like this: instead, the Doppler shift in the signals coming from the satellites is captured and this leads to an incredibly accurate measurement of speed.

If you are tracking seven satellites, then this is like having seven police radar guns aimed at you: the measurement is made by taking them all into account.

Doppler-Effect

参考

ntrip协议

NMEA-0183协议详解

rtk 精确定位 简介

什么是RTK?GPS导航和RTK的基本原理有什么不同?

UBUNTU编译运行RTKLIB

nmea_navsat_driver

空间坐标与投影系统系列(一):空间坐标和地图投影

rtklib manual

rtklibexplorer