使用Pluto SDR实现GPS定位 您所在的位置:网站首页 什么手机可以接收卫星信号 使用Pluto SDR实现GPS定位

使用Pluto SDR实现GPS定位

2024-07-01 21:24| 来源: 网络整理| 查看: 265

你可曾想过GPS全球定位系统是怎么实现米级甚至厘米级的定位的?你可曾好奇过为什么小小手机就可以连接到天上的卫星知晓自己的具体方位?今天我来向大家展示使用Pluto SDR接收GPS信号,实现定位。

所需器材

首先你需要有一个ADI公司推出的Pluto SDR,或是基于Pluto SDR固件的第三方SDR,如果你还没有配置Pluto SDR的运行环境,可以参考我的这一篇文章。

其次你需要一根专门用于接收遥远GPS卫星信号的高增益接收天线,如下图这一根。 在这里插入图片描述 GPS接收天线是有源天线,需要直流馈电,可以使用Bias-Tee实现。 在这里插入图片描述 将RF端与SDR相连,RF+DC端与有源天线相连,最后接上DC直流,即可给天线供电。请一定要在接上负载后再接直流电,否则可能烧毁器件!

配置环境

除了Pluto SDR的运行环境外,还需要安装gnss-sdr,这是一个专门基于SDR设备的全球卫星定位系统库,可以让SDR对接收到的导航数据进行解码,获得准确定位。

首先安装一些依赖:

sudo apt-get install build-essential cmake git pkg-config libboost-dev \ libboost-date-time-dev libboost-system-dev libboost-filesystem-dev \ libboost-thread-dev libboost-chrono-dev libboost-serialization-dev \ libboost-program-options-dev libboost-test-dev liblog4cpp5-dev \ libuhd-dev gnuradio-dev gr-osmosdr libblas-dev liblapack-dev \ libarmadillo-dev libgflags-dev libgoogle-glog-dev libhdf5-dev \ libgnutls-openssl-dev libmatio-dev libpugixml-dev libpcap-dev \ libprotobuf-dev protobuf-compiler libgtest-dev googletest \ python3-mako python3-six

然后拉取源码进行编译:

git clone https://github.com/gnss-sdr/gnss-sdr cd gnss-sdr/build cmake .. make sudo make install volk_profile volk_gnsssdr_profile

实际上你也可以通过包管理器安装gnss-sdr,但是版本很老,从源码编译可以确保安装的是最新版。

验证一下是否安装成功:

gnss-sdr --version

若输出当前版本则安装成功。

测试运行

接下来使用一个本地的卫星数据文件作为输入,验证一下gnss-sdr能否正常工作,这一步不需要真正的设备。若你不想测试,可以直接跳到下一步实机操作。

下载样例数据文件:

mkdir work cd work wget https://sourceforge.net/projects/gnss-sdr/files/data/2013_04_04_GNSS_SIGNAL_at_CTTC_SPAIN.tar.gz tar -zxvf 2013_04_04_GNSS_SIGNAL_at_CTTC_SPAIN.tar.gz

这个数据文件中包含了100秒的原始定位数据,由中心频率1575.42MHz的接收机获取,基带采样速率4MS/s,I/Q双路16-bit数据格式。

接下来将下列文本粘贴到一个新文件中:

