关于在QGC(QGroundControl) 3.4里导入RTK基站的RTCM3数据并转发至无人机移动端这件事

#ifdef myadd
#endif
之间的代码是我加的

void MAVLinkProtocol::receiveBytes(LinkInterface* link, QByteArray b)
{
    // Since receiveBytes signals cross threads we can end up with signals in the queue
    // that come through after the link is disconnected. For these we just drop the data
    // since the link is closed.
    if (!_linkMgr->containsLink(link)) {
        return;
    }

//    receiveMutex.lock();
    mavlink_message_t message;
    mavlink_status_t status;

    int mavlinkChannel = link->mavlinkChannel();

    static int nonmavlinkCount = 0;
    static bool checkedUserNonMavlink = false;
    static bool warnedUserNonMavlink = false;

    for (int position = 0; position < b.size(); position++) {
        unsigned int decodeState = mavlink_parse_char(mavlinkChannel, (uint8_t)(b[position]), &message, &status);

        if (decodeState == 0 && !link->decodedFirstMavlinkPacket())
        {
            nonmavlinkCount++;
#ifdef myadd
            if (b[0]==0xD3&&b[1]==0x00){
                qDebug() <<"now it is on b1"<<b;
             RTCMMavlink * mavlink123 = new RTCMMavlink(*_toolbox);
              int blength =b.size();
              QByteArray message(b, blength);
              mavlink123->RTCMDataUpdate(message);
              break;
                   }
#endif
            if (nonmavlinkCount > 1000 && !warnedUserNonMavlink)
            {
                // 500 bytes with no mavlink message. Are we connected to a mavlink capable device?
                if (!checkedUserNonMavlink)
                {
                    link->requestReset();
                    checkedUserNonMavlink = true;
                }
                else
                {
                    warnedUserNonMavlink = true;
                    // Disconnect the link since its some other device and
                    // QGC clinging on to it and feeding it data might have unintended
                    // side effects (e.g. if its a modem)
                    qDebug() << "disconnected link" << link->getName() << "as it contained no MAVLink data";
#ifdef myadd
                    if (b[0]==0xD3&&b[1]==0x00){
                        qDebug() <<"now it is on b2"<<b;
                        RTCMMavlink * mavlink1234 = new RTCMMavlink(*_toolbox);
                        int blength2 =b.size();
                         QByteArray message2(b, blength2);
                        mavlink1234->RTCMDataUpdate(message2);
						break;
#endif
                    }
                  else{
                        QMetaObject::invokeMethod(_linkMgr, "disconnectLink", Q_ARG( LinkInterface*, link ) );
                    }
                        return;
                }
            }
        }

RTCM3数据来源是通过RTKLIB的软件将UBX格式转换成RTCM3格式,并且通过TCP发送到QGC,步骤参考我的文章
此外记得添加头文件RTCMMavlink.h

#define myadd
#ifdef myadd
#include "qgroundcontrol/src/GPS/RTCM/RTCMMavlink.h"
#endif

使用的话添加一个TCP连接就好了
在这里插入图片描述
应用程序输出
在这里插入图片描述

  • 0
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值