1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2025-01-29 14:52:12 +01:00

Fixed bug where actCommand was unassigned.

Added in some additional functionality for appropriately setting update rates.
This commit is contained in:
Kenz Dale 2012-08-24 13:23:36 +02:00
parent 91852e8550
commit 00963e3647
2 changed files with 56 additions and 10 deletions

View File

@ -132,6 +132,7 @@ void Simulator::onStart()
ExtensionSystem::PluginManager* pm = ExtensionSystem::PluginManager::instance();
UAVObjectManager* objManager = pm->getObject<UAVObjectManager>();
actDesired = ActuatorDesired::GetInstance(objManager);
actCommand = ActuatorCommand::GetInstance(objManager);
manCtrlCommand = ManualControlCommand::GetInstance(objManager);
flightStatus = FlightStatus::GetInstance(objManager);
posHome = HomeLocation::GetInstance(objManager);
@ -230,18 +231,43 @@ void Simulator::receiveUpdate()
void Simulator::setupObjects()
{
setupInputObject(actDesired, settings.minOutputPeriod);
/* if (settings.gcsReciever) {
setupInputObject(actCommand, settings.outputRate);
setupOutputObject(gcsReceiver);
} else if (settings.manualControl) {
// setupInputObject(actDesired);
// setupInputObject(camDesired);
// setupInputObject(acsDesired);
// setupOutputObject(manCtrlCommand);
qDebug() << "ManualControlCommand not implemented yet";
}
*/
setupOutputObject(posHome, 10000);
setupOutputObject(baroAlt, 250);
if (settings.gpsPositionEnabled)
setupOutputObject(gpsPos, settings.gpsPosRate);
if (settings.groundTruthEnabled){
setupOutputObject(posActual, settings.groundTruthRate);
setupOutputObject(velActual, settings.groundTruthRate);
}
if (settings.attRawEnabled) {
setupOutputObject(accels, settings.attRawRate);
setupOutputObject(gyros, settings.attRawRate);
}
if (settings.attActualEnabled && settings.attActHW) {
setupOutputObject(accels, settings.attRawRate);
setupOutputObject(gyros, settings.attRawRate);
}
if (settings.attActualEnabled && !settings.attActHW)
setupOutputObject(attActual, 10);
//setupOutputObject(attActual, 100);
setupOutputObject(gpsPos, 250);
setupOutputObject(posActual, 250);
setupOutputObject(velActual, 250);
setupOutputObject(posHome, 1000);
setupOutputObject(accels, 10);
setupOutputObject(gyros, 10);
//setupOutputObject(attRaw, 100);
else
setupWatchedObject(attActual, 100);
}
@ -271,6 +297,25 @@ void Simulator::setupInputObject(UAVObject* obj, quint32 updatePeriod)
}
void Simulator::setupWatchedObject(UAVObject *obj, quint32 updatePeriod)
{
UAVObject::Metadata mdata;
mdata = obj->getDefaultMetadata();
UAVObject::SetGcsAccess(mdata, UAVObject::ACCESS_READONLY);
UAVObject::SetGcsTelemetryAcked(mdata, false);
UAVObject::SetGcsTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_MANUAL);
mdata.gcsTelemetryUpdatePeriod = 0;
UAVObject::SetFlightAccess(mdata, UAVObject::ACCESS_READWRITE);
UAVObject::SetFlightTelemetryAcked(mdata, false);
UAVObject::SetFlightTelemetryUpdateMode(mdata, UAVObject::UPDATEMODE_PERIODIC);
mdata.flightTelemetryUpdatePeriod = updatePeriod;
obj->setMetadata(mdata);
}
void Simulator::setupOutputObject(UAVObject* obj, quint32 updatePeriod)
{
UAVObject::Metadata mdata;

View File

@ -285,6 +285,7 @@ private:
//QList<QScopedPointer<UAVDataObject> > requiredUAVObjects;
void setupOutputObject(UAVObject* obj, quint32 updatePeriod);
void setupInputObject(UAVObject* obj, quint32 updatePeriod);
void setupWatchedObject(UAVObject *obj, quint32 updatePeriod);
void setupObjects();
};