NTRIP 配置及部分基础知识扫盲

题图为为我装设备盒和布电线网线的师傅

本文原为我写的实验室文档

0. 关于GNSS

0.0 何为GNSS

GNSS(global navigation satellite system) 全称全球导航卫星系统.

GPS(Global Positioning System) 全称全球定位系统, 是GNSS的一种实现.

目前世界的定位系统有:

  1. 美国 GPS
  2. 中国 BDS (北斗)
  3. 俄罗斯 GLONASS
  4. 欧盟 Galileo (伽利略, 尚在建造)

0.1 GNSS误差来源

GNSS不间断向大地发送信号, 一般仅需要一个接收器即可使用, 定位误差一般有:

  1. 轨道误差
  2. 时钟误差
  3. 电离层延迟
  4. 对流层延迟
  5. 多径误差
  6. 接收机噪音

误差主要来自电离层

综上, GNSS 误差一般在 10.2m 左右, 手机定位还参考了周围 WIFI/蓝牙等信号, 因此可达 1~4m.

1. 关于RTK

辅助定位方案有很多种, 比如 PPP, RTD, RTK 等等. 综合考虑各种情况, 我选择了 RTK.

RTK(Real Time Kinematic)全称实时动态载波相位差分技术, 可用于高精度, 实时的定位, 一般可达 1~20cm 的定位精度. 理论极限可达毫米级.

1.0 原理

RTK 通过已知确定位置的基站校准流动站位置.

详细参文档第五章.

1.1 组成

RTK需要:

  1. 基站
  2. 流动站
  3. 中间通讯手段

传统的中间通讯手段采用向周围发射关于基站信息的无线电波, 但一般只能覆盖几公里, 且有违法之虞, 又 RTK 基站的理论有效覆盖范围可达 30 公里, 因此有组织提出了 Ntrip 协议.

1.2 Ntrip

Ntrip(Networked Transport of RTCM via Internet Protocol) 全称基于互联网的 RTCM 网络传输协议, 运行流程如下:

有四个主要组成部分:

  1. Client
  2. Caster, 目前未见中文翻译, 拙译为汇总端.
  3. Server
  4. Source

服务端读取源端设备数据, 发送至汇总端, 客户端连接汇总端获取差分数据, 用于校正.

汇总端可将多个服务端数据汇总为一个虚拟基站, 也可以不汇总. 由于只有一个源和一个客户端, 以下讨论皆以单源为准.

1.3 Ntrip部署

Windows 的部署很简单, 使用 U-Center 一套解决.

以下介绍 Caster for Linux 部署, 以树莓派 3b+ 实操.

1.3.0 服务端

使用 RTKlib 的 str2str, 代码位于, 目前最新版本 2.4.3

1
2
3
4
git clone https://github.com/tomojitakasu/RTKLIB.git
cd ./rtklib_2.4.3/app/str2str/gcc
make
sudo cp str2str /usr/bin

str2str 有两个参数, -in 和 -out, 分别可选

