RTLManager.h 2.87 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 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
#pragma once

#include "GenericWaypointManager.h"
#include "Settings.h"
#include "AreaInterface.h"

namespace WaypointManager {

typedef GenericWaypointManager<QGeoCoordinate,
                               QVector,
                               QmlObjectListModel,
                               Settings>
        ManagerBase;
//!
//! \brief The RTLManager class is used to manage the return to launch of the vehicle.
//!
//! @note The \class QmlObjectList returned by \fn missionItems doesn't contain a MissionSettingsItem.
//! This list is supposed to be used for display purposes only.
class RTLManager : public ManagerBase
{
public:
    RTLManager() = delete;
    RTLManager(Settings &settings,
               AreaInterface &interface);

    //!
    //! \brief Does nothing.
    //!
    virtual void            setWaypoints(const QVector<QGeoCoordinate> &waypoints) override;
    //!
    //! \brief Does nothing.
    //!
    virtual void            push_back   (const QGeoCoordinate &wp) override;
    //!
    //! \brief Does nothing.
    //!
    virtual void            push_front  (const QGeoCoordinate &wp) override;
    //!
    //! \brief Clears the waypoint manager.
    virtual void            clear       () override;
    //!
    //! \brief Does nothing.
    //!
    virtual void            insert      (std::size_t i, const QGeoCoordinate &wp) override;
    //!
    //! \brief Returns zero.
    //! \return Returns zero.
    virtual std::size_t     size        () const override;
    //!
    //! \brief Returns an empty coordinate.
    virtual void            remove      (std::size_t i) override;


    //!
    //! \brief Updates the waypoint manager.
    //!
    //! After updateing a call to currentMissionItems or currentWaypoints returns
    //! a path from the vehicles current position to the home position.
    //!
    //! \return Returns true on success, false either.
    //!
    virtual bool update() override;
    //!
    //! \brief Does nothing.
    //! \return Returns true.
    //!
    virtual bool next() override;
    //!
    //! \brief Does nothing.
    //! \return Returns true.
    //!
    virtual bool previous() override;
    //!
    //! \brief Does nothing.
    //! \return Returns true.
    //!
    virtual bool reset() override;

79
    bool checkPrecondition(QString &errorString);
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99

protected:
    bool _insertMissionItem(const QGeoCoordinate &c,
                            size_t index,
                            QmlObjectListModel &list,
                            bool doUpdate);
    bool _insertMissionItem(const QGeoCoordinate &c,
                            size_t index,
                            bool doUpdate);
    bool _calcShortestPath(const QGeoCoordinate &start,
                           const QGeoCoordinate &destination,
                           QVector<QGeoCoordinate> &path);

    AreaInterface *_areaInterface;
private:
    bool _worker();

};

} // namespace WaypointManager