mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-02 10:24:11 +01:00
Merge remote-tracking branch 'origin/os/features/stick-deadband-next' into next
Conflicts: ground/openpilotgcs/src/plugins/config/configinputwidget.cpp
This commit is contained in:
commit
6350ec575e
@ -88,6 +88,7 @@ static float scaleChannel(int16_t value, int16_t max, int16_t min, int16_t neutr
|
|||||||
static uint32_t timeDifferenceMs(portTickType start_time, portTickType end_time);
|
static uint32_t timeDifferenceMs(portTickType start_time, portTickType end_time);
|
||||||
static bool okToArm(void);
|
static bool okToArm(void);
|
||||||
static bool validInputRange(int16_t min, int16_t max, uint16_t value);
|
static bool validInputRange(int16_t min, int16_t max, uint16_t value);
|
||||||
|
static void applyDeadband(float *value, float deadband);
|
||||||
|
|
||||||
#define RCVR_ACTIVITY_MONITOR_CHANNELS_PER_GROUP 12
|
#define RCVR_ACTIVITY_MONITOR_CHANNELS_PER_GROUP 12
|
||||||
#define RCVR_ACTIVITY_MONITOR_MIN_RANGE 10
|
#define RCVR_ACTIVITY_MONITOR_MIN_RANGE 10
|
||||||
@ -317,6 +318,13 @@ static void manualControlTask(void *parameters)
|
|||||||
cmd.Throttle = scaledChannel[MANUALCONTROLSETTINGS_CHANNELGROUPS_THROTTLE];
|
cmd.Throttle = scaledChannel[MANUALCONTROLSETTINGS_CHANNELGROUPS_THROTTLE];
|
||||||
flightMode = scaledChannel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE];
|
flightMode = scaledChannel[MANUALCONTROLSETTINGS_CHANNELGROUPS_FLIGHTMODE];
|
||||||
|
|
||||||
|
// Apply deadband for Roll/Pitch/Yaw stick inputs
|
||||||
|
if (settings.Deadband) {
|
||||||
|
applyDeadband(&cmd.Roll, settings.Deadband);
|
||||||
|
applyDeadband(&cmd.Pitch, settings.Deadband);
|
||||||
|
applyDeadband(&cmd.Yaw, settings.Deadband);
|
||||||
|
}
|
||||||
|
|
||||||
if(cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_COLLECTIVE] != PIOS_RCVR_INVALID &&
|
if(cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_COLLECTIVE] != PIOS_RCVR_INVALID &&
|
||||||
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_COLLECTIVE] != PIOS_RCVR_NODRIVER &&
|
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_COLLECTIVE] != PIOS_RCVR_NODRIVER &&
|
||||||
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_COLLECTIVE] != PIOS_RCVR_TIMEOUT)
|
cmd.Channel[MANUALCONTROLSETTINGS_CHANNELGROUPS_COLLECTIVE] != PIOS_RCVR_TIMEOUT)
|
||||||
@ -821,6 +829,20 @@ bool validInputRange(int16_t min, int16_t max, uint16_t value)
|
|||||||
return (value >= min - CONNECTION_OFFSET && value <= max + CONNECTION_OFFSET);
|
return (value >= min - CONNECTION_OFFSET && value <= max + CONNECTION_OFFSET);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Apply deadband to Roll/Pitch/Yaw channels
|
||||||
|
*/
|
||||||
|
static void applyDeadband(float *value, float deadband)
|
||||||
|
{
|
||||||
|
if (fabs(*value) < deadband)
|
||||||
|
*value = 0.0f;
|
||||||
|
else
|
||||||
|
if (*value > 0.0f)
|
||||||
|
*value -= deadband;
|
||||||
|
else
|
||||||
|
*value += deadband;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @}
|
* @}
|
||||||
* @}
|
* @}
|
||||||
|
@ -57,7 +57,7 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
|||||||
addApplySaveButtons(m_config->saveRCInputToRAM,m_config->saveRCInputToSD);
|
addApplySaveButtons(m_config->saveRCInputToRAM,m_config->saveRCInputToSD);
|
||||||
|
|
||||||
unsigned int index=0;
|
unsigned int index=0;
|
||||||
foreach(QString name,manualSettingsObj->getField("ChannelNumber")->getElementNames())
|
foreach (QString name, manualSettingsObj->getField("ChannelNumber")->getElementNames())
|
||||||
{
|
{
|
||||||
Q_ASSERT(index < ManualControlSettings::CHANNELGROUPS_NUMELEM);
|
Q_ASSERT(index < ManualControlSettings::CHANNELGROUPS_NUMELEM);
|
||||||
inputChannelForm * inp=new inputChannelForm(this,index==0);
|
inputChannelForm * inp=new inputChannelForm(this,index==0);
|
||||||
@ -70,6 +70,9 @@ ConfigInputWidget::ConfigInputWidget(QWidget *parent) : ConfigTaskWidget(parent)
|
|||||||
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelMax",inp->ui->channelMax,index);
|
addUAVObjectToWidgetRelation("ManualControlSettings","ChannelMax",inp->ui->channelMax,index);
|
||||||
++index;
|
++index;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
addUAVObjectToWidgetRelation("ManualControlSettings", "Deadband", m_config->deadband, 0, 0.01f);
|
||||||
|
|
||||||
connect(m_config->configurationWizard,SIGNAL(clicked()),this,SLOT(goToWizard()));
|
connect(m_config->configurationWizard,SIGNAL(clicked()),this,SLOT(goToWizard()));
|
||||||
connect(m_config->runCalibration,SIGNAL(toggled(bool)),this, SLOT(simpleCalibration(bool)));
|
connect(m_config->runCalibration,SIGNAL(toggled(bool)),this, SLOT(simpleCalibration(bool)));
|
||||||
|
|
||||||
@ -1096,7 +1099,7 @@ void ConfigInputWidget::invertControls()
|
|||||||
QCheckBox * cb=qobject_cast<QCheckBox *>(wd);
|
QCheckBox * cb=qobject_cast<QCheckBox *>(wd);
|
||||||
if(cb)
|
if(cb)
|
||||||
{
|
{
|
||||||
int index=manualSettingsObj->getField("ChannelNumber")->getElementNames().indexOf(cb->text());
|
int index = manualSettingsObj->getField("ChannelNumber")->getElementNames().indexOf(cb->text());
|
||||||
if((cb->isChecked() && (manualSettingsData.ChannelMax[index]>manualSettingsData.ChannelMin[index])) ||
|
if((cb->isChecked() && (manualSettingsData.ChannelMax[index]>manualSettingsData.ChannelMin[index])) ||
|
||||||
(!cb->isChecked() && (manualSettingsData.ChannelMax[index]<manualSettingsData.ChannelMin[index])))
|
(!cb->isChecked() && (manualSettingsData.ChannelMax[index]<manualSettingsData.ChannelMin[index])))
|
||||||
{
|
{
|
||||||
|
@ -44,13 +44,85 @@ QGroupBox::title {
|
|||||||
<item row="0" column="0">
|
<item row="0" column="0">
|
||||||
<widget class="QStackedWidget" name="stackedWidget">
|
<widget class="QStackedWidget" name="stackedWidget">
|
||||||
<property name="currentIndex">
|
<property name="currentIndex">
|
||||||
<number>1</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QWidget" name="advancedPage">
|
<widget class="QWidget" name="advancedPage">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<layout class="QVBoxLayout" name="channelSettings"/>
|
<layout class="QVBoxLayout" name="channelSettings"/>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Preferred</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>5</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
|
<item row="0" column="0">
|
||||||
|
<widget class="QLabel" name="labelDeadband">
|
||||||
|
<property name="text">
|
||||||
|
<string>Roll/Pitch/Yaw stick deadband</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<widget class="QDoubleSpinBox" name="deadband">
|
||||||
|
<property name="toolTip">
|
||||||
|
<string>Stick deadband in percents of full range (0-10), zero to disable</string>
|
||||||
|
</property>
|
||||||
|
<property name="decimals">
|
||||||
|
<number>1</number>
|
||||||
|
</property>
|
||||||
|
<property name="maximum">
|
||||||
|
<double>10.000000000000000</double>
|
||||||
|
</property>
|
||||||
|
<property name="singleStep">
|
||||||
|
<double>0.100000000000000</double>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="3">
|
||||||
|
<spacer name="horizontalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>40</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeType">
|
||||||
|
<enum>QSizePolicy::Preferred</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>5</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QPushButton" name="configurationWizard">
|
<widget class="QPushButton" name="configurationWizard">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
<field name="ChannelMax" units="us" type="int16" defaultvalue="2000"
|
<field name="ChannelMax" units="us" type="int16" defaultvalue="2000"
|
||||||
elementnames="Throttle,Roll,Pitch,Yaw,FlightMode,Collective,Accessory0,Accessory1,Accessory2"/>
|
elementnames="Throttle,Roll,Pitch,Yaw,FlightMode,Collective,Accessory0,Accessory1,Accessory2"/>
|
||||||
|
|
||||||
|
<field name="Deadband" units="%" type="float" elements="1" defaultvalue="0"/>
|
||||||
|
|
||||||
<field name="Arming" units="" type="enum" elements="1" options="Always Disarmed,Always Armed,Roll Left,Roll Right,Pitch Forward,Pitch Aft,Yaw Left,Yaw Right" defaultvalue="Always Disarmed"/>
|
<field name="Arming" units="" type="enum" elements="1" options="Always Disarmed,Always Armed,Roll Left,Roll Right,Pitch Forward,Pitch Aft,Yaw Left,Yaw Right" defaultvalue="Always Disarmed"/>
|
||||||
|
|
||||||
<!-- Note these options should be identical to those in StabilizationDesired.StabilizationMode -->
|
<!-- Note these options should be identical to those in StabilizationDesired.StabilizationMode -->
|
||||||
|
Loading…
Reference in New Issue
Block a user