[GNSS-SDR] ;######### GLOBAL OPTIONS ################## GNSS-SDR.internal_fs_sps=2000000 ;######### SIGNAL_SOURCE CONFIG ############ SignalSource.implementation=File_Signal_Source SignalSource.filename=/home/your-username/work/data/2013_04_04_GNSS_SIGNAL_at_CTTC_SPAIN.dat SignalSource.item_type=ishort SignalSource.sampling_frequency=4000000 SignalSource.samples=0 ;######### SIGNAL_CONDITIONER CONFIG ############ SignalConditioner.implementation=Signal_Conditioner DataTypeAdapter.implementation=Ishort_To_Complex InputFilter.implementation=Pass_Through InputFilter.item_type=gr_complex Resampler.implementation=Direct_Resampler Resampler.sample_freq_in=4000000 Resampler.sample_freq_out=2000000 Resampler.item_type=gr_complex ;######### CHANNELS GLOBAL CONFIG ############ Channels_1C.count=8 Channels.in_acquisition=8 Channel.signal=1C ;######### ACQUISITION GLOBAL CONFIG ############ Acquisition_1C.implementation=GPS_L1_CA_PCPS_Acquisition Acquisition_1C.item_type=gr_complex Acquisition_1C.pfa=0.01 Acquisition_1C.doppler_max=10000 Acquisition_1C.doppler_step=250 Acquisition_1C.blocking=true ;######### TRACKING GLOBAL CONFIG ############ Tracking_1C.implementation=GPS_L1_CA_DLL_PLL_Tracking Tracking_1C.item_type=gr_complex Tracking_1C.pll_bw_hz=40.0; Tracking_1C.dll_bw_hz=4.0; ;######### TELEMETRY DECODER GPS CONFIG ############ TelemetryDecoder_1C.implementation=GPS_L1_CA_Telemetry_Decoder ;######### OBSERVABLES CONFIG ############ Observables.implementation=Hybrid_Observables ;######### PVT CONFIG ############ PVT.implementation=RTKLIB_PVT PVT.positioning_mode=Single PVT.output_rate_ms=100 PVT.display_rate_ms=500 PVT.iono_model=Broadcast PVT.trop_model=Saastamoinen PVT.flag_rtcm_server=true PVT.flag_rtcm_tty_port=false PVT.rtcm_dump_devname=/dev/pts/1 PVT.rtcm_tcp_port=2101 PVT.rtcm_MT1019_rate_ms=5000 PVT.rtcm_MT1077_rate_ms=1000 PVT.rinex_version=2

注意SIGNAL_SOURCE CONFIG字段第二行需要改为你刚刚下载的数据文件的实际路径。 这个新文件命名为my-first-GNSS-SDR-receiver.conf或其他什么名字,但后缀一定是.conf。

最后进入到数据文件实际所在目录,键入:

gnss-sdr --config_file=./my-first-GNSS-SDR-receiver.conf

-config_file字段后的文件名更改为你的配置文件的实际文件名。

接下来你的控制台会出现:

$ gnss-sdr --config_file=./my-first-GNSS-SDR-receiver.conf Initializing GNSS-SDR v0.0.19 ... Please wait. Logging will be done at "/tmp" Use gnss-sdr --log_dir=/path/to/log to change that. Processing file /home/your-username/work/2013_04_04_GNSS_SIGNAL_at_CTTC_SPAIN.dat, which contains 1600000000 [bytes] GNSS signal recorded time to be processed: 99.999 [s] Starting a TCP/IP server of RTCM messages on port 2101 The TCP/IP server of RTCM messages is up and running. Accepting connections ... ...

等上几秒钟,跟踪到足够多的GPS信号后,就会开始解码GPS传回的数据帧(至少有3个子帧):

