Commit d32ab81d authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #4316 from dennisss/cf2

CF2 Support
parents 3d60c734 06d0a4af
......@@ -806,6 +806,8 @@ HEADERS+= \
src/AutoPilotPlugins/Common/MixersComponent.h \
src/AutoPilotPlugins/Common/MotorComponent.h \
src/AutoPilotPlugins/Common/RadioComponentController.h \
src/AutoPilotPlugins/Common/SyslinkComponent.h \
src/AutoPilotPlugins/Common/SyslinkComponentController.h \
src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.h \
src/FirmwarePlugin/CameraMetaData.h \
src/FirmwarePlugin/FirmwarePlugin.h \
......@@ -829,6 +831,8 @@ SOURCES += \
src/AutoPilotPlugins/Common/MixersComponent.cc \
src/AutoPilotPlugins/Common/MotorComponent.cc \
src/AutoPilotPlugins/Common/RadioComponentController.cc \
src/AutoPilotPlugins/Common/SyslinkComponent.cc \
src/AutoPilotPlugins/Common/SyslinkComponentController.cc \
src/AutoPilotPlugins/Generic/GenericAutoPilotPlugin.cc \
src/FirmwarePlugin/CameraMetaData.cc \
src/FirmwarePlugin/FirmwarePlugin.cc \
......
......@@ -24,6 +24,7 @@
<file alias="DebugWindow.qml">src/ui/preferences/DebugWindow.qml</file>
<file alias="ESP8266Component.qml">src/AutoPilotPlugins/Common/ESP8266Component.qml</file>
<file alias="ESP8266ComponentSummary.qml">src/AutoPilotPlugins/Common/ESP8266ComponentSummary.qml</file>
<file alias="SyslinkComponent.qml">src/AutoPilotPlugins/Common/SyslinkComponent.qml</file>
<file alias="FirmwareUpgrade.qml">src/VehicleSetup/FirmwareUpgrade.qml</file>
<file alias="FlightDisplayViewDummy.qml">src/FlightDisplay/FlightDisplayViewDummy.qml</file>
<file alias="FlightDisplayViewUVC.qml">src/FlightDisplay/FlightDisplayViewUVC.qml</file>
......
/****************************************************************************
*
* (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.
*
****************************************************************************/
#include "SyslinkComponent.h"
#include "AutoPilotPlugin.h"
SyslinkComponent::SyslinkComponent(Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent)
: VehicleComponent(vehicle, autopilot, parent)
, _name(tr("Syslink"))
{
}
QString SyslinkComponent::name(void) const
{
return _name;
}
QString SyslinkComponent::description(void) const
{
return tr("The Syslink Component is used to setup the radio connection on Crazyflies.");
}
QString SyslinkComponent::iconResource(void) const
{
return "/qmlimages/wifi.svg";
}
bool SyslinkComponent::requiresSetup(void) const
{
return false;
}
bool SyslinkComponent::setupComplete(void) const
{
return true;
}
QStringList SyslinkComponent::setupCompleteChangedTriggerList(void) const
{
return QStringList();
}
QUrl SyslinkComponent::setupSource(void) const
{
return QUrl::fromUserInput("qrc:/qml/SyslinkComponent.qml");
}
QUrl SyslinkComponent::summaryQmlSource(void) const
{
return QUrl();
}
QString SyslinkComponent::prerequisiteSetup(void) const
{
return QString();
}
/****************************************************************************
*
* (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.
*
****************************************************************************/
#ifndef SyslinkComponent_H
#define SyslinkComponent_H
#include "VehicleComponent.h"
class SyslinkComponent : public VehicleComponent
{
Q_OBJECT
public:
SyslinkComponent (Vehicle* vehicle, AutoPilotPlugin* autopilot, QObject* parent = NULL);
// Virtuals from VehicleComponent
QStringList setupCompleteChangedTriggerList() const;
// Virtuals from VehicleComponent
QString name () const;
QString description () const;
QString iconResource () const;
bool requiresSetup () const;
bool setupComplete () const;
QUrl setupSource () const;
QUrl summaryQmlSource () const;
QString prerequisiteSetup () const;
private:
const QString _name;
QVariantList _summaryItems;
};
#endif
/****************************************************************************
*
* (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.2
import QtQuick.Controls 1.2
import QtQuick.Dialogs 1.2
import QtQuick.Layouts 1.2
import QGroundControl.FactSystem 1.0
import QGroundControl.FactControls 1.0
import QGroundControl.Controls 1.0
import QGroundControl.ScreenTools 1.0
import QGroundControl.Controllers 1.0
SetupPage {
id: syslinkPage
pageComponent: pageComponent
Component {
id: pageComponent
Column {
id: innerColumn
width: availableWidth
spacing: ScreenTools.defaultFontPixelHeight * 0.5
property int textEditWidth: ScreenTools.defaultFontPixelWidth * 12
SyslinkComponentController {
id: controller
factPanel: syslinkPage.viewPanel
}
QGCLabel {
text: qsTr("Radio Settings")
font.family: ScreenTools.demiboldFontFamily
}
Rectangle {
width: parent.width
height: radioGrid.height + ScreenTools.defaultFontPixelHeight
color: qgcPal.windowShade
GridLayout {
id: radioGrid
anchors.margins: ScreenTools.defaultFontPixelHeight / 2
anchors.left: parent.left
anchors.top: parent.top
columns: 2
columnSpacing: ScreenTools.defaultFontPixelWidth
QGCLabel {
text: qsTr("Channel")
}
QGCTextField {
id: channelField
width: textEditWidth
text: controller.radioChannel
validator: IntValidator {bottom: 0; top: 125;}
inputMethodHints: Qt.ImhDigitsOnly
onEditingFinished: {
controller.radioChannel = text
}
}
QGCLabel {
id: channelHelp
Layout.columnSpan: radioGrid.columns
Layout.fillWidth: true
font.pointSize: ScreenTools.smallFontPointSize
wrapMode: Text.WordWrap
text: "Channel can be between 0 and 125"
}
QGCLabel {
id: addressLabel
text: qsTr("Address")
}
QGCTextField {
id: addressField
width: textEditWidth
text: controller.radioAddress
maximumLength: 10
validator: RegExpValidator { regExp: /^[0-9A-Fa-f]*$/ }
onEditingFinished: {
controller.radioAddress = text
}
}
QGCLabel {
id: addressHelp
Layout.columnSpan: radioGrid.columns
Layout.fillWidth: true
font.pointSize: ScreenTools.smallFontPointSize
wrapMode: Text.WordWrap
text: "Address in hex. Default is E7E7E7E7E7."
}
QGCLabel {
id: rateLabel
text: qsTr("Data Rate")
}
QGCComboBox {
id: rateField
Layout.fillWidth: true
model: controller.radioRates
currentIndex: controller.radioRate
onActivated: {
controller.radioRate = index
}
}
QGCButton {
text: "Restore Defaults"
width: textEditWidth
onClicked: {
controller.resetDefaults()
}
}
} // Grid
} // Rectangle - Radio Settings
}
}
}
/****************************************************************************
*
* (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.
*
****************************************************************************/
#include "SyslinkComponentController.h"
#include "QGCApplication.h"
#include "UAS.h"
#include "ParameterManager.h"
#include <QHostAddress>
#include <QtEndian>
QGC_LOGGING_CATEGORY(SyslinkComponentControllerLog, "SyslinkComponentControllerLog")
//-----------------------------------------------------------------------------
SyslinkComponentController::SyslinkComponentController()
{
_dataRates.append("750Kb/s");
_dataRates.append("1Mb/s");
_dataRates.append("2Mb/s");
Fact* chan = getParameterFact(_vehicle->id(), "SLNK_RADIO_CHAN");
connect(chan, &Fact::valueChanged, this, &SyslinkComponentController::_channelChanged);
Fact* rate = getParameterFact(_vehicle->id(), "SLNK_RADIO_RATE");
connect(rate, &Fact::valueChanged, this, &SyslinkComponentController::_rateChanged);
Fact* addr1 = getParameterFact(_vehicle->id(), "SLNK_RADIO_ADDR1");
connect(addr1, &Fact::valueChanged, this, &SyslinkComponentController::_addressChanged);
Fact* addr2 = getParameterFact(_vehicle->id(), "SLNK_RADIO_ADDR2");
connect(addr2, &Fact::valueChanged, this, &SyslinkComponentController::_addressChanged);
}
//-----------------------------------------------------------------------------
SyslinkComponentController::~SyslinkComponentController()
{
}
//-----------------------------------------------------------------------------
int
SyslinkComponentController::radioChannel()
{
return getParameterFact(_vehicle->id(), "SLNK_RADIO_CHAN")->rawValue().toUInt();
}
//-----------------------------------------------------------------------------
void
SyslinkComponentController::setRadioChannel(int num)
{
Fact* f = getParameterFact(_vehicle->id(), "SLNK_RADIO_CHAN");
f->setRawValue(QVariant(num));
}
//-----------------------------------------------------------------------------
QString
SyslinkComponentController::radioAddress()
{
uint32_t val_uh = getParameterFact(_vehicle->id(), "SLNK_RADIO_ADDR1")->rawValue().toUInt();
uint32_t val_lh = getParameterFact(_vehicle->id(), "SLNK_RADIO_ADDR2")->rawValue().toUInt();
uint64_t val = (((uint64_t) val_uh) << 32) | ((uint64_t) val_lh);
return QString().number(val, 16);
}
//-----------------------------------------------------------------------------
void
SyslinkComponentController::setRadioAddress(QString str)
{
Fact *uh = getParameterFact(_vehicle->id(), "SLNK_RADIO_ADDR1");
Fact *lh = getParameterFact(_vehicle->id(), "SLNK_RADIO_ADDR2");
uint64_t val = str.toULongLong(0, 16);
uint32_t val_uh = val >> 32;
uint32_t val_lh = val & 0xFFFFFFFF;
uh->setRawValue(QVariant(val_uh));
lh->setRawValue(QVariant(val_lh));
}
//-----------------------------------------------------------------------------
int
SyslinkComponentController::radioRate()
{
return getParameterFact(_vehicle->id(), "SLNK_RADIO_RATE")->rawValue().toInt();
}
//-----------------------------------------------------------------------------
void
SyslinkComponentController::setRadioRate(int idx)
{
if(idx >= 0 && idx <= 2 && idx != radioRate()) {
Fact* r = getParameterFact(_vehicle->id(), "SLNK_RADIO_RATE");
r->setRawValue(idx);
}
}
//-----------------------------------------------------------------------------
void
SyslinkComponentController::resetDefaults()
{
Fact* chan = getParameterFact(_vehicle->id(), "SLNK_RADIO_CHAN");
Fact* rate = getParameterFact(_vehicle->id(), "SLNK_RADIO_RATE");
Fact* addr1 = getParameterFact(_vehicle->id(), "SLNK_RADIO_ADDR1");
Fact* addr2 = getParameterFact(_vehicle->id(), "SLNK_RADIO_ADDR2");
chan->setRawValue(chan->rawDefaultValue());
rate->setRawValue(rate->rawDefaultValue());
addr1->setRawValue(addr1->rawDefaultValue());
addr2->setRawValue(addr2->rawDefaultValue());
}
//-----------------------------------------------------------------------------
void
SyslinkComponentController::_channelChanged(QVariant)
{
emit radioChannelChanged();
}
//-----------------------------------------------------------------------------
void
SyslinkComponentController::_addressChanged(QVariant)
{
emit radioAddressChanged();
}
//-----------------------------------------------------------------------------
void
SyslinkComponentController::_rateChanged(QVariant)
{
emit radioRateChanged();
}
/****************************************************************************
*
* (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.
*
****************************************************************************/
#ifndef SyslinkComponentController_H
#define SyslinkComponentController_H
#include "FactPanelController.h"
#include "UASInterface.h"
#include "QGCLoggingCategory.h"
#include "AutoPilotPlugin.h"
Q_DECLARE_LOGGING_CATEGORY(SyslinkComponentControllerLog)
namespace Ui {
class SyslinkComponentController;
}
class SyslinkComponentController : public FactPanelController
{
Q_OBJECT
public:
SyslinkComponentController ();
~SyslinkComponentController ();
Q_PROPERTY(int radioChannel READ radioChannel WRITE setRadioChannel NOTIFY radioChannelChanged)
Q_PROPERTY(QString radioAddress READ radioAddress WRITE setRadioAddress NOTIFY radioAddressChanged)
Q_PROPERTY(int radioRate READ radioRate WRITE setRadioRate NOTIFY radioRateChanged)
Q_PROPERTY(QStringList radioRates READ radioRates CONSTANT)
Q_PROPERTY(Vehicle* vehicle READ vehicle CONSTANT)
Q_INVOKABLE void resetDefaults();
int radioChannel ();
QString radioAddress ();
int radioRate ();
QStringList radioRates () { return _dataRates; }
Vehicle* vehicle () { return _vehicle; }
void setRadioChannel (int num);
void setRadioAddress (QString str);
void setRadioRate (int idx);
signals:
void radioChannelChanged ();
void radioAddressChanged ();
void radioRateChanged ();
private slots:
void _channelChanged (QVariant value);
void _addressChanged (QVariant value);
void _rateChanged (QVariant value);
private:
QStringList _dataRates;
};
#endif // SyslinkComponentController_H
......@@ -40,6 +40,7 @@ PX4AutoPilotPlugin::PX4AutoPilotPlugin(Vehicle* vehicle, QObject* parent)
, _motorComponent(NULL)
, _tuningComponent(NULL)
, _mixersComponent(NULL)
, _syslinkComponent(NULL)
{
if (!vehicle) {
qWarning() << "Internal error";
......@@ -122,6 +123,12 @@ const QVariantList& PX4AutoPilotPlugin::vehicleComponents(void)
} else {
qWarning() << "Call to vehicleCompenents prior to parametersReady";
}
if(_vehicle->parameterManager()->parameterExists(_vehicle->id(), "SLNK_RADIO_CHAN")) {
_syslinkComponent = new SyslinkComponent(_vehicle, this);
_syslinkComponent->setupTriggerSignals();
_components.append(QVariant::fromValue((VehicleComponent*)_syslinkComponent));
}
} else {
qWarning() << "Internal error";
}
......
......@@ -24,6 +24,7 @@
#include "MotorComponent.h"
#include "PX4TuningComponent.h"
#include "MixersComponent.h"
#include "SyslinkComponent.h"
#include "Vehicle.h"
#include <QImage>
......@@ -44,7 +45,6 @@ public:
const QVariantList& vehicleComponents(void) override;
void parametersReadyPreChecks(void) override;
QString prerequisiteSetup(VehicleComponent* component) const override;
protected:
bool _incorrectParameterVersion; ///< true: parameter version incorrect, setup not allowed
PX4AirframeLoader* _airframeFacts;
......@@ -59,7 +59,7 @@ protected:
MotorComponent* _motorComponent;
PX4TuningComponent* _tuningComponent;
MixersComponent* _mixersComponent;
SyslinkComponent* _syslinkComponent;
private:
QVariantList _components;
};
......
......@@ -51,6 +51,7 @@
#include "ScreenToolsController.h"
#include "QFileDialogController.h"
#include "RCChannelMonitorController.h"
#include "SyslinkComponentController.h"
#include "AutoPilotPlugin.h"
#include "VehicleComponent.h"
#include "FirmwarePluginManager.h"
......@@ -390,6 +391,7 @@ void QGCApplication::_initCommon(void)
qmlRegisterType<RCChannelMonitorController> ("QGroundControl.Controllers", 1, 0, "RCChannelMonitorController");
qmlRegisterType<JoystickConfigController> ("QGroundControl.Controllers", 1, 0, "JoystickConfigController");
qmlRegisterType<LogDownloadController> ("QGroundControl.Controllers", 1, 0, "LogDownloadController");
qmlRegisterType<SyslinkComponentController> ("QGroundControl.Controllers", 1, 0, "SyslinkComponentController");
#ifndef __mobile__
qmlRegisterType<ViewWidgetController> ("QGroundControl.Controllers", 1, 0, "ViewWidgetController");
qmlRegisterType<CustomCommandWidgetController> ("QGroundControl.Controllers", 1, 0, "CustomCommandWidgetController");
......
......@@ -73,7 +73,7 @@ public:
static const int boardIDMINDPXFMUV2 = 88; ///< MindPX V2 board, as from USB PID
static const int boardIDTAPV1 = 64; ///< TAP V1 board, as from USB PID
static const int boardIDASCV1 = 65; ///< ASC V1 board, as from USB PID
static const int boardIDCrazyflie2 = 12; ///< Crazyflie 2.0 board, as from USB PID
signals:
/// @brief Signals progress indicator for long running bootloader utility routines
void updateProgress(int curr, int total);
......
......@@ -335,6 +335,14 @@ void FirmwareUpgradeController::_initFirmwareHash()
{ AutoPilotStackPX4, BetaFirmware, DefaultVehicleFirmware, "http://px4-travis.s3.amazonaws.com/Firmware/beta/asc-v1_default.px4"},
{ AutoPilotStackPX4, DeveloperFirmware, DefaultVehicleFirmware, "http://px4-travis.s3.amazonaws.com/Firmware/master/asc-v1_default.px4"},
};
//////////////////////////////////// Crazyflie 2.0 firmwares //////////////////////////////////////////////////
FirmwareToUrlElement_t rgCrazyflie2FirmwareArray[] = {
{ AutoPilotStackPX4, StableFirmware, DefaultVehicleFirmware, "http://px4-travis.s3.amazonaws.com/Firmware/stable/crazyflie_default.px4"},
{ AutoPilotStackPX4, BetaFirmware, DefaultVehicleFirmware, "http://px4-travis.s3.amazonaws.com/Firmware/beta/crazyflie_default.px4"},
{ AutoPilotStackPX4, DeveloperFirmware, DefaultVehicleFirmware, "http://px4-travis.s3.amazonaws.com/Firmware/master/crazyflie_default.px4"},
};
/////////////////////////////// px4flow firmwares ///////////////////////////////////////
FirmwareToUrlElement_t rgPX4FLowFirmwareArray[] = {
{ PX4Flow, StableFirmware, DefaultVehicleFirmware, "http://px4-travis.s3.amazonaws.com/Flow/master/px4flow.px4" },
......@@ -406,6 +414,12 @@ void FirmwareUpgradeController::_initFirmwareHash()
_rgASCV1Firmware.insert(FirmwareIdentifier(element.stackType, element.firmwareType, element.vehicleType), element.url);
}
size = sizeof(rgCrazyflie2FirmwareArray)/sizeof(rgCrazyflie2FirmwareArray[0]);
for (int i = 0; i < size; i++) {
const FirmwareToUrlElement_t& element = rgCrazyflie2FirmwareArray[i];
_rgCrazyflie2Firmware.insert(FirmwareIdentifier(element.stackType, element.firmwareType, element.vehicleType), element.url);
}
size = sizeof(rgPX4FLowFirmwareArray)/sizeof(rgPX4FLowFirmwareArray[0]);
for (int i = 0; i < size; i++) {
const FirmwareToUrlElement_t& element = rgPX4FLowFirmwareArray[i];
......@@ -457,6 +471,8 @@ QHash<FirmwareUpgradeController::FirmwareIdentifier, QString>* FirmwareUpgradeCo
return &_rgTAPV1Firmware;
case Bootloader::boardIDASCV1:
return &_rgASCV1Firmware;
case Bootloader::boardIDCrazyflie2:
return &_rgCrazyflie2Firmware;
case Bootloader::boardID3DRRadio:
return &_rg3DRRadioFirmware;
default:
......
......@@ -211,6 +211,7 @@ private:
QHash<FirmwareIdentifier, QString> _rgMindPXFMUV2Firmware;
QHash<FirmwareIdentifier, QString> _rgTAPV1Firmware;
QHash<FirmwareIdentifier, QString> _rgASCV1Firmware;
QHash<FirmwareIdentifier, QString> _rgCrazyflie2Firmware;
QHash<FirmwareIdentifier, QString> _rgPX4FLowFirmware;
QHash<FirmwareIdentifier, QString> _rg3DRRadioFirmware;
......
......@@ -204,7 +204,6 @@ bool QGCSerialPortInfo::getBoardInfo(QGCSerialPortInfo::BoardType_t& boardType,
if (boardType == BoardTypeUnknown) {
// Fall back to port name matching which could lead to incorrect board mapping. But in some cases the
// vendor and product id do not come through correctly so this is used as a last chance detection method.
for (int i=0; i<_boardFallbackList.count(); i++) {
const BoardFallback_t& boardFallback = _boardFallbackList[i];
......
......@@ -17,6 +17,7 @@
{ "vendorID": 9900, "productID": 50, "boardClass": "Pixhawk", "name": "PX4 FMU V5" },
{ "vendorID": 9900, "productID": 64, "boardClass": "Pixhawk", "name": "TAP V1" },
{ "vendorID": 9900, "productID": 65, "boardClass": "Pixhawk", "name": "ASC V1" },
{ "vendorID": 9900, "productID": 22, "boardClass": "Pixhawk", "name": "Crazyflie 2" },
{ "vendorID": 9900, "productID": 21, "boardClass": "PX4 Flow", "name": "PX4 Flow" },
......@@ -49,6 +50,8 @@
{ "regExp": "^PX4 ASC v1.x$", "boardClass": "Pixhawk" },
{ "regExp": "^PX4 BL ASC v1.x$", "boardClass": "Pixhawk" },
{ "regExp": "^PX4 FMU", "boardClass": "Pixhawk" },
{ "regExp": "^PX4 Crazyflie v2.0", "boardClass": "Pixhawk" },
{ "regExp": "^Crazyflie BL", "boardClass": "Pixhawk" },
{ "regExp": "PX4.*Flow", "boardClass": "PX4 Flow" },
{ "regExp": "^FT231X USB UART$", "boardClass": "SiK Radio" },
{ "regExp": "USB UART$", "boardClass": "SiK Radio", "androidOnly": true, "comment": "Very broad fallback, too dangerous for non-android" }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment