SimulatedPosition.h 1.63 KB
Newer Older
1 2
/****************************************************************************
 *
Gus Grubba's avatar
Gus Grubba committed
3
 * (c) 2009-2020 QGROUNDCONTROL PROJECT <http://www.qgroundcontrol.org>
4 5 6 7 8
 *
 * QGroundControl is licensed according to the terms in the file
 * COPYING.md in the root of the source code directory.
 *
 ****************************************************************************/
Jimmy Johnson's avatar
Jimmy Johnson committed
9 10 11 12 13 14 15

#pragma once

#include <QtPositioning/qgeopositioninfosource.h>
#include "QGCToolbox.h"
#include <QTimer>

16 17
class Vehicle;

Jimmy Johnson's avatar
Jimmy Johnson committed
18 19 20 21 22 23 24
class SimulatedPosition : public QGeoPositionInfoSource
{
   Q_OBJECT

public:
    SimulatedPosition();

25
    QGeoPositionInfo lastKnownPosition(bool fromSatellitePositioningMethodsOnly = false) const override;
Jimmy Johnson's avatar
Jimmy Johnson committed
26

27 28 29
    PositioningMethods  supportedPositioningMethods (void) const override;
    int                 minimumUpdateInterval       (void) const override { return _updateIntervalMsecs; }
    Error               error                       (void) const override;
Jimmy Johnson's avatar
Jimmy Johnson committed
30 31

public slots:
32 33 34
    void startUpdates   (void) override;
    void stopUpdates    (void) override;
    void requestUpdate  (int timeout = 5000) override;
Jimmy Johnson's avatar
Jimmy Johnson committed
35 36

private slots:
37 38 39
    void _updatePosition                (void);
    void _vehicleAdded                  (Vehicle* vehicle);
    void _vehicleHomePositionChanged    (QGeoCoordinate homePosition);
Jimmy Johnson's avatar
Jimmy Johnson committed
40 41

private:
42 43
    QTimer              _updateTimer;
    QGeoPositionInfo    _lastPosition;
Jimmy Johnson's avatar
Jimmy Johnson committed
44

45 46 47 48
    static constexpr int    _updateIntervalMsecs =              1000;
    static constexpr double _horizontalVelocityMetersPerSec =   0.5;
    static constexpr double _verticalVelocityMetersPerSec =     0.1;
    static constexpr double _heading =                          45;
Jimmy Johnson's avatar
Jimmy Johnson committed
49
};