AirframeComponent.cc 4.83 KB
Newer Older
1 2 3 4 5 6 7 8 9
/****************************************************************************
 *
 *   (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.
 *
 ****************************************************************************/

10 11 12 13 14

/// @file
///     @author Don Gagne <don@thegagnes.com>

#include "AirframeComponent.h"
15
#include "QGCQmlWidgetHolder.h"
16

17 18 19
#if 0
// Broken by latest mavlink module changes. Not used yet. Comment out for now.
// Discussing mavlink fix.
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
struct mavType {
    int         type;
    const char* description;
};

/// @brief Used to translate from MAV_TYPE_* id to user string
static const struct mavType mavTypeInfo[] = {
    { MAV_TYPE_GENERIC,             "Generic" },
    { MAV_TYPE_FIXED_WING,          "Fixed Wing" },
    { MAV_TYPE_QUADROTOR,           "Quadrotor" },
    { MAV_TYPE_COAXIAL,             "Coaxial" },
    { MAV_TYPE_HELICOPTER,          "Helicopter"},
    { MAV_TYPE_ANTENNA_TRACKER,     "Antenna Tracker" },
    { MAV_TYPE_GCS,                 "Ground Control Station" },
    { MAV_TYPE_AIRSHIP,             "Airship" },
    { MAV_TYPE_FREE_BALLOON,        "Free Balloon" },
    { MAV_TYPE_ROCKET,              "Rocket" },
    { MAV_TYPE_GROUND_ROVER,        "Ground Rover" },
    { MAV_TYPE_SURFACE_BOAT,        "Boat" },
    { MAV_TYPE_SUBMARINE,           "Submarine" },
    { MAV_TYPE_HEXAROTOR,           "Hexarotor" },
    { MAV_TYPE_OCTOROTOR,           "Octorotor" },
    { MAV_TYPE_TRICOPTER,           "Tricopter" },
    { MAV_TYPE_FLAPPING_WING,       "Flapping Wing" },
    { MAV_TYPE_KITE,                "Kite" },
    { MAV_TYPE_ONBOARD_CONTROLLER,  "Onbard companion controller" },
    { MAV_TYPE_VTOL_DUOROTOR,       "Two-rotor VTOL" },
    { MAV_TYPE_VTOL_QUADROTOR,      "Quad-rotor VTOL" },
48 49 50 51 52
    { MAV_TYPE_VTOL_RESERVED1,      "Reserved" },
    { MAV_TYPE_VTOL_RESERVED2,      "Reserved" },
    { MAV_TYPE_VTOL_RESERVED3,      "Reserved" },
    { MAV_TYPE_VTOL_RESERVED4,      "Reserved" },
    { MAV_TYPE_VTOL_RESERVED5,      "Reserved" },
53
    { MAV_TYPE_GIMBAL,              "Gimbal" },
54 55
};
static size_t cMavTypes = sizeof(mavTypeInfo) / sizeof(mavTypeInfo[0]);
56
#endif
57

58
AirframeComponent::AirframeComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent) :
59
    VehicleComponent(vehicle, autopilot, parent),
60 61
    _name(tr("Airframe"))
{
62 63 64
#if 0
    // Broken by latest mavlink module changes. Not used yet. Comment out for now.
    // Discussing mavlink fix.
Don Gagne's avatar
Don Gagne committed
65 66
    Q_UNUSED(mavTypeInfo);  // Keeping this around for later use
    
67 68
    // Validate that our mavTypeInfo array hasn't gotten out of sync
    
69
    qDebug() << cMavTypes << MAV_TYPE_ENUM_END;
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
    Q_ASSERT(cMavTypes == MAV_TYPE_ENUM_END);
    
    static const int mavTypes[] = {
        MAV_TYPE_GENERIC,
        MAV_TYPE_FIXED_WING,
        MAV_TYPE_QUADROTOR,
        MAV_TYPE_COAXIAL,
        MAV_TYPE_HELICOPTER,
        MAV_TYPE_ANTENNA_TRACKER,
        MAV_TYPE_GCS,
        MAV_TYPE_AIRSHIP,
        MAV_TYPE_FREE_BALLOON,
        MAV_TYPE_ROCKET,
        MAV_TYPE_GROUND_ROVER,
        MAV_TYPE_SURFACE_BOAT,
        MAV_TYPE_SUBMARINE,
        MAV_TYPE_HEXAROTOR,
        MAV_TYPE_OCTOROTOR,
        MAV_TYPE_TRICOPTER,
        MAV_TYPE_FLAPPING_WING,
        MAV_TYPE_KITE,
        MAV_TYPE_ONBOARD_CONTROLLER,
        MAV_TYPE_VTOL_DUOROTOR,
93
        MAV_TYPE_VTOL_QUADROTOR,
94 95 96 97 98
        MAV_TYPE_VTOL_RESERVED1,
        MAV_TYPE_VTOL_RESERVED2,
        MAV_TYPE_VTOL_RESERVED3,
        MAV_TYPE_VTOL_RESERVED4,
        MAV_TYPE_VTOL_RESERVED5,
99
        MAV_TYPE_GIMBAL,
100
    };
Don Gagne's avatar
Don Gagne committed
101
    Q_UNUSED(mavTypes); // Keeping this around for later use
102
    
Don Gagne's avatar
Don Gagne committed
103
    for (size_t i=0; i<cMavTypes; i++) {
104 105
        Q_ASSERT(mavTypeInfo[i].type == mavTypes[i]);
    }
106
#endif
107 108 109 110 111 112 113 114 115 116
}

QString AirframeComponent::name(void) const
{
    return _name;
}

QString AirframeComponent::description(void) const
{
    return tr("The Airframe Component is used to select the airframe which matches your vehicle. "
nopeppermint's avatar
nopeppermint committed
117
              "This will in turn set up the various tuning values for flight parameters.");
118 119
}

120
QString AirframeComponent::iconResource(void) const
121
{
122
    return "/qmlimages/AirframeComponentIcon.png";
123 124 125 126 127 128 129 130 131
}

bool AirframeComponent::requiresSetup(void) const
{
    return true;
}

bool AirframeComponent::setupComplete(void) const
{
Don Gagne's avatar
Don Gagne committed
132
    return _autopilot->getParameterFact(FactSystem::defaultComponentId, "SYS_AUTOSTART")->rawValue().toInt() != 0;
133 134
}

Don Gagne's avatar
Don Gagne committed
135
QStringList AirframeComponent::setupCompleteChangedTriggerList(void) const
136
{
Don Gagne's avatar
Don Gagne committed
137
    return QStringList("SYS_AUTOSTART");
138 139
}

140
QUrl AirframeComponent::setupSource(void) const
141
{
142
    return QUrl::fromUserInput("qrc:/qml/AirframeComponent.qml");
143 144
}

145
QUrl AirframeComponent::summaryQmlSource(void) const
146
{
147
    return QUrl::fromUserInput("qrc:/qml/AirframeComponentSummary.qml");
148
}
Don Gagne's avatar
Don Gagne committed
149 150 151 152 153

QString AirframeComponent::prerequisiteSetup(void) const
{
    return QString();
}