1
2
3
4
5
6
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)
file : [file://]path[::T][::+start][::xseppd][::S=swap]

这里只用于从串口读, 并发给汇总端.

1.3.1 汇总端

1
2
3
4
5
git clone https://github.com/thpe/ntripcaster.git
cd ./ntripcaster/ntripcaster0.1.5
./configure –prefix=/opt
make
sudo make install

这时候你可以在 /opt/ 下 bin 中得到 ntripcaster, 并在 conf 下得到两个配置文件, 为了让汇总端读取, 需要重命名

1
2
3
cd /opt/conf
cp ntripcaster.conf.dist ntripcaster.conf
cp sourcetable.dat.dist sourcetable.dat

然后修改 ntripcaster.conf:

server_url后写成http://你的机器IP

encoder_password后改为密码, 尚未测试空密码如何

server_name后起一个随便的名字

port是服务端口, 这里我设置为 8000

这是我当前的配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
##################################
# NtripCaster configuration file #
################################################################################

############### Server Location and Resposible Person ##########################
# Server meta info with no fuctionality.

location BKG
rp_email [email protected]
server_url http://10.18.45.156

########################### Server Limits ######################################
# Maximum number of simultaneous connections.

max_clients 100
max_clients_per_source 100
max_sources 40

######################### Server passwords #####################################
# The "encoder_password" is used from the sources to log in.

encoder_password *********

#################### Server IP/port configuration ##############################
# The server_name specifies the hostname of the server and must not be set to
# an IP-adress. It is very important that server_name resolves to the IP-adress
# the server is running at.
# For every port, the server should listen to, a new port line can be added.

server_name testname
#port 80
port 8000

######################## Main Server Logfile ##################################
# logfile contains information about connections, warnings, errors etc.

logdir /opt/logs
logfile ntripcaster.log

############################ Access Control ###################################
# Here you specify which users have access to which mountpoints,
# one line per mount.
#
# Syntax: /<MOUNTPOINT>:<USER1>:<PASSWORD1>,<USER2>:<PASSWORD2>,...,<USERn>:<PASSWORDn>
#
# /<MOUNTPOINT>: name of the mountpoint. Must start with a slash.
# <USERi>: name of the user that has access to <MOUNTPOINT>.
# <PASSWORDi>: password of <USERi>.
#

# example:
#/mount0:user0:pass0,user1:pass1,user2:pass2
/BUCU0:user1:password1,user2:password2
/PADO0

10.18.45.156是我在内网的IP.

之后需要

修改sourcetable.dat, 添加一行:

1
STR;FFMJ2;Frankfurt;RTCM 3;1(1),3(19),16(59);0;GPS+BEIDOU;GREF;DEU;50.12;8.68;0;1;GPSNet V2.10;none;N;N;560;Demo

挂载点名 FFMJ2

[公式]

, 我的设备使用了 GPS 和 北斗双星定位, 因此写作 GPS+BEIDOU. 其余参数我也还不知道什么意思.

[1] http://yinflying.top/2017/01/274

1.3.2 客户端

目前先用 U-Center, 网上下一个就是了.

1.3.3 运行

首先运行汇总端

1
2
cd /opt/bin/
./ntripcaster

之后是服务端.

首先需要确定基站插在了哪里

1
2
pi@raspberrypi:~ $ ls -l /dev/ttyUSB*
crw-rw---- 1 root dialout 188, 0 7月 19 20:21 /dev/ttyUSB0

在 ttyUSB0 上(写这篇文章的时候我已经拔了), 因此下面写ttyUSB0, 9600 是基站波特率, ****是密码, 10.18.45.156 是设备IP, 8000 是端口, FFMJ2 是挂载点.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
root@raspberrypi:/home/pi# str2str -in serial://ttyUSB0:9600:8:n:1:#stq -out ntrips://:****@10.18.45.156:8000/FFMJ2
stream server start
2019/07/19 13:42:03 [CW---] 0 B 0 bps (0) /dev/ttyUSB0 (1) 10.18.45.156
2019/07/19 13:42:08 [CC---] 652 B 1444 bps (0) /dev/ttyUSB0 (1) 10.18.45.156/FFMJ2
2019/07/19 13:42:13 [CW---] 1324 B 741 bps (0) /dev/ttyUSB0 (1) disconnected
2019/07/19 13:42:18 [CW---] 1852 B 702 bps (0) /dev/ttyUSB0 (1) disconnected
2019/07/19 13:42:23 [CW---] 2928 B 1899 bps (0) /dev/ttyUSB0 (1) send error (111)
2019/07/19 13:42:28 [CW---] 3652 B 1198 bps (0) /dev/ttyUSB0 (1) send error (111)
2019/07/19 13:42:33 [CW---] 4852 B 1198 bps (0) /dev/ttyUSB0 (1) send error (111)
2019/07/19 13:42:38 [CW---] 6166 B 1900 bps (0) /dev/ttyUSB0 (1) send error (111)
2019/07/19 13:42:43 [CW---] 6786 B 987 bps (0) /dev/ttyUSB0 (1) 10.18.45.156
2019/07/19 13:42:48 [CW---] 7914 B 1651 bps (0) /dev/ttyUSB0 (1) 10.18.45.156
2019/07/19 13:42:53 [CW---] 8390 B 247 bps (0) /dev/ttyUSB0 (1) timeout
2019/07/19 13:42:58 [CW---] 8814 B 454 bps (0) /dev/ttyUSB0 (1) timeout
2019/07/19 13:43:03 [CC---] 9486 B 742 bps (0) /dev/ttyUSB0 (1) 10.18.45.156/FFMJ2
2019/07/19 13:43:08 [CC---] 9900 B 494 bps (0) /dev/ttyUSB0 (1) 10.18.45.156/FFMJ2
2019/07/19 13:43:13 [CC---] 10448 B 1445 bps (0) /dev/ttyUSB0 (1) 10.18.45.156/FFMJ2
2019/07/19 13:43:18 [CC---] 11172 B 744 bps (0) /dev/ttyUSB0 (1) 10.18.45.156/FFMJ2
2019/07/19 13:43:23 [CC---] 12020 B 952 bps (0) /dev/ttyUSB0 (1) 10.18.45.156/FFMJ2
2019/07/19 13:43:28 [CW---] 12620 B 949 bps (0) /dev/ttyUSB0 (1) recv error (115)
2019/07/19 13:43:33 [CW---] 13416 B 2187 bps (0) /dev/ttyUSB0 (1) recv error (115)
2019/07/19 13:43:38 [CW---] 14378 B 701 bps (0) /dev/ttyUSB0 (1) 10.18.45.156
2019/07/19 13:43:43 [CW---] 14874 B 742 bps (0) /dev/ttyUSB0 (1) 10.18.45.156
2019/07/19 13:43:48 [CW---] 15598 B 1443 bps (0) /dev/ttyUSB0 (1) timeout
2019/07/19 13:43:53 [CW---] 16312 B 1196 bps (0) /dev/ttyUSB0 (1) timeout
2019/07/19 13:43:58 [CC---] 16736 B 989 bps (0) /dev/ttyUSB0 (1) 10.18.45.156/FFMJ2
2019/07/19 13:44:03 [CC---] 17760 B 1729 bps (0) /dev/ttyUSB0 (1) 10.18.45.156/FFMJ2
2019/07/19 13:44:08 [CC---] 18712 B 952 bps (0) /dev/ttyUSB0 (1) 10.18.45.156/FFMJ2
2019/07/19 13:44:13 [CC---] 19550 B 2147 bps (0) /dev/ttyUSB0 (1) 10.18.45.156/FFMJ2
2019/07/19 13:44:18 [CC---] 19964 B 702 bps (0) /dev/ttyUSB0 (1) 10.18.45.156/FFMJ2
2019/07/19 13:44:23 [CC---] 21040 B 1443 bps (0) /dev/ttyUSB0 (1) 10.18.45.156/FFMJ2
2019/07/19 13:44:28 [CC---] 22136 B 1689 bps (0) /dev/ttyUSB0 (1) 10.18.45.156/FFMJ2
2019/07/19 13:44:33 [CC---] 22994 B 1237 bps (0) /dev/ttyUSB0 (1) 10.18.45.156/FFMJ2
2019/07/19 13:44:38 [CC---] 23770 B 701 bps (0) /dev/ttyUSB0 (1) 10.18.45.156/FFMJ2

服务端成功连接后, 汇总端有输出

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
root@raspberrypi:/opt/bin# ./ntripcaster
NtripCaster Version 0.1.5 Initializing...
NtripCaster comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of NtripCaster under the terms of the
GNU General Public License.
For more information about these matters, see the file named COPYING.
Starting thread engine...
[19/Jul/2019:21:45:54] NtripCaster Version 0.1.5 Starting..
[19/Jul/2019:21:45:54] Using stdout as NtripCaster logging window
[19/Jul/2019:21:45:54] Starting main connection handler...
[19/Jul/2019:21:46:14] WARNING: Resolving the server name [testname] does not work!
[19/Jul/2019:21:46:14] Listening on port 8000...
[19/Jul/2019:21:46:14] Using 'testname' as servername...
[19/Jul/2019:21:46:14] Server limits: 100 clients, 100 clients per source, 40 sources
[19/Jul/2019:21:46:14] Starting Calender Thread...
[19/Jul/2019:21:46:14] Bandwidth:0.000000KB/s Sources:0 Clients:0
[19/Jul/2019:21:46:14] Accepted encoder on mountpoint /FFMJ2 from 10.18.45.156. 2 sources connected
[19/Jul/2019:21:46:14] Accepted encoder on mountpoint /AB0 from 10.18.45.156. 2 sources connected
[19/Jul/2019:21:46:14] Kicking source 0 [10.18.45.156] [Source signed off (killed itself)] [encoder], connected for 0 seconds, 0 bytes transfered. 1 sources connected
[19/Jul/2019:21:46:14] Kicking all 0 clients for source 0
[19/Jul/2019:21:46:14] Kicking source 1 [10.18.45.156] [Source signed off (killed itself)] [encoder], connected for 0 seconds, 0 bytes transfered. 0 sources connected
[19/Jul/2019:21:46:14] Kicking all 0 clients for source 1

转移到 Windows 上, 打开 U-Center, Receiver->NTRIP Client...->填入各项信息, 用户名为空, 单击更新源表, 在下拉框里选择FFMJ2, 之后确定.

查看 Fix Mode, 很快, 就到了 3D/DGNSS/FIXED, 按 F12, 查看定位结果.

关于硬件配置购买及修改, 明日待续.


吐槽: 今天为了连接眼前三十厘米的树莓派, 我先笔记本从从手机热点将数据转送到北京的服务器, 然后服务器转发到校园网我的路由器, 路由器转发到运行frp的台式, 台式转发到同在校园网的树莓派,, 数据发过去一次要跑1600km, 回来又要跑1600km, fong了

作者

myuan

发布于

2019-07-23

更新于

2024-06-04

许可协议

评论