@ -24,14 +24,14 @@
@@ -24,14 +24,14 @@
/// @file
/// @author Don Gagne <don@thegagnes.com>
# include "FlightModesComponent Controller.h"
# include "PX4Advanced FlightModesController.h"
# include "QGCMAVLink.h"
# include "AutoPilotPluginManager.h"
# include <QVariant>
# include <QQmlProperty>
FlightModesComponent Controller : : FlightModesComponent Controller ( void ) :
PX4Advanced FlightModesController: : PX4Advanced FlightModesController( void ) :
_validConfiguration ( false ) ,
_channelCount ( 18 ) ,
_manualModeSelected ( false ) ,
@ -55,10 +55,10 @@ FlightModesComponentController::FlightModesComponentController(void) :
@@ -55,10 +55,10 @@ FlightModesComponentController::FlightModesComponentController(void) :
_init ( ) ;
_validateConfiguration ( ) ;
connect ( _vehicle , & Vehicle : : rcChannelsChanged , this , & FlightModesComponent Controller : : _rcChannelsChanged ) ;
connect ( _vehicle , & Vehicle : : rcChannelsChanged , this , & PX4Advanced FlightModesController: : _rcChannelsChanged ) ;
}
void FlightModesComponent Controller : : _init ( void )
void PX4Advanced FlightModesController: : _init ( void )
{
// FIXME: What about VTOL? That confuses the whole Flight Mode naming scheme
_fixedWing = _vehicle - > vehicleType ( ) = = MAV_TYPE_FIXED_WING ;
@ -151,7 +151,7 @@ void FlightModesComponentController::_init(void)
@@ -151,7 +151,7 @@ void FlightModesComponentController::_init(void)
/// This will look for parameter settings which would cause the config to not run correctly.
/// It will set _validConfiguration and _configurationErrors as needed.
void FlightModesComponent Controller : : _validateConfiguration ( void )
void PX4Advanced FlightModesController: : _validateConfiguration ( void )
{
_validConfiguration = true ;
@ -205,7 +205,7 @@ void FlightModesComponentController::_validateConfiguration(void)
@@ -205,7 +205,7 @@ void FlightModesComponentController::_validateConfiguration(void)
}
/// Connected to Vehicle::rcChannelsChanged signal
void FlightModesComponent Controller : : _rcChannelsChanged ( int channelCount , int pwmValues [ Vehicle : : cMaxRcChannels ] )
void PX4Advanced FlightModesController: : _rcChannelsChanged ( int channelCount , int pwmValues [ Vehicle : : cMaxRcChannels ] )
{
for ( int channel = 0 ; channel < channelCount ; channel + + ) {
int channelValue = pwmValues [ channel ] ;
@ -232,7 +232,7 @@ void FlightModesComponentController::_rcChannelsChanged(int channelCount, int pw
@@ -232,7 +232,7 @@ void FlightModesComponentController::_rcChannelsChanged(int channelCount, int pw
emit switchLiveRangeChanged ( ) ;
}
double FlightModesComponent Controller : : _switchLiveRange ( const QString & param )
double PX4Advanced FlightModesController: : _switchLiveRange ( const QString & param )
{
QVariant value ;
@ -244,27 +244,27 @@ double FlightModesComponentController::_switchLiveRange(const QString& param)
@@ -244,27 +244,27 @@ double FlightModesComponentController::_switchLiveRange(const QString& param)
}
}
double FlightModesComponent Controller : : manualModeRcValue ( void )
double PX4Advanced FlightModesController: : manualModeRcValue ( void )
{
return _switchLiveRange ( " RC_MAP_MODE_SW " ) ;
}
double FlightModesComponent Controller : : assistModeRcValue ( void )
double PX4Advanced FlightModesController: : assistModeRcValue ( void )
{
return manualModeRcValue ( ) ;
}
double FlightModesComponent Controller : : autoModeRcValue ( void )
double PX4Advanced FlightModesController: : autoModeRcValue ( void )
{
return manualModeRcValue ( ) ;
}
double FlightModesComponent Controller : : acroModeRcValue ( void )
double PX4Advanced FlightModesController: : acroModeRcValue ( void )
{
return _switchLiveRange ( " RC_MAP_ACRO_SW " ) ;
}
double FlightModesComponent Controller : : altCtlModeRcValue ( void )
double PX4Advanced FlightModesController: : altCtlModeRcValue ( void )
{
int posCtlSwitchChannel = getParameterFact ( - 1 , " RC_MAP_POSCTL_SW " ) - > rawValue ( ) . toInt ( ) ;
@ -275,12 +275,12 @@ double FlightModesComponentController::altCtlModeRcValue(void)
@@ -275,12 +275,12 @@ double FlightModesComponentController::altCtlModeRcValue(void)
}
}
double FlightModesComponent Controller : : posCtlModeRcValue ( void )
double PX4Advanced FlightModesController: : posCtlModeRcValue ( void )
{
return _switchLiveRange ( " RC_MAP_POSCTL_SW " ) ;
}
double FlightModesComponent Controller : : missionModeRcValue ( void )
double PX4Advanced FlightModesController: : missionModeRcValue ( void )
{
int returnSwitchChannel = getParameterFact ( - 1 , " RC_MAP_RETURN_SW " ) - > rawValue ( ) . toInt ( ) ;
int loiterSwitchChannel = getParameterFact ( - 1 , " RC_MAP_LOITER_SW " ) - > rawValue ( ) . toInt ( ) ;
@ -302,22 +302,22 @@ double FlightModesComponentController::missionModeRcValue(void)
@@ -302,22 +302,22 @@ double FlightModesComponentController::missionModeRcValue(void)
return _switchLiveRange ( switchChannelParam ) ;
}
double FlightModesComponent Controller : : loiterModeRcValue ( void )
double PX4Advanced FlightModesController: : loiterModeRcValue ( void )
{
return _switchLiveRange ( " RC_MAP_LOITER_SW " ) ;
}
double FlightModesComponent Controller : : returnModeRcValue ( void )
double PX4Advanced FlightModesController: : returnModeRcValue ( void )
{
return _switchLiveRange ( " RC_MAP_RETURN_SW " ) ;
}
double FlightModesComponent Controller : : offboardModeRcValue ( void )
double PX4Advanced FlightModesController: : offboardModeRcValue ( void )
{
return _switchLiveRange ( " RC_MAP_OFFB_SW " ) ;
}
void FlightModesComponent Controller : : _recalcModeSelections ( void )
void PX4Advanced FlightModesController: : _recalcModeSelections ( void )
{
_manualModeSelected = false ;
_assistModeSelected = false ;
@ -377,7 +377,7 @@ void FlightModesComponentController::_recalcModeSelections(void)
@@ -377,7 +377,7 @@ void FlightModesComponentController::_recalcModeSelections(void)
emit modesSelectedChanged ( ) ;
}
void FlightModesComponent Controller : : _recalcModeRows ( void )
void PX4Advanced FlightModesController: : _recalcModeRows ( void )
{
int modeSwitchChannel = getParameterFact ( - 1 , " RC_MAP_MODE_SW " ) - > rawValue ( ) . toInt ( ) ;
int acroSwitchChannel = getParameterFact ( - 1 , " RC_MAP_ACRO_SW " ) - > rawValue ( ) . toInt ( ) ;
@ -467,140 +467,140 @@ void FlightModesComponentController::_recalcModeRows(void)
@@ -467,140 +467,140 @@ void FlightModesComponentController::_recalcModeRows(void)
emit modeRowsChanged ( ) ;
}
double FlightModesComponent Controller : : manualModeThreshold ( void )
double PX4Advanced FlightModesController: : manualModeThreshold ( void )
{
return 0.0 ;
}
double FlightModesComponent Controller : : assistModeThreshold ( void )
double PX4Advanced FlightModesController: : assistModeThreshold ( void )
{
return getParameterFact ( - 1 , " RC_ASSIST_TH " ) - > rawValue ( ) . toDouble ( ) ;
}
double FlightModesComponent Controller : : autoModeThreshold ( void )
double PX4Advanced FlightModesController: : autoModeThreshold ( void )
{
return getParameterFact ( - 1 , " RC_AUTO_TH " ) - > rawValue ( ) . toDouble ( ) ;
}
double FlightModesComponent Controller : : acroModeThreshold ( void )
double PX4Advanced FlightModesController: : acroModeThreshold ( void )
{
return getParameterFact ( - 1 , " RC_ACRO_TH " ) - > rawValue ( ) . toDouble ( ) ;
}
double FlightModesComponent Controller : : altCtlModeThreshold ( void )
double PX4Advanced FlightModesController: : altCtlModeThreshold ( void )
{
return _assistModeVisible ? 0.0 : getParameterFact ( - 1 , " RC_ASSIST_TH " ) - > rawValue ( ) . toDouble ( ) ;
}
double FlightModesComponent Controller : : posCtlModeThreshold ( void )
double PX4Advanced FlightModesController: : posCtlModeThreshold ( void )
{
return getParameterFact ( - 1 , " RC_POSCTL_TH " ) - > rawValue ( ) . toDouble ( ) ;
}
double FlightModesComponent Controller : : missionModeThreshold ( void )
double PX4Advanced FlightModesController: : missionModeThreshold ( void )
{
return _autoModeVisible ? 0.0 : getParameterFact ( - 1 , " RC_AUTO_TH " ) - > rawValue ( ) . toDouble ( ) ;
}
double FlightModesComponent Controller : : loiterModeThreshold ( void )
double PX4Advanced FlightModesController: : loiterModeThreshold ( void )
{
return getParameterFact ( - 1 , " RC_LOITER_TH " ) - > rawValue ( ) . toDouble ( ) ;
}
double FlightModesComponent Controller : : returnModeThreshold ( void )
double PX4Advanced FlightModesController: : returnModeThreshold ( void )
{
return getParameterFact ( - 1 , " RC_RETURN_TH " ) - > rawValue ( ) . toDouble ( ) ;
}
double FlightModesComponent Controller : : offboardModeThreshold ( void )
double PX4Advanced FlightModesController: : offboardModeThreshold ( void )
{
return getParameterFact ( - 1 , " RC_OFFB_TH " ) - > rawValue ( ) . toDouble ( ) ;
}
void FlightModesComponent Controller : : setAssistModeThreshold ( double threshold )
void PX4Advanced FlightModesController: : setAssistModeThreshold ( double threshold )
{
getParameterFact ( - 1 , " RC_ASSIST_TH " ) - > setRawValue ( threshold ) ;
_recalcModeSelections ( ) ;
}
void FlightModesComponent Controller : : setAutoModeThreshold ( double threshold )
void PX4Advanced FlightModesController: : setAutoModeThreshold ( double threshold )
{
getParameterFact ( - 1 , " RC_AUTO_TH " ) - > setRawValue ( threshold ) ;
_recalcModeSelections ( ) ;
}
void FlightModesComponent Controller : : setAcroModeThreshold ( double threshold )
void PX4Advanced FlightModesController: : setAcroModeThreshold ( double threshold )
{
getParameterFact ( - 1 , " RC_ACRO_TH " ) - > setRawValue ( threshold ) ;
_recalcModeSelections ( ) ;
}
void FlightModesComponent Controller : : setAltCtlModeThreshold ( double threshold )
void PX4Advanced FlightModesController: : setAltCtlModeThreshold ( double threshold )
{
setAssistModeThreshold ( threshold ) ;
}
void FlightModesComponent Controller : : setPosCtlModeThreshold ( double threshold )
void PX4Advanced FlightModesController: : setPosCtlModeThreshold ( double threshold )
{
getParameterFact ( - 1 , " RC_POSCTL_TH " ) - > setRawValue ( threshold ) ;
_recalcModeSelections ( ) ;
}
void FlightModesComponent Controller : : setMissionModeThreshold ( double threshold )
void PX4Advanced FlightModesController: : setMissionModeThreshold ( double threshold )
{
setAutoModeThreshold ( threshold ) ;
}
void FlightModesComponent Controller : : setLoiterModeThreshold ( double threshold )
void PX4Advanced FlightModesController: : setLoiterModeThreshold ( double threshold )
{
getParameterFact ( - 1 , " RC_LOITER_TH " ) - > setRawValue ( threshold ) ;
_recalcModeSelections ( ) ;
}
void FlightModesComponent Controller : : setReturnModeThreshold ( double threshold )
void PX4Advanced FlightModesController: : setReturnModeThreshold ( double threshold )
{
getParameterFact ( - 1 , " RC_RETURN_TH " ) - > setRawValue ( threshold ) ;
_recalcModeSelections ( ) ;
}
void FlightModesComponent Controller : : setOffboardModeThreshold ( double threshold )
void PX4Advanced FlightModesController: : setOffboardModeThreshold ( double threshold )
{
getParameterFact ( - 1 , " RC_OFFB_TH " ) - > setRawValue ( threshold ) ;
_recalcModeSelections ( ) ;
}
int FlightModesComponent Controller : : _channelToChannelIndex ( int channel )
int PX4Advanced FlightModesController: : _channelToChannelIndex ( int channel )
{
return _channelListModelChannel . lastIndexOf ( channel ) ;
}
int FlightModesComponent Controller : : _channelToChannelIndex ( const QString & channelParam )
int PX4Advanced FlightModesController: : _channelToChannelIndex ( const QString & channelParam )
{
return _channelToChannelIndex ( getParameterFact ( - 1 , channelParam ) - > rawValue ( ) . toInt ( ) ) ;
}
int FlightModesComponent Controller : : manualModeChannelIndex ( void )
int PX4Advanced FlightModesController: : manualModeChannelIndex ( void )
{
return _channelToChannelIndex ( " RC_MAP_MODE_SW " ) ;
}
int FlightModesComponent Controller : : assistModeChannelIndex ( void )
int PX4Advanced FlightModesController: : assistModeChannelIndex ( void )
{
return _channelToChannelIndex ( " RC_MAP_MODE_SW " ) ;
}
int FlightModesComponent Controller : : autoModeChannelIndex ( void )
int PX4Advanced FlightModesController: : autoModeChannelIndex ( void )
{
return _channelToChannelIndex ( " RC_MAP_MODE_SW " ) ;
}
int FlightModesComponent Controller : : acroModeChannelIndex ( void )
int PX4Advanced FlightModesController: : acroModeChannelIndex ( void )
{
return _channelToChannelIndex ( " RC_MAP_ACRO_SW " ) ;
}
int FlightModesComponent Controller : : altCtlModeChannelIndex ( void )
int PX4Advanced FlightModesController: : altCtlModeChannelIndex ( void )
{
int posCtlSwitchChannel = getParameterFact ( - 1 , " RC_MAP_POSCTL_SW " ) - > rawValue ( ) . toInt ( ) ;
@ -611,17 +611,17 @@ int FlightModesComponentController::altCtlModeChannelIndex(void)
@@ -611,17 +611,17 @@ int FlightModesComponentController::altCtlModeChannelIndex(void)
}
}
int FlightModesComponent Controller : : posCtlModeChannelIndex ( void )
int PX4Advanced FlightModesController: : posCtlModeChannelIndex ( void )
{
return _channelToChannelIndex ( " RC_MAP_POSCTL_SW " ) ;
}
int FlightModesComponent Controller : : loiterModeChannelIndex ( void )
int PX4Advanced FlightModesController: : loiterModeChannelIndex ( void )
{
return _channelToChannelIndex ( " RC_MAP_LOITER_SW " ) ;
}
int FlightModesComponent Controller : : missionModeChannelIndex ( void )
int PX4Advanced FlightModesController: : missionModeChannelIndex ( void )
{
int loiterSwitchChannel = getParameterFact ( - 1 , " RC_MAP_LOITER_SW " ) - > rawValue ( ) . toInt ( ) ;
@ -632,22 +632,22 @@ int FlightModesComponentController::missionModeChannelIndex(void)
@@ -632,22 +632,22 @@ int FlightModesComponentController::missionModeChannelIndex(void)
}
}
int FlightModesComponent Controller : : returnModeChannelIndex ( void )
int PX4Advanced FlightModesController: : returnModeChannelIndex ( void )
{
return _channelToChannelIndex ( " RC_MAP_RETURN_SW " ) ;
}
int FlightModesComponent Controller : : offboardModeChannelIndex ( void )
int PX4Advanced FlightModesController: : offboardModeChannelIndex ( void )
{
return _channelToChannelIndex ( " RC_MAP_OFFB_SW " ) ;
}
int FlightModesComponent Controller : : _channelIndexToChannel ( int index )
int PX4Advanced FlightModesController: : _channelIndexToChannel ( int index )
{
return _channelListModelChannel [ index ] ;
}
void FlightModesComponent Controller : : setManualModeChannelIndex ( int index )
void PX4Advanced FlightModesController: : setManualModeChannelIndex ( int index )
{
getParameterFact ( - 1 , " RC_MAP_MODE_SW " ) - > setRawValue ( _channelIndexToChannel ( index ) ) ;
@ -657,7 +657,7 @@ void FlightModesComponentController::setManualModeChannelIndex(int index)
@@ -657,7 +657,7 @@ void FlightModesComponentController::setManualModeChannelIndex(int index)
}
void FlightModesComponent Controller : : setAcroModeChannelIndex ( int index )
void PX4Advanced FlightModesController: : setAcroModeChannelIndex ( int index )
{
getParameterFact ( - 1 , " RC_MAP_ACRO_SW " ) - > setRawValue ( _channelIndexToChannel ( index ) ) ;
@ -665,7 +665,7 @@ void FlightModesComponentController::setAcroModeChannelIndex(int index)
@@ -665,7 +665,7 @@ void FlightModesComponentController::setAcroModeChannelIndex(int index)
_recalcModeRows ( ) ;
}
void FlightModesComponent Controller : : setPosCtlModeChannelIndex ( int index )
void PX4Advanced FlightModesController: : setPosCtlModeChannelIndex ( int index )
{
int channel = _channelIndexToChannel ( index ) ;
@ -687,7 +687,7 @@ void FlightModesComponentController::setPosCtlModeChannelIndex(int index)
@@ -687,7 +687,7 @@ void FlightModesComponentController::setPosCtlModeChannelIndex(int index)
}
void FlightModesComponent Controller : : setLoiterModeChannelIndex ( int index )
void PX4Advanced FlightModesController: : setLoiterModeChannelIndex ( int index )
{
int channel = _channelIndexToChannel ( index ) ;
@ -709,7 +709,7 @@ void FlightModesComponentController::setLoiterModeChannelIndex(int index)
@@ -709,7 +709,7 @@ void FlightModesComponentController::setLoiterModeChannelIndex(int index)
}
void FlightModesComponent Controller : : setReturnModeChannelIndex ( int index )
void PX4Advanced FlightModesController: : setReturnModeChannelIndex ( int index )
{
getParameterFact ( - 1 , " RC_MAP_RETURN_SW " ) - > setRawValue ( _channelIndexToChannel ( index ) ) ;
_recalcModeSelections ( ) ;
@ -718,7 +718,7 @@ void FlightModesComponentController::setReturnModeChannelIndex(int index)
@@ -718,7 +718,7 @@ void FlightModesComponentController::setReturnModeChannelIndex(int index)
}
void FlightModesComponent Controller : : setOffboardModeChannelIndex ( int index )
void PX4Advanced FlightModesController: : setOffboardModeChannelIndex ( int index )
{
getParameterFact ( - 1 , " RC_MAP_OFFB_SW " ) - > setRawValue ( _channelIndexToChannel ( index ) ) ;
_recalcModeSelections ( ) ;
@ -727,7 +727,7 @@ void FlightModesComponentController::setOffboardModeChannelIndex(int index)
@@ -727,7 +727,7 @@ void FlightModesComponentController::setOffboardModeChannelIndex(int index)
}
void FlightModesComponent Controller : : generateThresholds ( void )
void PX4Advanced FlightModesController: : generateThresholds ( void )
{
// Reset all thresholds to 0.0