大疆RTK网络和移动站连接

news/2024/11/28 22:45:54/

1.说明

根据大疆开放的api,集成一个rtk定位的功能到我们的软件,两种方式

1.1有一个移动站,基站,让app去连接移动基站,获取gps定位信息

1.2用千寻的网络账号,自定义网络,来获取gps信息

2.效果图:我把项目代码单独抽了rtk功能的代码,运行,测试的效果图,可以拿到gps数据,但是对频有点问题,没有解决

 

3.下载地址:https://github.com/wrs13634194612/DJIRTK

 

4.代码

1.打开rtk模块

       mRtk.setRtkEnabled(isChecked, new CommonCallbacks.CompletionCallback() {@Overridepublic void onResult(DJIError djiError) {}});

2.获取rtk模块的状态,打开或关闭

mRtk.getRtkEnabled(new CommonCallbacks.CompletionCallbackWith<Boolean>() {@Overridepublic void onSuccess(Boolean aBoolean) {//这个东西用来判断是否成功开启RTK//String description2 = "AZ=启用RTK模块: " + aBoolean;//  NettyClient.getInstance().sendMsgToServer(description2);getActivity().runOnUiThread(new Runnable() {@Overridepublic void run() {tv_rtk_status.setText(String.valueOf(aBoolean));  //??这玩意能不能记住我的状态呢}});}

3.设置信号源,移动站或者自定义网络

主要有这几种:根据需求 自行选择

NONENot using any reference station source.
BASE_STATIONRTK is using the D-RTK 2 base station as the reference station.
CUSTOM_NETWORK_SERVICERTK is using third-party network service as the reference station. The network service should use NTRIP(Networked Transport of RTCM via Internet Protocol).
NETWORK_RTKDefault virtual reference station solution to provide cm level accurate position. The frame can be either WGS84 or CGCS 2000. Please note that this default solution can only be used in China. Please add the "djinetworkrtkhelper" to the project via gradle:
implementation 'com.dji:library-networkrtk-helper:1.0' It is only supported by Phantom 4 RTK.
UNKNOWNUnknown reference station source.
    //设置信号源  移动站mRtk.setReferenceStationSource(ReferenceStationSource.BASE_STATION, new CommonCallbacks.CompletionCallback() {@Overridepublic void onResult(DJIError djiError) {}});

4.查看一下当前的信号源是什么

    mRtk.addReferenceStationSourceCallback(new ReferenceStationSource.Callback() {@Overridepublic void onReferenceStationSourceUpdate(ReferenceStationSource referenceStationSource) {// String description3 = "AC=设置RTK信号源-移动站rtk: " + referenceStationSource.toString();//  NettyClient.getInstance().sendMsgToServer(description3);  tv_rtk_sourcegetActivity().runOnUiThread(new Runnable() {@Overridepublic void run() {tv_rtk_source.setText(String.valueOf(referenceStationSource));}});}});

5.拿飞机gps数据,实时刷新

       mRtk.setStateCallback(new RTKState.Callback() {@Overridepublic void onUpdate(RTKState rtkState) {// String description2 = String.valueOf(rtkState.isRTKBeingUsed());changertkstate(rtkState);String description ="A=RTKBeingUsed是否正在使用rtk: " + rtkState.isRTKBeingUsed() + "\n"+ "B=distanceToHomePointDataSource到本站数据源的距离: " + rtkState.getDistanceToHomePointDataSource() + "\n"+ "C=TakeoffAltitudeRecorded,true表示飞机起飞时飞行控制器记录了高度\n: " + rtkState.isTakeoffAltitudeRecorded() + "\n" +"DA=DistanceToHomePointDataSource起始点数据源: " + rtkState.getDistanceToHomePointDataSource() + "\n" +"DA=DistanceToHomePointDataSource起始点数据源Two: " + rtkState.getHomePointDataSource() +"DB=HomePointLocation起始点位置: " + rtkState.getHomePointLocation() + "\n" +"DC=SatelliteCount,GPS或RTK卫星计数: " + rtkState.getSatelliteCount() + "\n"+ "E=TakeOffAltitude起飞高度: " + rtkState.getTakeOffAltitude() + "\n"+ "F=DistanceToHomePoint离家点的距离: " + rtkState.getDistanceToHomePoint() + "\n" +"G=PositioningSolution描述了用于确定定位的方法: " + rtkState.getPositioningSolution() + "\n"+ "H=Error错误信息: " + rtkState.getError() + "\n"+ "I=HeadingValid航向有效性: " + rtkState.isHeadingValid() + "\n" +"J=Heading移动站度数: " + rtkState.getHeading() + "\n"+ "K=HeadingSolution确定精度的方法: " + rtkState.getHeadingSolution() + "\n"+ "L=MobileStationLocation指示RTK位置数据: " + rtkState.getMobileStationLocation() + "\n" +"M=MobileStationAltitude移动台接收器相对于地面系统位置的高度: " + rtkState.getMobileStationAltitude() + "\n"+ "N=MobileStationStandardDeviation以米为单位的定位精度的标准偏差: " + rtkState.getMobileStationStandardDeviation().getStdLatitude()+ "," + rtkState.getMobileStationStandardDeviation().getStdLongitude() + "," + rtkState.getMobileStationStandardDeviation().getStdAltitude() + "\n"+ "O=FusionMobileStationLocation移动台的融合位置: " + rtkState.getFusionMobileStationLocation() + "\n" +"P=FusionMobileStationAltitude移动台的融合高度: " + rtkState.getFusionMobileStationAltitude() + "\n"+ "Q=FusionHeading移动台的融合航向: " + rtkState.getFusionHeading() + "\n"+ "R=BaseStationLocation基站的位置坐标: " + rtkState.getBaseStationLocation() + "\n" +"S=BaseStationAltitude基站在海平面以上的高度: " + rtkState.getBaseStationAltitude() + "\n"+ "T=MobileStationReceiver1GPSInfo单个RTK接收器GPS信息,卫星计数: " + rtkState.getMobileStationReceiver1GPSInfo().getSatelliteCount() + "\n"+ "U=MobileStationReceiver1BeiDouInfo单个RTK接收器北斗信息,卫星计数: " + rtkState.getMobileStationReceiver1BeiDouInfo().getSatelliteCount() + "\n" +"V=MobileStationReceiver1GLONASSInfo 每个接收器连接到单个天线: " + rtkState.getMobileStationReceiver1GLONASSInfo().getSatelliteCount() + "\n"+ "W=MobileStationReceiver1GalileoInfo每个接收器连接到单个天线: " + rtkState.getMobileStationReceiver1GalileoInfo().getSatelliteCount() + "\n"+ "X=MobileStationReceiver2GPSInfo移动台2GPS信息: " + rtkState.getMobileStationReceiver2GPSInfo().getSatelliteCount() + "\n" +"Y=MobileStationReceiver2BeiDouInfo移动台2北斗信息: " + rtkState.getMobileStationReceiver2BeiDouInfo().getSatelliteCount() + "\n"+ "Z=MobileStationReceiver2GLONASSInfo移动台信息: " + rtkState.getMobileStationReceiver2GLONASSInfo().getSatelliteCount() + "\n"+ "ZA=MobileStationReceiver2GalileoInfo移动台信息: " + rtkState.getMobileStationReceiver2GalileoInfo().getSatelliteCount() + "\n" +"ZB=BaseStationReceiverGPSInfo: " + rtkState.getBaseStationReceiverGPSInfo().getSatelliteCount() + "\n"+ "ZC=BaseStationReceiverBeiDouInfo: " + rtkState.getBaseStationReceiverBeiDouInfo().getSatelliteCount() + "\n"+ "ZD=BaseStationReceiverGLONASSInfo: " + rtkState.getBaseStationReceiverGLONASSInfo().getSatelliteCount() + "\n" +"ZE=BaseStationReceiverGalileoInfo: " + rtkState.getBaseStationReceiverGalileoInfo().getSatelliteCount() + "\n"+ "ZF=MobileStationReceiver1GPSInfo: " + rtkState.getMobileStationReceiver1GPSInfo().getSatelliteCount() + "\n"+ "ZG=MobileStationReceiver1BeiDouInfo: " + rtkState.getMobileStationReceiver1BeiDouInfo().getSatelliteCount() + "\n";// NettyClient.getInstance().sendMsgToServer(description);}});

6.获取基站的电池,移动站是否连接,主要看你能不能拿到移动站的电压,能拿到那就是连上了,拿不到就是没连上

    if (ModuleVerificationUtil.isBaseStationAvailable()) {mBaseStation = ((Aircraft) DJISampleApplication.getProductInstance()).getBaseStation();mBaseStation.addBaseStationBatteryStateUpdatedCallback(baseStationBatteryState -> {String description5 ="电压: " + baseStationBatteryState.getVoltage()+ ",电流" + baseStationBatteryState.getCurrent()+ ",电池剩余" + baseStationBatteryState.getCapacityPercent()+ ",温度: " + baseStationBatteryState.getTemperature();//  NettyClient.getInstance().sendMsgToServer(description5);changeDescription2(baseStationBatteryState);});mBaseStation.addBaseStationStateUpdatedCallback(new BaseStationState.Callback() {@Overridepublic void onUpdateBaseStationState(BaseStationState baseStationState) {//添加回调以接收最新的基站状态。 仅受Phantom 4 RTK和M200系列v2支持String description6 ="电压: " + baseStationState.isAllowedToUse()+ ",基站位置类型" + baseStationState.getBaseStationLocationType();getActivity().runOnUiThread(new Runnable() {@Overridepublic void run() {tv_tem5.setText(description6);}});}});}

到这里,移动站的连接就差不多结束了,接下来看看自定义网络的连接

1.切换信号源到网络rtk

  //设置信号源  网络RTKmRtk.setReferenceStationSource(ReferenceStationSource.CUSTOM_NETWORK_SERVICE, new CommonCallbacks.CompletionCallback() {@Overridepublic void onResult(DJIError djiError) {}});

2.查看当前信号源:

      mRtk.addReferenceStationSourceCallback(new ReferenceStationSource.Callback() {@Overridepublic void onReferenceStationSourceUpdate(ReferenceStationSource referenceStationSource) {String description3 = "AC=设置RTK信号源-网络rtk: " + referenceStationSource.toString();//   NettyClient.getInstance().sendMsgToServer(description3);}});

3.设置千寻账号,没有的自己去注册,需要付费

NetworkServiceSettings里面

getServerAddress 地址

getPort  端口号

getUserName  用户名

getPassword 密码

getMountPoint  域名  可以直接设置,测试的时候我是直接写死的数据,实际应用,需要有一个输入框,动态改变数据

      if (ModuleVerificationUtil.isNetRtkAvailable()) {mRTKNetworkServiceProvider = DJISDKManager.getInstance().getRTKNetworkServiceProvider();ipString = etip.getText().toString();mRTKNetworkServiceProvider.setCustomNetworkSettings(new NetworkServiceSettings.Builder().userName("testuser").password("admin123").ip("10.0.19.105").port(9102).mountPoint("MMPT32_GGB").build()); //设置千寻网络地址String description4 = "AD=网络服务的设置IP: "+ mRTKNetworkServiceProvider.getCustomNetworkSettings().getServerAddress()+ ",端口号:" + mRTKNetworkServiceProvider.getCustomNetworkSettings().getPort()+ ",用户名:" + mRTKNetworkServiceProvider.getCustomNetworkSettings().getUserName()+ ",密码:" + mRTKNetworkServiceProvider.getCustomNetworkSettings().getPassword()+ ",域名:" + mRTKNetworkServiceProvider.getCustomNetworkSettings().getMountPoint();// NettyClient.getInstance().sendMsgToServer(description4);}

4.开启网络服务:

         if (ModuleVerificationUtil.isNetRtkAvailable()) {mRTKNetworkServiceProvider = DJISDKManager.getInstance().getRTKNetworkServiceProvider();mRTKNetworkServiceProvider.startNetworkService(new CommonCallbacks.CompletionCallback() {@Overridepublic void onResult(DJIError djiError) {// 启动作为参考站的网络服务//  String description5 = "AE=启用网络服务: " + djiError.toString();//   NettyClient.getInstance().sendMsgToServer(description5);}});}

5.获取连接状态,如果 description5 这个值能拿到  TRANSMITTING 的话,就表示连接成功,就可以拿到数据了

         if (ModuleVerificationUtil.isNetRtkAvailable()) {mRTKNetworkServiceProvider = DJISDKManager.getInstance().getRTKNetworkServiceProvider();mRTKNetworkServiceProvider.addNetworkServiceStateCallback(new NetworkServiceState.Callback() {@Overridepublic void onNetworkServiceStateUpdate(NetworkServiceState networkServiceState) {String description5 = String.valueOf(networkServiceState.getChannelState());//  NettyClient.getInstance().sendMsgToServer(description5);changeDescription(description5);}});}

NetworkServiceChannelState

DISABLEDThe network service is not started.未连接
NETWORK_NOT_REACHABLEThe network is not reachable from the mobile device.
AIRCRAFT_DISCONNECTEDThe aircraft is not connected.
LOGIN_FAILURESDK cannot login with the provided username and password. Check getError.
TRANSMITTINGData is transmitting through the channel.  表示连接上 
DISCONNECTEDThe channel is disconnected and the server is not reachable now. Check getError. 连接失败
ACCOUNT_ERRORUser account error. Check getError.
SERVER_NOT_REACHABLEUnable to connect to server.
CONNECTINGConnecting to server.
SERVICE_SUSPENSIONThe account for network RTK plan A has been expired, please activate plan B.
INVALID_REQUESTThe invalid request is rejected by the server.
UNKNOWNUnknown.

需要源码的,自行下载

end


http://www.ppmy.cn/news/653858.html

相关文章

大疆NAZA飞控win10系统安装疑难图解

第一步&#xff0c;官网一服务与支持一下载中心一产品下载一飞行控制系统一naza系列下载如下两个。安装软件和驱动&#xff0c;安装黑色的&#xff0c;可能弹出如下。 出现这个情况后&#xff0c;将系统时间调整为2014年之前。 右键管理员打开。警告解除&#xff0c;如下图 继…

妙算2使用Onboard-SDK控制大疆210V2无人机(模拟器中 )

一、硬件连接 1.使用无人机自带的USB-USB连接无人机210与电脑&#xff0c;连接方式如下图。大疆210无人机上设置如下图所示: A、绿色三角所指的开关,拨动到靠近USB接口的一侧,也就是现在图片中白色接线的一侧; B:妙算2的串口与大疆210飞控的接口如下面的第二图。 二、例程编…

零度 大疆调试飞行经验

 1,对于支持数据透传飞控,如零度飞控,对于电台的购买,可以自己购买市场上支持透传的无线模块,在满足工作需求的情况下可以很大的节约成本。 1,当飞行器的飞行距离较远,或是天气不好时难以辨认飞行器机头,选择启动智能能方向控制中的航向锁定,或是返航锁定; 2,…

0055. 跳跃游戏

0055. 跳跃游戏 原题链接&#xff1a;完成情况&#xff1a;解题思路&#xff1a;参考代码&#xff1a;__55跳跃游戏01__动态规划__55跳跃游戏01__贪心 原题链接&#xff1a; 0055. 跳跃游戏 https://leetcode-cn.com/problems/jump-game/ 完成情况&#xff1a; 解题思路&…

设计一个高流量高并发的系统需要关注哪些点

1、设计原则 1.1、系统设计原则 在设计一个系统之前&#xff0c;我们先要有一个统一且清晰的认知&#xff1a;不要想着一下就能设计出完美的系统&#xff0c;好的系统是迭代出来的。不要复杂化&#xff0c;要先解决核心问题。但是要有先行的规划&#xff0c;对现有的问题有方…

佳博便携式条码打印机怎么使用_佳博打印机如何设置热敏打印

原标题&#xff1a;佳博打印机如何设置热敏打印 现在市场上标签纸种类比较多&#xff0c;如果你的打印机适合哪种标签纸&#xff0c;你需要在你的打印机上安装对应的标签纸即可&#xff0c;这里以佳博打印机安装热敏纸为例&#xff0c;首选需要在打印机上安装热敏纸&#xff0c…

佳博Gprinter EVA G 打印机驱动

佳博Gprinter EVA G 打印机驱动是官方提供的一款打印机驱动&#xff0c;本站收集提供高速下载&#xff0c;用于解决打印机与电脑连接不了&#xff0c;无法正常使用的问题&#xff0c;本动适用于&#xff1a;Windows XP / Windows 7 / Windows 8 / Windows 10 32/64位操作系统。…

android 佳博蓝牙打印机功能开发

蓝牙自动连接已配对设备 private void connectBluetooth(){BluetoothAdapter mBluetoothAdapter BluetoothAdapter.getDefaultAdapter();Set<BluetoothDevice> pairedDevices mBluetoothAdapter.getBondedDevices();if (pairedDevices.size()!0){for (BluetoothDevice …