... Current receiver time: 14 s New GPS NAV message received in channel 3: subframe 1 from satellite GPS PRN 20 (Block IIR) New GPS NAV message received in channel 0: subframe 1 from satellite GPS PRN 01 (Block IIF) New GPS NAV message received in channel 4: subframe 1 from satellite GPS PRN 32 (Block IIF) New GPS NAV message received in channel 2: subframe 1 from satellite GPS PRN 17 (Block IIR-M) Current receiver time: 15 s Current receiver time: 16 s Current receiver time: 17 s Current receiver time: 18 s Current receiver time: 19 s Current receiver time: 20 s New GPS NAV message received in channel 3: subframe 2 from satellite GPS PRN 02 (Block IIR) New GPS NAV message received in channel 0: subframe 2 from satellite GPS PRN 01 (Block IIF) New GPS NAV message received in channel 4: subframe 2 from satellite GPS PRN 32 (Block IIF) New GPS NAV message received in channel 1: subframe 2 from satellite GPS PRN 11 (Block IIR) New GPS NAV message received in channel 2: subframe 2 from satellite GPS PRN 17 (Block IIR-M) Current receiver time: 21 s Current receiver time: 22 s Current receiver time: 23 s Current receiver time: 24 s Current receiver time: 25 s Current receiver time: 26 s New GPS NAV message received in channel 3: subframe 3 from satellite GPS PRN 20 (Block IIR) New GPS NAV message received in channel 0: subframe 3 from satellite GPS PRN 01 (Block IIF) New GPS NAV message received in channel 4: subframe 3 from satellite GPS PRN 32 (Block IIF) New GPS NAV message received in channel 2: subframe 3 from satellite GPS PRN 17 (Block IIR-M) New GPS NAV message received in channel 1: subframe 3 from satellite GPS PRN 11 (Block IIR) First position fix at 2013-Apr-04 06:23:31.740000 UTC is Lat = 41.2749 [deg], Long = 1.98754 [deg], Height= 100.795 [m] Position at 2013-Apr-04 06:23:32.000000 UTC using 4 observations is Lat = 41.274888307 [deg], Long = 1.987581872 [deg], Height = 86.928 [m] Position at 2013-Apr-04 06:23:32.500000 UTC using 4 observations is Lat = 41.274964746 [deg], Long = 1.987510141 [deg], Height = 90.557 [m] Current receiver time: 27 s Position at 2013-Apr-04 06:23:33.000000 UTC using 4 observations is Lat = 41.274921885 [deg], Long = 1.987605767 [deg], Height = 73.365 [m] Position at 2013-Apr-04 06:23:33.500000 UTC using 4 observations is Lat = 41.274866502 [deg], Long = 1.987553835 [deg], Height = 83.313 [m] Current receiver time: 28 s Position at 2013-Apr-04 06:23:34.000000 UTC using 4 observations is Lat = 41.274904024 [deg], Long = 1.987612510 [deg], Height = 87.615 [m] Position at 2013-Apr-04 06:23:34.500000 UTC using 4 observations is Lat = 41.274877911 [deg], Long = 1.987553312 [deg], Height = 81.405 [m] Current receiver time: 29 s Position at 2013-Apr-04 06:23:35.000000 UTC using 4 observations is Lat = 41.274916750 [deg], Long = 1.987576650 [deg], Height = 108.288 [m] Position at 2013-Apr-04 06:23:35.500000 UTC using 4 observations is Lat = 41.274803167 [deg], Long = 1.987562527 [deg], Height = 90.144 [m] Current receiver time: 30 s Position at 2013-Apr-04 06:23:36.000000 UTC using 4 observations is Lat = 41.275044618 [deg], Long = 1.987619037 [deg], Height = 102.346 [m] Position at 2013-Apr-04 06:23:36.500000 UTC using 4 observations is Lat = 41.274878468 [deg], Long = 1.987557377 [deg], Height = 102.764 [m] Current receiver time: 31 s Position at 2013-Apr-04 06:23:37.000000 UTC using 4 observations is Lat = 41.274995336 [deg], Long = 1.987554843 [deg], Height = 113.653 [m] Position at 2013-Apr-04 06:23:37.500000 UTC using 4 observations is Lat = 41.274951615 [deg], Long = 1.987600581 [deg], Height = 92.064 [m] Current receiver time: 32 s ...

如果最终控制台输出如下内容,恭喜,你已经成功定位了!

... Current receiver time: 1 min 40 s Position at 2013-Apr-04 06:24:45.500000 UTC using 5 observations is Lat = 41.274821613 [deg], Long = 1.987629659 [deg], Height = 69.292 [m] Position at 2013-Apr-04 06:24:46.000000 UTC using 5 observations is Lat = 41.274817101 [deg], Long = 1.987576895 [deg], Height = 43.517 [m] Position at 2013-Apr-04 06:24:46.500000 UTC using 5 observations is Lat = 41.274830209 [deg], Long = 1.987583859 [deg], Height = 54.475 [m] Stopping GNSS-SDR, please wait! Total GNSS-SDR run time: 37.106698 [seconds] GNSS-SDR program ended. Stopping TCP/IP server on port 2101

你可以在当前目录下看到多出来很多的文件,这些就是定位数据文件,需要用专门的软件和地图网页打开,你也可以直接打开其中一些文件,里面存储着你的经纬度和海拔。

实际操作时,大致流程也是如此,首先需要大约半分钟的信号跟踪,跟踪到足够多的卫星后(至少4颗),便开始解析子帧,当至少3个子帧顺利解析后,定位成功,控制台会用不同颜色输出当前经纬度、海拔、三个方向的速度(由于设备固定,一般都是很接近0的数值)。

实机操作

上面这个配置文件只是个实例,实际使用Pluto SDR时需要专门的配置文件,可以从官方仓库找到,这里我们使用基于Pluto SDR的这个配置文件,将其下载到本地。

wget https://raw.githubusercontent.com/gnss-sdr/gnss-sdr/main/conf/gnss-sdr_GPS_L1_plutosdr_realtime.conf

然后指定配置文件运行gnss-sdr:

gnss-sdr --config_file=./gnss-sdr_GPS_L1_plutosdr_realtime.conf

只要GPS天线所处天空足够开阔,天气足够晴朗,很快就能在控制台看到解析子帧的信息,然后就会输出当前的位置,并且当GPS信号跟踪锁定后,哪怕GPS天线移动,定位信息也会持续不断更新,并且会显示出各个方向的移动速度,是不是有点像车辆导航?



【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有