基于Linux系统,使用906b、907am板卡搭建RTK网络

(文章中提到的挖掘机开发板为linux系统)

概述

一、系统组成

  • NtripSource:用来产生GPS差分数据,并把差分数据提交给NtripServer

  • NtripServer:负责把GPS差分数据提交给NtripCaster

  • NtripCaster:差分数据中心,负责接收、发送GPS差分数据

  • NtripClient:登录NtripCaster后,NtripCaster把GPS差分数据发送给它

二、局域网环境搭建

本次测试在局域网下进行。基站运行在windows端,服务器运行在linux虚拟机端,流动站运行在挖掘机板子(linux系统)上。现在介绍如何将三者配置在一个局域网下。

1、查看windows ip地址:

(1)使用网线连接电脑与挖掘机板子.

(2)查看windows的ip地址

"win+R"打开运行,输入cmd打开命令提示窗口,再输入 ipconfig,

可得windows端ip,此处为169.254.191.97

2、设置挖掘机板子ip地址

在板子上输入以下指令:


ifconfig eth0 169.254.191.98
ifconfig

可以发现,此时板子eth0网卡的ip地址已被设置为169.254.191.98,再输入以下指令:


ping 169.254.191.97

出现上图现象,说明挖掘机板子可以ping通windows,挖掘机板子与windows处于同一子网。

3、设置linux虚拟机ip地址

(1)设置虚拟机网络连接为桥接模式

(2)在虚拟机终端输入以下指令:


ifconfig ens33 169.254.191.99

同挖掘机板子操作相同,linux虚拟机可以ping通挖掘机板子。

自此,基站、服务器、流动站处于同一局域网下。

服务器配置

1、下载ntripcaster

下载地址:ntripcaster-1: Standard Ntrip Broadcaster

2、编译ntripcaster-master

运行


make
make install

默认安装路径为 /user/local

3、配置ntripcaster.conf

将安装路径下 ntripcaster/conf 中的ntripcaster.conf.dist 复制一份,命名为ntripcaster.conf

修改ntripcaster.conf相关参数,例如:


#################################
# NtripCaster configuration file #
################################################################################

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

location BKG
rp_email casteradmin@ifag.de
server_url http://169.254.191.99

########################### 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 123456

#################### 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 SJ-108
#port 80
port 8000

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

logdir /usr/local/ntripcaster/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
/SDJT:user1:password1
4、配置sourcetable.dat

将安装路径下 ntripcaster/conf 中的sourcetable.dat.dist复制一份,命名为sourcetable.dat

填加挂载点相关参数,例如:


STR;SDJT;jinan;RTCM 3;1005(1),1074(1),1077(1),1084(1),1087(1),1124(1),1127(1),1230(1),4072.1(1);2;;;;;;0;0;;none;B;N;560;UBUNTU

具体参数含义可在安装包conf文件夹下的NtripSourcetable.doc文件中查找

4、开启服务器

运行安装路径下 ntripcaster/bin 中的ntripcaster


cd /user/local/ntripcaster/bin
./ntripcaster

基站配置

一、windows环境下基站配置
1、配置基站位置

(1)使用串口助手打开基站串口,向基站发送定位,指令如下:


$cfgprt,,,,4;cfgmsg,2,1005,1;cfgmsg,2,1074,1;cfgmsg,2,1084,1;cfgmsg,2,1114,1;cfgmsg,2,1124,1;cfgtpm,1,,31.901795900,117.263292867,124.689;cfgsave,

$cfgprt,,,,4 //输出 RTCM 协议,关闭 NMEA 协议输出

$cfgmsg,2,1005,1 //输出基准站坐标 1005 语句

$cfgmsg,2,1074,1 //输出 GPS 观测量 1074 语句

$cfgmsg,2,1084,1 //输出 GLONASS 观测量 1084 语句

$cfgmsg,2,1114,1 //输出 QZSS 观测量 1114 语句

$cfgmsg,2,1124,1 //输出 BDS 观测量 1124 语句

$cfgtpm,2,900,,,;cfgsave, //配置定点优化模式,900 秒,并保存配置;

$cfgclr, //恢复出厂设置

31.901795900,117.263292867,124.689 //基站坐标

(2)关闭串口

2、基站通过服务器转发设置

配置完成,点击Start按键,若Input和Output前绿灯闪烁,则说明基站正在向服务器发送数据

二、挖掘机开发板下基站配置
1、将基站位置坐标传入基站串口

新建C文件


vi chuankou.c

程序如下:


//chuankou 基站配置

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <termios.h>
#include <string.h>
#include <sys/ioctl.h>

/*第一部分代码*/
//根据具体的设备修改
const char default_path[] = "/dev/ttyS3";
//const char default_path[] = "/dev/ttyUSB0";  linux虚拟机下适用
// const char default_path[] = "/dev/tty";


