About importing RTCM3 data of RTK base station in QGC (QGroundControl) 3.4 and forwarding it to the mobile terminal of drone

#ifdef myadd #I added the code between
#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;
                }
            }
        }

The source of RTCM3 data is to convert UBX format to RTCM3 format through RTKLIB software, and send it to QGC via TCP. For steps, please refer to my article.
Also remember to add the header file RTCMMavlink.h

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

If you use it, just add a TCP connection.
Insert picture description here
Application output
Insert picture description here

Published 8 original articles · Like 11 · Visit 2925

Guess you like

Origin blog.csdn.net/weixin_44457020/article/details/103446845