HSIDisplay.h 4.09 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
/*=====================================================================

PIXHAWK Micro Air Vehicle Flying Robotics Toolkit

(c) 2009, 2010 PIXHAWK PROJECT  <http://pixhawk.ethz.ch>

This file is part of the PIXHAWK project

    PIXHAWK is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.

    PIXHAWK is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with PIXHAWK. If not, see <http://www.gnu.org/licenses/>.

======================================================================*/

/**
 * @file
 *   @brief Definition of of Horizontal Situation Indicator class
 *
 *   @author Lorenz Meier <mavteam@student.ethz.ch>
 *
 */

#ifndef HSIDISPLAY_H
#define HSIDISPLAY_H

#include <QtGui/QWidget>
#include <QColor>
#include <QTimer>
#include <QMap>
#include <QPair>
#include <cmath>

#include "HDDisplay.h"
lm's avatar
lm committed
43
#include "MG.h"
44 45 46 47

class HSIDisplay : public HDDisplay {
    Q_OBJECT
public:
48
    HSIDisplay(QWidget *parent = 0);
lm's avatar
lm committed
49
    // ~HSIDisplay();
50 51 52

public slots:
    void setActiveUAS(UASInterface* uas);
lm's avatar
lm committed
53
    void updateSatellite(int uasid, int satid, float azimuth, float direction, float snr, bool used);
54 55 56 57
    void updateAttitudeSetpoints(UASInterface*, double rollDesired, double pitchDesired, double yawDesired, double thrustDesired, quint64 usec);
    void updatePositionSetpoints(int uasid, double xDesired, double yDesired, double zDesired, quint64 usec);
    void updateLocalPosition(UASInterface*, double x, double y, double z, quint64 usec);
    void updateGlobalPosition(UASInterface*, double lat, double lon, double alt, quint64 usec);
lm's avatar
lm committed
58
    void paintEvent(QPaintEvent * event);
59 60 61

protected slots:
    void paintDisplay();
lm's avatar
lm committed
62 63
    void drawGPS();
    void drawObjects();
64 65 66
    void drawPositionSetpoint(float xRef, float yRef, float radius, const QColor& color, QPainter* painter);
    void drawAttitudeSetpoint(float xRef, float yRef, float radius, const QColor& color, QPainter* painter);
    void drawAltitudeSetpoint(float xRef, float yRef, float radius, const QColor& color, QPainter* painter);
lm's avatar
lm committed
67

68 69

protected:
lm's avatar
lm committed
70 71 72 73 74 75 76 77
    static QColor getColorForSNR(float snr);

    /**
     * @brief Private data container class to be used within the HSI widget
     */
    class GPSSatellite
    {
    public:
lm's avatar
lm committed
78
        GPSSatellite(int id, float elevation, float azimuth, float snr, bool used) :
lm's avatar
lm committed
79
                id(id),
lm's avatar
lm committed
80
                elevation(elevation),
lm's avatar
lm committed
81 82
                azimuth(azimuth),
                snr(snr),
lm's avatar
lm committed
83 84
                used(used),
                lastUpdate(MG::TIME::getGroundTimeNowUsecs())
lm's avatar
lm committed
85 86 87 88
        {

        }

lm's avatar
lm committed
89
        void update(int id, float elevation, float azimuth, float snr, bool used)
lm's avatar
lm committed
90 91
        {
            this->id = id;
lm's avatar
lm committed
92
            this->elevation = elevation;
lm's avatar
lm committed
93 94 95
            this->azimuth = azimuth;
            this->snr = snr;
            this->used = used;
lm's avatar
lm committed
96
            this->lastUpdate = MG::TIME::getGroundTimeNowUsecs();
lm's avatar
lm committed
97 98 99
        }

        int id;
lm's avatar
lm committed
100
        float elevation;
lm's avatar
lm committed
101 102 103
        float azimuth;
        float snr;
        bool used;
lm's avatar
lm committed
104
        quint64 lastUpdate;
lm's avatar
lm committed
105 106 107 108

        friend class HSIDisplay;
    };

lm's avatar
lm committed
109
    QMap<int, GPSSatellite*> gpsSatellites;
pixhawk's avatar
pixhawk committed
110
    unsigned int satellitesUsed;
111

112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140
    // Current controller values
    float attXSet;
    float attYSet;
    float attYawSet;
    float altitudeSet;

    float posXSet;
    float posYSet;
    float posZSet;

    // Controller saturation values
    float attXSaturation;
    float attYSaturation;
    float attYawSaturation;

    float posXSaturation;
    float posYSaturation;
    float altitudeSaturation;

    // Position
    float lat;
    float lon;
    float alt;
    quint64 globalAvailable;  ///< Last global position update time
    float x;
    float y;
    float z;
    quint64 localAvailable;   ///< Last local position update time

141 142 143 144
private:
};

#endif // HSIDISPLAY_H