QGC开发 显示双GPS/RTK信息以及自定义页面(ubuntu)

2023-05-16

一、QGC开发 显示双GPS/RTK信息

1. 在sitl中进行仿真,虚拟出第二个GPS mavlink发送到地面站。

在这里插入图片描述

如下图中,在mavlink_msg_gps2_raw.h中找到发送第二组gps/rtk数据函数mavlink_msg_gps2_raw_send()发送,由于第一组已经有在发送,故只加入第二组。
在这里插入图片描述
发送代码如下:

    mavlink_msg_gps2_raw_send  (
        chan,
        last_fix_time_ms(0)*(uint64_t)1000,
        status(0),
        loc.lat,        // in 1E7 degrees
        loc.lng,        // in 1E7 degrees
        loc.alt * 10UL, // in mm
        get_hdop(0),
        get_vdop(0),
        ground_speed(0)*100,  // cm/s
        ground_course(0)*100, // 1/100 degrees,
        num_sats(0),
        0,                    // TODO: Elipsoid height in mm
        0);   
        

2. 在QGC工程中加入解析第二个gps/rtl那包。

主要改了三个文件以及添加一个文件:分别为FirmwarePlugin.ccVehicle.ccVehicle.h + GPS2Indicator.qml
FirmwarePlugin.cc中如图中加入:

_toolBarIndicatorList.append(QVariant::fromValue(QUrl::fromUserInput("qrc:/toolbar/GPS2Indicator.qml")));

在这里插入图片描述

  • Vehicle.h 中,首先加入一个class
class VehicleGPS2FactGroup : public FactGroup
{
    Q_OBJECT

public:
    VehicleGPS2FactGroup(QObject* parent = nullptr);

    Q_PROPERTY(Fact* lat                READ lat                CONSTANT)
    Q_PROPERTY(Fact* lon                READ lon                CONSTANT)
    Q_PROPERTY(Fact* hdop               READ hdop               CONSTANT)
    Q_PROPERTY(Fact* vdop               READ vdop               CONSTANT)
    Q_PROPERTY(Fact* courseOverGround   READ courseOverGround   CONSTANT)
    Q_PROPERTY(Fact* count              READ count              CONSTANT)
    Q_PROPERTY(Fact* lock               READ lock               CONSTANT)

    Fact* lat               (void) { return &_latFact; }
    Fact* lon               (void) { return &_lonFact; }
    Fact* hdop              (void) { return &_hdopFact; }
    Fact* vdop              (void) { return &_vdopFact; }
    Fact* courseOverGround  (void) { return &_courseOverGroundFact; }
    Fact* count             (void) { return &_countFact; }
    Fact* lock              (void) { return &_lockFact; }

    static const char* _latFactName;
    static const char* _lonFactName;
    static const char* _hdopFactName;
    static const char* _vdopFactName;
    static const char* _courseOverGroundFactName;
    static const char* _countFactName;
    static const char* _lockFactName;

private:
    Fact        _latFact;
    Fact        _lonFact;
    Fact        _hdopFact;
    Fact        _vdopFact;
    Fact        _courseOverGroundFact;
    Fact        _countFact;
    Fact        _lockFact;
};

  • 再加入一些,声明:(由于改的部分比较零散,故用直接看git改的内容)
    在这里插入图片描述
  • Vehicle.cc中加入mavlink解析函数:
    在这里插入图片描述
  • 加入:
    在这里插入图片描述在这里插入图片描述

3. 最后新建一个qml文件

在这里插入图片描述
—>
在这里插入图片描述然后把下面的内容复制粘贴进去:

/****************************************************************************
 *
 *   (c) 2009-2016 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/

import QtQuick          2.11
import QtQuick.Layouts  1.11

import QGroundControl                       1.0
import QGroundControl.Controls              1.0
import QGroundControl.MultiVehicleManager   1.0
import QGroundControl.ScreenTools           1.0
import QGroundControl.Palette               1.0

//-------------------------------------------------------------------------
//-- GPS Indicator
Item {
    id:             _root
    width:          (gps2ValuesColumn.x + gps2ValuesColumn.width) * 1.1
    anchors.top:    parent.top
    anchors.bottom: parent.bottom

    Component {
        id: gps2Info

        Rectangle {
            width:  gps2Col.width   + ScreenTools.defaultFontPixelWidth  * 3 //宽度
            height: gps2Col.height  + ScreenTools.defaultFontPixelHeight * 2 //高度
            radius: ScreenTools.defaultFontPixelHeight * 0.5                //半径
            color:  qgcPal.window                                           //颜色
            border.color:   qgcPal.text                                     //加边框

            Column {
                id:                 gps2Col
                spacing:            ScreenTools.defaultFontPixelHeight * 0.5
                width:              Math.max(gps2Grid.width, gps2Label.width)
                anchors.margins:    ScreenTools.defaultFontPixelHeight
                anchors.centerIn:   parent                                   // anchors.centerIn:parent,是将子控件放在父控件的正中心

                QGCLabel {
                    id:             gps2Label
                    text:           (activeVehicle && activeVehicle.gps2.count.value >= 0) ? qsTr("GPS Status") : qsTr("GPS Data Unavailable")
                    font.family:    ScreenTools.demiboldFontFamily          // 字体
                    anchors.horizontalCenter: parent.horizontalCenter       // 水平居中
                }

                GridLayout {
                    id:                 gps2Grid
                    visible:            (activeVehicle && activeVehicle.gps2.count.value >= 0)
                    anchors.margins:    ScreenTools.defaultFontPixelHeight
                    columnSpacing:      ScreenTools.defaultFontPixelWidth
                    anchors.horizontalCenter: parent.horizontalCenter
                    columns: 2

                    QGCLabel { text: qsTr("GPS Count:") }
                    QGCLabel { text: activeVehicle ? activeVehicle.gps2.count.valueString : qsTr("N/A", "No data to display") }
                    QGCLabel { text: qsTr("GPS Lock:") }
                    QGCLabel { text: activeVehicle ? activeVehicle.gps2.lock.enumStringValue : qsTr("N/A", "No data to display") }
                    QGCLabel { text: qsTr("HDOP:") }
                    QGCLabel { text: activeVehicle ? activeVehicle.gps2.hdop.valueString : qsTr("--.--", "No data to display") }
                    QGCLabel { text: qsTr("VDOP:") }
                    QGCLabel { text: activeVehicle ? activeVehicle.gps2.vdop.valueString : qsTr("--.--", "No data to display") }
                    QGCLabel { text: qsTr("Course Over Ground:") }
                    QGCLabel { text: activeVehicle ? activeVehicle.gps2.courseOverGround.valueString : activeVehicle.gps2.courseOverGround.valueString }
                }
            }
        }
    }

    QGCColoredImage {
        id:                 gps2Icon
        width:              height
        anchors.top:        parent.top
        anchors.bottom:     parent.bottom
        source:             "/qmlimages/Gps.svg"
        fillMode:           Image.PreserveAspectFit
        sourceSize.height:  height
        opacity:            (activeVehicle && activeVehicle.gps2.count.value >= 0) ? 1 : 0.5
        color:              qgcPal.buttonText
    }

    Column {
        id:                     gps2ValuesColumn
        anchors.verticalCenter: parent.verticalCenter
        anchors.leftMargin:     ScreenTools.defaultFontPixelWidth / 2
        anchors.left:           gps2Icon.right

        QGCLabel {
            anchors.horizontalCenter:   hdopValue.horizontalCenter
            visible:                    activeVehicle && !isNaN(activeVehicle.gps2.hdop.value)
            color:                      qgcPal.buttonText
            text:                       activeVehicle ? activeVehicle.gps2.count.valueString : ""
        }

        QGCLabel {
            id:         hdopValue
            visible:    activeVehicle && !isNaN(activeVehicle.gps2.hdop.value)
            color:      qgcPal.buttonText
            text:       activeVehicle ? activeVehicle.gps2.hdop.value.toFixed(1) : ""
        }
    }

    MouseArea {
        anchors.fill:   parent
        onClicked: {
            mainWindow.showPopUp(_root, gps2Info)
        }
    }
}

然后debug即可:
在这里插入图片描述
出现了两个GPS,由于在飞控中发下来的数据一模一样,所以存在两个一样,为了验证没问题,去飞控把下发的卫星数量改下。
把卫星改为40颗

    mavlink_msg_gps2_raw_send  (
        chan,
        last_fix_time_ms(0)*(uint64_t)1000,
        status(0),
        loc.lat,        // in 1E7 degrees
        loc.lng,        // in 1E7 degrees
        loc.alt * 10UL, // in mm
        get_hdop(0),
        get_vdop(0),
        ground_speed(0)*100,  // cm/s
        ground_course(0)*100, // 1/100 degrees,
        40,
        0,                    // TODO: Elipsoid height in mm
        0);   

第二个卫星显示是40,故接收以及显示成功:
在这里插入图片描述
完成

二、自定义页面

用到的文件为:MainRootWindow.qmlMainToolBar.qml
效果如下图,功能可后续扩展:
在这里插入图片描述

如下图,新建myadd.qml

在这里插入图片描述


import QtQuick                  2.11
import QtQuick.Controls         2.4
import QtQuick.Layouts          1.11
import QtQuick.Dialogs          1.3
import QtQuick.Controls.Styles  1.4
import QtLocation               5.3
import QtPositioning            5.3

import QGroundControl                       1.0
import QGroundControl.Controls              1.0
import QGroundControl.ScreenTools           1.0
import QGroundControl.Palette               1.0
import QGroundControl.FlightMap             1.0
import QGroundControl.QGCMapEngineManager   1.0
import QGroundControl.FactSystem            1.0
import QGroundControl.FactControls          1.0

Rectangle{
    id:         myRect
    color:      "red"
    visible:     true
    x:          100
    y:          100
    width:      100
    height:     100
    Text {
        id: myTest
        text: qsTr("!!!!!")
        color: "blue"
        font.pointSize: 20
    }

MainRootWindow.qml中加入内容如下图:

在这里插入图片描述

MainToolBar.qml中加入

在这里插入图片描述

            QGCToolBarButton {
                id:                 addmyButton
                anchors.top:        parent.top
                anchors.bottom:     parent.bottom
                icon.source:        "/qmlimages/Plan.svg"
                onClicked: {
                    checked = true
                    mainWindow.showmyaddview()
                }
            }

编译后完成

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

QGC开发 显示双GPS/RTK信息以及自定义页面(ubuntu) 的相关文章

随机推荐

  • phpExcel的使用方法以及导入导出实例【转载】

    一 下载PHPExcel 下载地址 xff1a https github com PHPOffice PHPExcel 二 读取Excel文件内容插入数据库 lt php require once 39 Classes PHPExcel p
  • 关于git 、初识git (fatal: Not a valid object name: 'master'.)

    主要错误原因是因为没有master分支 必须要commit一次 才可以有master分支 才可以创建别的分支 具体步骤 1 打开命令行 git add index html 2 git commit m 34 this is a test
  • 关于git的使用

    查看https blog csdn net qq 42072311 article details 80696886 https blog csdn net kevindgk article details 51606925 查看这两个博客
  • php使用upload封装类上传文件

    原文https blog csdn net navioo article details 51777799
  • phpStorm2018安装与破解(免安装打包版)

    首先将我为大家事先准备好的打包文件拷贝至软件安装盘 xff0c 本人安装于D盘 xff0c 所以这里已本人安装破解的过程进行讲述 1 gt phpStorm2018 2 2下载请转至链接 https pan baidu com s 1Kno
  • 最简洁的麦克纳姆轮原理与控制方法

    最简洁的麦克纳姆轮控制原理与控制方法 0 写在前面 对于第一次接触麦轮的小伙伴们肯定是没办法十分清晰地想象出麦轮底盘的各种运动该如何控制的 而在实际使用中 xff0c 麦轮的运动灵活性与控制难度之比又非常高 xff0c 可以说是在比较平整的
  • Nuttx下移植uorb笔记

    Nuttx下移植uorb笔记 之前接触过ros下的消息机制 xff08 生产者 消费者 xff09 模型 xff0c 第一感觉是灵活好用 xff0c 但是在资源有限的嵌入式环境里面 xff0c 邮箱 消息 显得就有点不那么灵活 xff0c
  • 关于ADRC算法以及参数整定(调参)的一些心得体会

    关于ADRC算法以及参数整定 xff08 调参 xff09 的一些心得体会 ADRC xff0c 全称叫做Active Disturbance Rejection Control xff0c 中文名是自抗扰控制技术 这项控制算法是由中科院的
  • boa-0.94.13:CGI中文问题

    为什么中文乱码 用win7 自带的浏览器ie 打开服务器的cgi form html xff0c 在Name 输入框输入 汉字 两个字 xff0c 提交服务器 如图1 图1 返回的是结果为 xff1a Server Got you para
  • 跑通VINS-Fusion全流程

    跑通VINS Fusion全流程 常规安装步骤详见官方1 ROS安装2 ceres solver安装3 VINS Fusion安装4 KITTI数据集下载5 跑通KITTI数据集 常规安装步骤详见官方 https github com HK
  • 带GPS的SLAM数据集汇总

    1 带GPS的相关SLAM数据集 Kitti 部分带部分不带 xff0c 看网站写的很详细 xff0c 数据集很常用 http www cvlibs net datasets kitti eval odometry php CMU Visu
  • 跑通GVINS——港科大新作

    跑通GVINS 港科大新作 0 简介1 环境2 跑通GVINS3 数据集4 相关资料打包下载 xff08 不包括数据集 xff09 6 泡泡机器人解读 港科大又一力作 xff01 vins mono以及vins fusion升级版GVINS
  • GVINS文章暴力翻译(仅供自学)

    GVINS文章暴力翻译 xff08 仅供自学 xff09 摘要1 介绍2 相关工作3 符号和定义A 框架b 状态 4 GNSS基本介绍A GNSS 概述B 伪距测量C 多普勒测量D SPP算法 5 系统概述6 概率公式A 地图估计B 惯性因
  • Vins-fusion用到的kitti数据集轨迹对不齐,使用evo -a转换

    kitti数据集基准问题 下面两个图一个是转换前 xff0c 一个是evo a 转换后的 问题描述 xff1a 现在遇到的问题是groundtruth和估计的位姿没有在一个坐标系中 xff0c 生成的轨迹对不齐 xff0c 需要首先根据位姿
  • 怎样用美图秀秀制作一寸照片

    有些时候 xff0c 老是会埋怨自己的http jingyan baidu com article 73c3ce28c852b7e50243d945 html证件照很难看 xff0c 自己拍的照片又不合格 xff0c 该怎么办呢 这里和大家
  • Realsense D435i关闭IR结构光

    Realsense D435i 关闭IR光 前言环境一次性关闭IR光从源码修改 前言 由于要做Realsense D435i的双目结构光相机标定 xff0c 其中用到了ROS来录制数据包 xff0c 但是结构光会影响标定 xff0c 所以得
  • vins-mono保存、重载地图、evo工具测试

    vins mono保存 重载地图 evo工具测试 地图保存与加载先跑起来修改地图保存的路径保存地图重载地图 evo测评evo工具修改数据格式使用evo绘制轨迹与双目ORB SLAM2进行对比 下面咱们来对vins mono地图进行简单测试
  • C++11新特性简介

    目录 功能扩展与增强 右值概念 类中右值扩展 标准库中右值扩展 内联命名空间 初始化 initialzier list 原始字符串 自定义字面值 类型自动推导 auto decltype 常量表达式函数constexpr 变长模板 空指针n
  • Realsense D435i单目跑ORB_SLAM2(无ROS版)

    主要参考mono euroc这个文件修改 xff0c 把数据源改成realsense的就可以了 如何获取realsense数据 xff0c 在之前的博客也阐述过 Realsense D435i 43 Opencv 获取彩色 深度 IMU数据
  • QGC开发 显示双GPS/RTK信息以及自定义页面(ubuntu)

    一 QGC开发 显示双GPS RTK信息 1 在sitl中进行仿真 xff0c 虚拟出第二个GPS mavlink发送到地面站 如下图中 xff0c 在mavlink msg gps2 raw h中找到发送第二组gps rtk数据函数mav