1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

OP-475: More changes to get the FlightStatus object to work for Armed and

FlightMode
This commit is contained in:
James Cotton 2011-05-07 15:06:04 -05:00
parent 80c839d5bb
commit 10e55c25bc
4 changed files with 25 additions and 18 deletions

View File

@ -143,10 +143,6 @@ static void stabilizationTask(void* parameters)
continue;
}
// Clear alarms
AlarmsClear(SYSTEMALARMS_ALARM_STABILIZATION);
// Check how long since last update
thisSysTime = xTaskGetTickCount();
if(thisSysTime > lastSysTime) // reuse dt in case of wraparound
@ -160,9 +156,6 @@ static void stabilizationTask(void* parameters)
RateDesiredGet(&rateDesired);
SystemSettingsGet(&systemSettings);
if(PARSE_FLIGHT_MODE(flightStatus.FlightMode) == FLIGHTMODE_MANUAL)
return;
#if defined(PIOS_QUATERNION_STABILIZATION)
// Quaternion calculation of error in each axis. Uses more memory.
float rpy_desired[3];
@ -269,7 +262,8 @@ static void stabilizationTask(void* parameters)
// Save dT
actuatorDesired.UpdateTime = dT * 1000;
if(PARSE_FLIGHT_MODE(flightStatus.FlightMode) == FLIGHTMODE_MANUAL)
shouldUpdate = 0;
if(shouldUpdate)
{
@ -285,6 +279,9 @@ static void stabilizationTask(void* parameters)
ZeroPids();
}
// Clear alarms
AlarmsClear(SYSTEMALARMS_ALARM_STABILIZATION);
}
}

View File

@ -249,13 +249,17 @@ void GCSControlGadget::buttonState(ButtonNumber number, bool pressed)
case 1://Armed
if (currentCGSControl)
{
if(obj->getField("Armed")->getValue().toString().compare("True")==0)
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(QString("FlightStatus")) );
if(obj->getField("Armed")->getValue().toString().compare("Armed")==0)
{
obj->getField("Armed")->setValue("False");
obj->getField("Armed")->setValue("Disarmed");
}
else
{
obj->getField("Armed")->setValue("True");
obj->getField("Armed")->setValue("Armed");
}
}
break;

View File

@ -52,7 +52,8 @@ GCSControlGadgetWidget::GCSControlGadgetWidget(QWidget *parent) : QLabel(parent)
m_gcscontrol->checkBoxGcsControl->setChecked(mdata.flightAccess == UAVObject::ACCESS_READONLY);
// Set up the drop down box for the flightmode
m_gcscontrol->comboBoxFlightMode->addItems(obj->getField("FlightMode")->getOptions());
UAVDataObject* flightStatus = dynamic_cast<UAVDataObject*>( objManager->getObject(QString("FlightStatus")) );
m_gcscontrol->comboBoxFlightMode->addItems(flightStatus->getField("FlightMode")->getOptions());
// Set up slots and signals for joysticks
connect(m_gcscontrol->widgetLeftStick,SIGNAL(positionClicked(double,double)),this,SLOT(leftStickClicked(double,double)));
@ -133,18 +134,21 @@ void GCSControlGadgetWidget::toggleArmed(int state)
{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(QString("ManualControlCommand")) );
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(QString("FlightStatus")) );
if(state)
obj->getField("Armed")->setValue("True");
obj->getField("Armed")->setValue("Armed");
else
obj->getField("Armed")->setValue("False");
obj->getField("Armed")->setValue("Disarmed");
obj->updated();
}
void GCSControlGadgetWidget::mccChanged(UAVObject * obj)
{
m_gcscontrol->checkBoxArmed->setChecked(obj->getField("Armed")->getValue() == "True");
m_gcscontrol->comboBoxFlightMode->setCurrentIndex(m_gcscontrol->comboBoxFlightMode->findText(obj->getField("FlightMode")->getValue().toString()));
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVDataObject* flightStatus = dynamic_cast<UAVDataObject*>( objManager->getObject(QString("FlightStatus")) );
m_gcscontrol->comboBoxFlightMode->setCurrentIndex(m_gcscontrol->comboBoxFlightMode->findText(flightStatus->getField("FlightMode")->getValue().toString()));
m_gcscontrol->checkBoxArmed->setChecked(flightStatus->getField("Armed")->getValue() == "Armed");
}
/*!
@ -154,7 +158,7 @@ void GCSControlGadgetWidget::selectFlightMode(int state)
{
ExtensionSystem::PluginManager *pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager *objManager = pm->getObject<UAVObjectManager>();
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(QString("ManualControlCommand")) );
UAVDataObject* obj = dynamic_cast<UAVDataObject*>( objManager->getObject(QString("FlightStatus")) );
UAVObjectField * field = obj->getField("FlightMode");
field->setValue(field->getOptions()[state]);
obj->updated();

View File

@ -66,6 +66,7 @@ HEADERS += $$UAVOBJECT_SYNTHETICS/ahrsstatus.h \
$$UAVOBJECT_SYNTHETICS/watchdogstatus.h \
$$UAVOBJECT_SYNTHETICS/nedaccel.h \
$$UAVOBJECT_SYNTHETICS/sonaraltitude.h \
$$UAVOBJECT_SYNTHETICS/flightstatus.h \
$$UAVOBJECT_SYNTHETICS/attitudesettings.h
SOURCES += $$UAVOBJECT_SYNTHETICS/ahrsstatus.cpp \
@ -112,4 +113,5 @@ SOURCES += $$UAVOBJECT_SYNTHETICS/ahrsstatus.cpp \
$$UAVOBJECT_SYNTHETICS/nedaccel.cpp \
$$UAVOBJECT_SYNTHETICS/sonaraltitude.cpp \
$$UAVOBJECT_SYNTHETICS/uavobjectsinit.cpp \
$$UAVOBJECT_SYNTHETICS/flightstatus.cpp \
$$UAVOBJECT_SYNTHETICS/attitudesettings.cpp