mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2025-04-11 03:02:20 +02:00
Merged in f5soh/librepilot/LP-478_Wizard_stick_do_not_move (pull request #384)
LP-478 TX Wizard issues
This commit is contained in:
commit
ae74c7f3f0
@ -10,7 +10,7 @@
|
|||||||
* pass it to ManualControl
|
* pass it to ManualControl
|
||||||
*
|
*
|
||||||
* @file receiver.c
|
* @file receiver.c
|
||||||
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015.
|
* @author The LibrePilot Project, http://www.librepilot.org Copyright (C) 2015-2017.
|
||||||
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
|
* The OpenPilot Team, http://www.openpilot.org Copyright (C) 2014.
|
||||||
* @brief Receiver module. Handles safety R/C link and flight mode.
|
* @brief Receiver module. Handles safety R/C link and flight mode.
|
||||||
*
|
*
|
||||||
@ -68,7 +68,7 @@
|
|||||||
// safe band to allow a bit of calibration error or trim offset (in microseconds)
|
// safe band to allow a bit of calibration error or trim offset (in microseconds)
|
||||||
#define CONNECTION_OFFSET 250
|
#define CONNECTION_OFFSET 250
|
||||||
|
|
||||||
#define ASSISTEDCONTROL_DEADBAND_MINIMUM 2 // minimum value for a well bahaved Tx, in percent.
|
#define ASSISTEDCONTROL_DEADBAND_MINIMUM 2 // minimum value for a well behaved Tx, in percent.
|
||||||
|
|
||||||
// Private types
|
// Private types
|
||||||
|
|
||||||
@ -198,24 +198,21 @@ static void receiverTask(__attribute__((unused)) void *parameters)
|
|||||||
{
|
{
|
||||||
ManualControlSettingsData settings;
|
ManualControlSettingsData settings;
|
||||||
ManualControlCommandData cmd;
|
ManualControlCommandData cmd;
|
||||||
FlightStatusData flightStatus;
|
|
||||||
|
|
||||||
|
uint8_t armed;
|
||||||
uint8_t disconnected_count = 0;
|
uint8_t disconnected_count = 0;
|
||||||
uint8_t connected_count = 0;
|
uint8_t connected_count = 0;
|
||||||
|
|
||||||
// For now manual instantiate extra instances of Accessory Desired. In future should be done dynamically
|
// For now manual instantiate extra instances of Accessory Desired. In future should be done dynamically
|
||||||
// this includes not even registering it if not used
|
// this includes not even registering it if not used
|
||||||
AccessoryDesiredCreateInstance();
|
AccessoryDesiredCreateInstance(); // Accessory1
|
||||||
AccessoryDesiredCreateInstance();
|
AccessoryDesiredCreateInstance(); // Accessory2
|
||||||
AccessoryDesiredCreateInstance();
|
AccessoryDesiredCreateInstance(); // Accessory3
|
||||||
|
|
||||||
// Rssi input
|
// Rssi input
|
||||||
AccessoryDesiredCreateInstance();
|
AccessoryDesiredCreateInstance();
|
||||||
|
|
||||||
// Whenever the configuration changes, make sure it is safe to fly
|
|
||||||
|
|
||||||
ManualControlCommandGet(&cmd);
|
ManualControlCommandGet(&cmd);
|
||||||
FlightStatusGet(&flightStatus);
|
|
||||||
|
|
||||||
/* Initialize the RcvrActivty FSM */
|
/* Initialize the RcvrActivty FSM */
|
||||||
portTickType lastActivityTime = xTaskGetTickCount();
|
portTickType lastActivityTime = xTaskGetTickCount();
|
||||||
@ -241,17 +238,20 @@ static void receiverTask(__attribute__((unused)) void *parameters)
|
|||||||
ManualControlSettingsGet(&settings);
|
ManualControlSettingsGet(&settings);
|
||||||
SystemSettingsThrustControlGet(&thrustType);
|
SystemSettingsThrustControlGet(&thrustType);
|
||||||
|
|
||||||
|
FlightStatusArmedGet(&armed);
|
||||||
/* Update channel activity monitor */
|
/* Update channel activity monitor */
|
||||||
if (flightStatus.Armed == FLIGHTSTATUS_ARMED_DISARMED) {
|
if (armed == FLIGHTSTATUS_ARMED_DISARMED) {
|
||||||
if (updateRcvrActivity(&activity_fsm)) {
|
if (updateRcvrActivity(&activity_fsm)) {
|
||||||
/* Reset the aging timer because activity was detected */
|
/* Reset the aging timer because activity was detected */
|
||||||
lastActivityTime = lastSysTime;
|
lastActivityTime = lastSysTime;
|
||||||
}
|
}
|
||||||
/* Read signal quality from the group used for the throttle */
|
|
||||||
(void)updateRcvrStatus(&activity_fsm,
|
|
||||||
settings.ChannelGroups.Throttle,
|
|
||||||
rssiValue);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Read signal quality from the group used for the throttle */
|
||||||
|
(void)updateRcvrStatus(&activity_fsm,
|
||||||
|
settings.ChannelGroups.Throttle,
|
||||||
|
rssiValue);
|
||||||
|
|
||||||
if (timeDifferenceMs(lastActivityTime, lastSysTime) > 5000) {
|
if (timeDifferenceMs(lastActivityTime, lastSysTime) > 5000) {
|
||||||
resetRcvrActivity(&activity_fsm);
|
resetRcvrActivity(&activity_fsm);
|
||||||
resetRcvrStatus(&activity_fsm);
|
resetRcvrStatus(&activity_fsm);
|
||||||
@ -794,7 +794,9 @@ group_completed:
|
|||||||
return activity_updated;
|
return activity_updated;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read signal quality from the specified group or use Rssi input value if any */
|
/**
|
||||||
|
* Read signal quality from the specified group or use Rssi input value if any
|
||||||
|
*/
|
||||||
static bool updateRcvrStatus(
|
static bool updateRcvrStatus(
|
||||||
struct rcvr_activity_fsm *fsm,
|
struct rcvr_activity_fsm *fsm,
|
||||||
ManualControlSettingsChannelGroupsOptions group, int8_t rssiValue)
|
ManualControlSettingsChannelGroupsOptions group, int8_t rssiValue)
|
||||||
|
@ -58,7 +58,7 @@
|
|||||||
#define MAX_INPUT_US 2500
|
#define MAX_INPUT_US 2500
|
||||||
|
|
||||||
#define CHANNEL_NUMBER_NONE 0
|
#define CHANNEL_NUMBER_NONE 0
|
||||||
#define DEFAULT_FLIGHT_MODE_NUMBER 0
|
#define DEFAULT_FLIGHT_MODE_NUMBER 1
|
||||||
|
|
||||||
ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
|
ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
|
||||||
ConfigTaskWidget(parent),
|
ConfigTaskWidget(parent),
|
||||||
@ -200,6 +200,8 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
|
|||||||
connect(ui->runCalibration, SIGNAL(toggled(bool)), this, SLOT(simpleCalibration(bool)));
|
connect(ui->runCalibration, SIGNAL(toggled(bool)), this, SLOT(simpleCalibration(bool)));
|
||||||
|
|
||||||
connect(ReceiverActivity::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateReceiverActivityStatus()));
|
connect(ReceiverActivity::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateReceiverActivityStatus()));
|
||||||
|
connect(FlightStatus::GetInstance(getObjectManager()), SIGNAL(objectUpdated(UAVObject *)), this, SLOT(updateReceiverActivityStatus()));
|
||||||
|
|
||||||
ui->receiverActivityStatus->setStyleSheet("QLabel { background-color: darkGreen; color: rgb(255, 255, 255); \
|
ui->receiverActivityStatus->setStyleSheet("QLabel { background-color: darkGreen; color: rgb(255, 255, 255); \
|
||||||
border: 1px solid grey; border-radius: 5; margin:1px; font:bold;}");
|
border: 1px solid grey; border-radius: 5; margin:1px; font:bold;}");
|
||||||
|
|
||||||
@ -440,6 +442,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) :
|
|||||||
|
|
||||||
groundChannelOrder << ManualControlSettings::CHANNELGROUPS_THROTTLE <<
|
groundChannelOrder << ManualControlSettings::CHANNELGROUPS_THROTTLE <<
|
||||||
ManualControlSettings::CHANNELGROUPS_YAW <<
|
ManualControlSettings::CHANNELGROUPS_YAW <<
|
||||||
|
ManualControlSettings::CHANNELGROUPS_FLIGHTMODE <<
|
||||||
ManualControlSettings::CHANNELGROUPS_ACCESSORY0;
|
ManualControlSettings::CHANNELGROUPS_ACCESSORY0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -662,12 +665,8 @@ void ConfigInputWidget::wzNext()
|
|||||||
throttleError = false;
|
throttleError = false;
|
||||||
checkThrottleRange();
|
checkThrottleRange();
|
||||||
|
|
||||||
// Force flight mode number to be 1 if 2 CH ground vehicle was selected
|
|
||||||
if (transmitterType == ground) {
|
|
||||||
forceOneFlightMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
manualSettingsObj->setData(manualSettingsData);
|
manualSettingsObj->setData(manualSettingsData);
|
||||||
|
|
||||||
// move to Arming Settings tab
|
// move to Arming Settings tab
|
||||||
ui->stackedWidget->setCurrentIndex(0);
|
ui->stackedWidget->setCurrentIndex(0);
|
||||||
ui->tabWidget->setCurrentIndex(3);
|
ui->tabWidget->setCurrentIndex(3);
|
||||||
@ -843,12 +842,12 @@ void ConfigInputWidget::wizardSetUpStep(enum wizardSteps step)
|
|||||||
extraWidgets.clear();
|
extraWidgets.clear();
|
||||||
for (int index = 0; index < manualSettingsObj->getField("ChannelMax")->getElementNames().length(); index++) {
|
for (int index = 0; index < manualSettingsObj->getField("ChannelMax")->getElementNames().length(); index++) {
|
||||||
QString name = manualSettingsObj->getField("ChannelMax")->getElementNames().at(index);
|
QString name = manualSettingsObj->getField("ChannelMax")->getElementNames().at(index);
|
||||||
if (!name.contains("Access") && !name.contains("Flight") &&
|
if (!name.contains("Access") && !name.contains("Flight") && !name.contains("Rssi") &&
|
||||||
(!name.contains("Collective") || transmitterType == heli)) {
|
(!name.contains("Collective") || transmitterType == heli)) {
|
||||||
QCheckBox *cb = new QCheckBox(name, this);
|
QCheckBox *cb = new QCheckBox(name, this);
|
||||||
// Make sure checked status matches current one
|
// Make sure checked status matches current one
|
||||||
cb->setChecked(manualSettingsData.ChannelMax[index] < manualSettingsData.ChannelMin[index]);
|
cb->setChecked(manualSettingsData.ChannelMax[index] < manualSettingsData.ChannelMin[index]);
|
||||||
wizardUi->checkBoxesLayout->addWidget(cb, extraWidgets.size() / 4, extraWidgets.size() % 4);
|
wizardUi->checkBoxesLayout->addWidget(cb, extraWidgets.size() / 5, extraWidgets.size() % 5);
|
||||||
extraWidgets.append(cb);
|
extraWidgets.append(cb);
|
||||||
connect(cb, SIGNAL(toggled(bool)), this, SLOT(invertControls()));
|
connect(cb, SIGNAL(toggled(bool)), this, SLOT(invertControls()));
|
||||||
}
|
}
|
||||||
@ -917,12 +916,6 @@ void ConfigInputWidget::wizardTearDownStep(enum wizardSteps step)
|
|||||||
disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(identifyControls()));
|
disconnect(receiverActivityObj, SIGNAL(objectUpdated(UAVObject *)), this, SLOT(identifyControls()));
|
||||||
wizardUi->wzNext->setEnabled(true);
|
wizardUi->wzNext->setEnabled(true);
|
||||||
setTxMovement(nothing);
|
setTxMovement(nothing);
|
||||||
/* If flight mode stick isn't identified, force flight mode number to be 1 */
|
|
||||||
manualSettingsData = manualSettingsObj->getData();
|
|
||||||
if (manualSettingsData.ChannelGroups[ManualControlSettings::CHANNELNUMBER_FLIGHTMODE] ==
|
|
||||||
ManualControlSettings::CHANNELGROUPS_NONE) {
|
|
||||||
forceOneFlightMode();
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case wizardIdentifyCenter:
|
case wizardIdentifyCenter:
|
||||||
manualCommandData = manualCommandObj->getData();
|
manualCommandData = manualCommandObj->getData();
|
||||||
@ -1182,6 +1175,7 @@ void ConfigInputWidget::identifyControls()
|
|||||||
void ConfigInputWidget::identifyLimits()
|
void ConfigInputWidget::identifyLimits()
|
||||||
{
|
{
|
||||||
uint16_t inputValue;
|
uint16_t inputValue;
|
||||||
|
static uint16_t previousInputFMValue;
|
||||||
bool newLimitValue = false;
|
bool newLimitValue = false;
|
||||||
bool newFlightModeValue = false;
|
bool newFlightModeValue = false;
|
||||||
|
|
||||||
@ -1214,32 +1208,37 @@ void ConfigInputWidget::identifyLimits()
|
|||||||
}
|
}
|
||||||
// Flightmode channel
|
// Flightmode channel
|
||||||
if (i == ManualControlSettings::CHANNELGROUPS_FLIGHTMODE) {
|
if (i == ManualControlSettings::CHANNELGROUPS_FLIGHTMODE) {
|
||||||
// Avoid duplicate values too close and error due to RcTx drift
|
int deltaInput = abs(previousInputFMValue - inputValue);
|
||||||
int minSpacing = 100; // 100µs
|
previousInputFMValue = inputValue;
|
||||||
for (int pos = 0; pos < manualSettingsData.FlightModeNumber + 1; ++pos) {
|
// Expecting two consecutive readings within a close value
|
||||||
if (flightModeSignalValue[pos] == 0) {
|
if (deltaInput < 5) {
|
||||||
newFlightModeValue = true;
|
// Avoid duplicate values too close and error due to RcTx drift
|
||||||
// A new flightmode value can be set now
|
int minSpacing = 100; // 100µs
|
||||||
for (int checkpos = 0; checkpos < manualSettingsData.FlightModeNumber + 1; ++checkpos) {
|
for (int pos = 0; pos < manualSettingsData.FlightModeNumber + 1; ++pos) {
|
||||||
// Check if value is already used, MinSpacing needed between values.
|
if (flightModeSignalValue[pos] == 0) {
|
||||||
if ((flightModeSignalValue[checkpos] < inputValue + minSpacing) &&
|
newFlightModeValue = true;
|
||||||
(flightModeSignalValue[checkpos] > inputValue - minSpacing)) {
|
// A new flightmode value can be set now
|
||||||
newFlightModeValue = false;
|
for (int checkpos = 0; checkpos < manualSettingsData.FlightModeNumber + 1; ++checkpos) {
|
||||||
|
// Check if value is already used, MinSpacing needed between values.
|
||||||
|
if ((flightModeSignalValue[checkpos] < inputValue + minSpacing) &&
|
||||||
|
(flightModeSignalValue[checkpos] > inputValue - minSpacing)) {
|
||||||
|
newFlightModeValue = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
// Be sure FlightModeNumber is < FlightModeSettings::FLIGHTMODEPOSITION_NUMELEM (6)
|
||||||
// Be sure FlightModeNumber is < FlightModeSettings::FLIGHTMODEPOSITION_NUMELEM (6)
|
if ((manualSettingsData.FlightModeNumber < FlightModeSettings::FLIGHTMODEPOSITION_NUMELEM) && newFlightModeValue) {
|
||||||
if ((manualSettingsData.FlightModeNumber < FlightModeSettings::FLIGHTMODEPOSITION_NUMELEM) && newFlightModeValue) {
|
// Start from 0, erase previous count
|
||||||
// Start from 0, erase previous count
|
if (pos == 0) {
|
||||||
if (pos == 0) {
|
manualSettingsData.FlightModeNumber = 0;
|
||||||
manualSettingsData.FlightModeNumber = 0;
|
}
|
||||||
|
// Store new value and increase FlightModeNumber
|
||||||
|
flightModeSignalValue[pos] = inputValue;
|
||||||
|
manualSettingsData.FlightModeNumber++;
|
||||||
|
// Show flight mode number
|
||||||
|
m_txFlightModeCountText->setText(QString().number(manualSettingsData.FlightModeNumber));
|
||||||
|
m_txFlightModeCountText->setVisible(true);
|
||||||
|
m_txFlightModeCountBG->setVisible(true);
|
||||||
}
|
}
|
||||||
// Store new value and increase FlightModeNumber
|
|
||||||
flightModeSignalValue[pos] = inputValue;
|
|
||||||
manualSettingsData.FlightModeNumber++;
|
|
||||||
// Show flight mode number
|
|
||||||
m_txFlightModeCountText->setText(QString().number(manualSettingsData.FlightModeNumber));
|
|
||||||
m_txFlightModeCountText->setVisible(true);
|
|
||||||
m_txFlightModeCountBG->setVisible(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2013,11 +2012,6 @@ void ConfigInputWidget::simpleCalibration(bool enable)
|
|||||||
|
|
||||||
restoreMdataSingle(manualCommandObj, &manualControlMdata);
|
restoreMdataSingle(manualCommandObj, &manualControlMdata);
|
||||||
|
|
||||||
// Force flight mode number to be 1 if 2 channel ground vehicle was confirmed
|
|
||||||
if (transmitterType == ground) {
|
|
||||||
forceOneFlightMode();
|
|
||||||
}
|
|
||||||
|
|
||||||
for (unsigned int i = 0; i < ManualControlSettings::CHANNELNUMBER_RSSI; i++) {
|
for (unsigned int i = 0; i < ManualControlSettings::CHANNELNUMBER_RSSI; i++) {
|
||||||
if ((i == ManualControlSettings::CHANNELNUMBER_FLIGHTMODE) || (i == ManualControlSettings::CHANNELNUMBER_THROTTLE)) {
|
if ((i == ManualControlSettings::CHANNELNUMBER_FLIGHTMODE) || (i == ManualControlSettings::CHANNELNUMBER_THROTTLE)) {
|
||||||
adjustSpecialNeutrals();
|
adjustSpecialNeutrals();
|
||||||
@ -2148,19 +2142,16 @@ void ConfigInputWidget::resetActuatorSettings()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void ConfigInputWidget::forceOneFlightMode()
|
|
||||||
{
|
|
||||||
manualSettingsData = manualSettingsObj->getData();
|
|
||||||
manualSettingsData.FlightModeNumber = 1;
|
|
||||||
manualSettingsObj->setData(manualSettingsData);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ConfigInputWidget::updateReceiverActivityStatus()
|
void ConfigInputWidget::updateReceiverActivityStatus()
|
||||||
{
|
{
|
||||||
ReceiverActivity *receiverActivity = ReceiverActivity::GetInstance(getObjectManager());
|
ReceiverActivity *receiverActivity = ReceiverActivity::GetInstance(getObjectManager());
|
||||||
|
|
||||||
Q_ASSERT(receiverActivity);
|
Q_ASSERT(receiverActivity);
|
||||||
|
|
||||||
|
FlightStatus *flightStatus = FlightStatus::GetInstance(getObjectManager());
|
||||||
|
|
||||||
|
Q_ASSERT(flightStatus);
|
||||||
|
|
||||||
UAVObjectField *activeGroup = receiverActivity->getField(QString("ActiveGroup"));
|
UAVObjectField *activeGroup = receiverActivity->getField(QString("ActiveGroup"));
|
||||||
Q_ASSERT(activeGroup);
|
Q_ASSERT(activeGroup);
|
||||||
|
|
||||||
@ -2170,12 +2161,15 @@ void ConfigInputWidget::updateReceiverActivityStatus()
|
|||||||
QString activeGroupText = activeGroup->getValue().toString();
|
QString activeGroupText = activeGroup->getValue().toString();
|
||||||
QString activeChannelText = activeChannel->getValue().toString();
|
QString activeChannelText = activeChannel->getValue().toString();
|
||||||
|
|
||||||
|
|
||||||
if (activeGroupText != "None") {
|
if (activeGroupText != "None") {
|
||||||
ui->receiverActivityStatus->setText(tr("%1 input - Channel %2").arg(activeGroupText).arg(activeChannelText));
|
ui->receiverActivityStatus->setText(tr("%1 input - Channel %2").arg(activeGroupText).arg(activeChannelText));
|
||||||
ui->receiverActivityStatus->setStyleSheet("QLabel { background-color: green; color: rgb(255, 255, 255); \
|
ui->receiverActivityStatus->setStyleSheet("QLabel { background-color: green; color: rgb(255, 255, 255); \
|
||||||
border: 1px solid grey; border-radius: 5; margin:1px; font:bold;}");
|
border: 1px solid grey; border-radius: 5; margin:1px; font:bold;}");
|
||||||
} else {
|
} else {
|
||||||
ui->receiverActivityStatus->setText(tr("No activity"));
|
bool armed = (flightStatus->getArmed() == FlightStatus::ARMED_ARMED);
|
||||||
|
QString receiverActivityText = armed ? tr("Disabled (Armed)") : tr("No activity");
|
||||||
|
ui->receiverActivityStatus->setText(receiverActivityText);
|
||||||
ui->receiverActivityStatus->setStyleSheet("QLabel { background-color: darkGreen; color: rgb(255, 255, 255); \
|
ui->receiverActivityStatus->setStyleSheet("QLabel { background-color: darkGreen; color: rgb(255, 255, 255); \
|
||||||
border: 1px solid grey; border-radius: 5; margin:1px; font:bold;}");
|
border: 1px solid grey; border-radius: 5; margin:1px; font:bold;}");
|
||||||
}
|
}
|
||||||
|
@ -228,7 +228,6 @@ private slots:
|
|||||||
void resetChannelSettings();
|
void resetChannelSettings();
|
||||||
void resetFlightModeSettings();
|
void resetFlightModeSettings();
|
||||||
void resetActuatorSettings();
|
void resetActuatorSettings();
|
||||||
void forceOneFlightMode();
|
|
||||||
void updateReceiverActivityStatus();
|
void updateReceiverActivityStatus();
|
||||||
|
|
||||||
void failsafeFlightModeChanged(int index);
|
void failsafeFlightModeChanged(int index);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user