int main(int argc, char *argv[])
{
   int fd;
   int res;
   char *path;
   char buf[1024] = "$cfgprt,,,,4;cfgmsg,2,1005,1;cfgmsg,2,1074,1;cfgmsg,2,1084,1;cfgmsg,2,1114,1;cfgmsg,2,1124,1;cfgtpm,1,,31.901795900,117.263292867,124.689;cfgsave,\n";


   /*第二部分代码*/

   //若无输入参数则使用默认终端设备
   if (argc > 1)
      path = argv[1];
   else
      path = (char *)default_path;

   //获取串口设备描述符
   printf("This is tty/usart demo.\n");
   fd = open(path, O_RDWR); //读写打开
   if (fd < 0) {
      printf("Fail to Open %s device\n", path);
      return 0;
   }

   /*第三部分代码*/
   struct termios opt;

   //清空串口接收缓冲区
   tcflush(fd, TCIOFLUSH);
   // 获取串口参数opt
   tcgetattr(fd, &opt);

   //设置串口输出波特率
   cfsetospeed(&opt, B115200);
   //设置串口输入波特率
   cfsetispeed(&opt, B115200);
   //设置数据位数
   opt.c_cflag &= ~CSIZE;
   opt.c_cflag |= CS8;
   //校验位
   opt.c_cflag &= ~PARENB;
   opt.c_iflag &= ~INPCK;
   //设置停止位
   opt.c_cflag &= ~CSTOPB;

   //更新配置
   tcsetattr(fd, TCSANOW, &opt);

   printf("Device %s is set to 115200bps,8N1\n",path);

   /*第四部分代码*/

   do {
      //发送字符串
      write(fd, buf, strlen(buf));

      //接收字符串
      res = read(fd, buf, 1024);
      if (res >0 ) {
      //给接收到的字符串加结束符
      buf[res] = '\0';
      printf("Receive res = %d bytes data: %s\n",res, buf);
          }
} while (res >= 0);

   printf("read error,res = %d",res);

   close(fd);
   return 0;
}

运行以下指令进行交叉编译


arm-linux-gnueabihf-gcc chuankou.c -o chuankou

运行生成的可执行文件 chuankou,接收到到含有ok字符的返回值,说明基站坐标配置成功

可能遇到的问题:

(1)有数据,但没有接收到带有ok的字符.

解决方案:可能是发送的指令格式问题,注意要在指令最后加上”\n“换行符。

2、RTKLIB-rtklib_2.4.3下载地址

GitHub - tomojitakasu/RTKLIB at rtklib_2.4.3

3、交叉编译RTKLIB-rtklib_2.4.3中的str2str

文件位置:RTKLIB-rtklib_2.4.3/app/consapp/str2str/gcc

在makefile中加入


CC = arm-linux-gnueabihf-gcc

make进行编译

4、运行str2str

./str2str -in serial://ttyS3:115200:8:N:1:off -out ntrips://:123456@169.254.191.99:8000/SDJT

流动站配置

一、windows下流动站配置

这里使用梦芯流动站测试软件u-center测试软件。在实际测试中只有u-center可以检测到挂载点,梦芯测试软件只能检测到梦芯服务器上设置的挂载点

1、使用梦芯流动站测试软件

(1)使用CH340连接907am

(2)配置服务器参数

(3)位置源设置为:串口实时位置

(4)运行DGNSS

(5)检查定位数据

定位类型 0未定位 1非差分定位 2差分定位 3浮动 4固定

2、使用u-center测试软件

下载地址:u-center | u-blox

(1)打开串口并设置波特率为115200

(2)打开 NTRIP Client 设置,输入服务器对应参数,点击Update spurce table即可寻找到到设置的挂载点SDJT。

(3)连接成功后打开 Text Console即可得到定位数据。下图所示证明得到RTK固定解。

二、挖掘机板子(linux系统)下流动站配置
1、ntripclient下载地址

ntripclient: RTCM差分数据传输NTRIP协议客户端,可用于连接千寻差分服务,能用于Linux系统

2、交叉编译

修改ntripclient-openwrt-package文件夹下makefile


CC   = arm-linux-gnueabihf-gcc
OPTS = -Wall -O3
ntripclient: ntripclient.c serial.c
        $(CC) $(OPTS) ntripclient.c -o $@

clean:
        $(RM) ntripclient core*


archive:
        zip -9 ntripclient.zip ntripclient.c makefile README serial.c

tgzarchive:
        tar -czf ntripclient.tgz ntripclient.c makefile README serial.c

输入make,开始编译

3、运行ntripclient

./ntripclient --server 192.168.164.128 --port 8000 --mountpoint SDJT -u user1 -p password1 --mode n --nmea "\$GNGGA,034458.00,2810.79928,N,11256.54467,E,2,12,0.64,36.0,M,-12.7,M,1.0,0773*7D" -l logfile.serial -D /dev/ttyS3 -B 115200

其余设置可以在ntripclient-openwrt-package文件夹下README找到

4、日志文件

日志文件保存在ntripclient-openwrt-package文件夹下

5、检查定位数据

(1)日志文件得到RTK固定解

(2)经过解算,得到各点相对于平均值的漂移值,在0-3mm内漂移。

评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值