osaet/content/posts/rtcm-1005-parsing.md
yarnom f0b50d13ea feat: add admin publishing workflow and yar theme
Add Go/Postgres admin APIs, Angular admin UI, manual build flow, asset uploads, markdown import/export, configurable slug generation, and the Yar reading theme. Exclude local docs and generated development artifacts from version control.
2026-06-01 15:48:04 +08:00

246 lines
7.1 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
id: 3bbc87e8-55cd-4e53-8589-3fc76f6d746e
slug: rtcm-1005-parsing
title: RTCM 1005 解析
summary: ""
status: published
tags: []
cover: ""
version: 1
slug_source: manual
slug_locked: true
published_at: "2026-01-07T09:27:22+08:00"
created_at: "2024-07-19T13:02:26+08:00"
updated_at: "2026-01-07T09:27:22+08:00"
---
### 前言
RTCM 是一种普遍采用的数据传输格式,它是由国际海运事业无线电技术委员会提出的,用于制定在差分全球导航定位系统和实时动态操作时使用的标准。
下面是技术规范文档:
- [RTCM3.3 c10403.3_all.PDF](https://rtcm.myshopify.com/products/rtcm-10403-3-differential-gnss-global-navigation-satellite-systems-services-version-3-amendment-2-may-20-2021)
- [北云科技技术文档](http://www.bynav.cn/media/upload/cms_15/AN018_RTCM3.2%E6%A0%BC%E5%BC%8F%E8%AF%B4%E6%98%8E_%E5%8C%97%E4%BA%91%E7%A7%91%E6%8A%80.pdf)
第一个文档是官方的,包含了很多的细节,但是需要付费,虽说有其他方式获得,但版权原因还是不在此贴出;
第二个文档是北云科技的,中文文档虽说少了一些细节,但终究方便阅读,虽然本文不会参考它 :)
### 文档解读
RTK的消息类型有很多初看会很懵但在只要找到自己想要了解的消息类型即可在文档的 **3.2 节 Message Type Summary** 中有详细的介绍,本文主要关注 1005 这个消息类型,它由 19 个字节也就是 152 个比特构成,它主要包含基准站位置数据信息,也就是基站的 ECEF 的坐标。
![Screenshot from 2024-08-05 09-41-51.png](https://s2.loli.net/2024/08/05/RaPYsoigDQx9bdJ.png)
在正式阅读之前,还需要了解一下数据结构和类型,在文档的 **3.3节 Data Types** 有详细的介绍:
数据类型很好理解,它规定了数据的范围和构成,后面写程序做转换的时候要严格按照本节的数据结构来实现。
![image.png](https://s2.loli.net/2024/08/05/NnBhPOSTv6WiQXE.png)
下面是这个协议具体的内容, 后面会详细分析:
![image.png](https://s2.loli.net/2024/08/05/wpTWIeMRGxCgiKB.png)
---
### 解算
下面给出一段 RTCM 1005 的原始码流,它是十六进制的 ASCII
````
D3 00 13 3E D7 D3 02 02 98 0E DE EF 34 B4 BD 62 AC 09 41 98 6F 33 36 0B 98
````
在手动计算之前还需要了解一下它在传输时候的格式RTCM 数据以帧的形式的传输
![image.png](https://s2.loli.net/2024/08/05/qzBoWSIQyPXiNL6.png)
- Preamble 同步码8 bits 11010011 ,其十六进制为 'D3'
- Reserved 保留6 bits000000十六进制为 00
- Message Length 长度10 bits数据信息的长度以字节数表示
- Variable Length Data Message0-1023 bytes 可变长数据消息,长度不定,最大 1023 bytes
- CRC校验24 bits
所以 RCTM 1005 每帧大致长这样: **1101 0011 0000 00 + 长度 + 数据 + 校验**
开头固定为 **1101 0011 0000 00** ,十六进制就是 **D30** ,我们再回头看一下原始码流:
````
D3 00 13 3E D7 D3 02 02 98 0E DE EF 34 B4 BD 62 AC 09 41 98 6F 33 36 0B 98
````
前三个十六进制 ASCII 码 我们就能解析出来了,后面紧跟着的是消息长度,它使用 10 个 bit 存储
````D3 00 13
Hex D3 00 13
Binary 1101 0011 0000 0000 0001 0011
````
所以,同步码 + 保留 + 长度 总共就用了 24 个 bit ,也就是 3 个字节
接下来就是可变长度的数据消息了,下面的表格就是 1005 类型的数据内容:
````
DATA FIELD DF NUMBER DATA TYPE NO. OF BITS
-------------------------------------------------------------------------------
Message Number ("1005"=0011 1110 1101) DF002 uint12 12
Reference Station ID DF003 uint12 12
Reserved for ITRF Realization Year DF021 uint6 6
GPS Indicator DF022 bit(1) 1
GLONASS Indicator DF023 bit(1) 1
Reserved for Galileo Indicator DF024 bit(1) 1
Reference-Station Indicator DF141 bit(1) 1
Antenna Reference Point ECEF-X DF025 int38 38
Single Receiver Oscillator Indicator DF142 bit(1) 1
Reserved DF001 bit(1) 1
Antenna Reference Point ECEF-Y DF026 int38 38
Quarter Cycle Indicator DF364 bit(2) 2
Antenna Reference Point ECEF-Z DF027 int38 38
-------------------------------------------------------------------------------
TOTAL 152
````
#### Message Number ("1005"=0011 1110 1101)
它的长度 12 个比特,也就是 3 个 Hex Ascii 码:
```
Hex: 3E D
Bin: 0011 1110 1101
Dec: 1005
```
将十六进制的 3ED Ascii 码转换为 十进制的数字,我们可以看到它正好是 **1005**
#### Reference Station ID
```
Hex: 7 D3
Bin: 0111 1101 0011
Dec: 2003
```
#### Reserved for ITRF Realization Year
Hex02 02
Bin**0000 00**1 00000 0010取前 6 位 ,也就是 0000 00 = 0
#### GPS Indicator
Hex: 02 02
Bin0000 00**1 **00000 0010 (取第 7 位 ,也就是 1
#### GLONASS Indicator
Hex: 02 02
Bin0000 001**0** 0000 0010 (取第 8 位 ,也就是 0
#### Reserved for Galileo Indicator
Hex: 02 02
Bin0000 0010 **0**000 0010 (取第 9 位 ,也就是 0
#### Reference-Station Indicator
Hex: 02 02
Bin0000 0010 0**0**00 0010 (取第 10 位 ,也就是 0
#### Antenna Reference Point ECEF-X
它的长度是 38 bits
Hex 02 98 0E DE EF
Bin: 00**00 0010 1001 1000 0000 1110 1101 1110 1110 1111**
Dec: 11141045999
#### Single Receiver Oscillator Indicator
Hex: 34
Bin: **0**011 0100 (取第 1 位, 也就是0
#### Reserved
Hex: 34
Bin: 0**0**11 0100 (取第 2 位, 也就是0
#### Antenna Reference Point ECEF-Y
它的长度是 38 bits
Hex: 34 B4 BD 62 AC
Bin: 00**11 0100 1011 0100 1011 1101 0110 0010 1010 1100**
二进制最高位是 1 为负数所以要取反再加1
补码: 1**0 1011 0100 1011 0100 0010 1001 1101 0101 0100**
除去第一位的符号位,后面加粗的就是实际的数值
Bin: 0 1011 0100 1011 0100 0010 1001 1101 0101 0100
Hex: 4B 4B 42 9D 54
Dec: 48507297108
加上符号位就是 -48507297108
#### Quarter Cycle Indicator
Hex: 09
Bin: **00** 00 1001取前两位 也就是 00
#### Antenna Reference Point ECEF-Z
Hex : 09 41 98 6F 33
Bin: 00**00 1001 0100 0001 1001 1000 0110 1111 0011 0011**
Dec 39755214643
---
到此为止,手动结算就已完成,若是关注 ECEF XYZ 的取值,则需要回看数据类型,它们的数据类型是 DF025、DF026、DF027
![image.png](https://s2.loli.net/2024/08/05/QcpB6iJHEjxY8Ng.png)
这张图详细地说明了 ECEF XYZ 的数据类型,数据范围,数据处理
其中,它是 int38 的有符号38位整数数据是 0.0001 m
上面我们算得的数,都应做一个处理:
ECEF-X 11141045999 * 0.0001 = 1114104.5999m
ECEF-Y 48507297108*0.0001= -4850729.7108m
ECEF-Z39755214643*0.0001 = 3975521.4643m
(完)