From e94d3d38461ee63913b01f6160fa3f3b861ab353 Mon Sep 17 00:00:00 2001 From: peabody124 Date: Mon, 23 Aug 2010 03:51:08 +0000 Subject: [PATCH] AHRS/Flight: Allow selecting simple algorithm as well as INSGPS git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1384 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/OpenPilot/Modules/AHRSComms/ahrs_comms.c | 5 ++++- flight/OpenPilot/UAVObjects/ahrssettings.c | 2 +- flight/OpenPilot/UAVObjects/inc/ahrssettings.h | 2 +- .../OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj | 4 ++-- ground/src/plugins/uavobjects/ahrssettings.cpp | 3 ++- ground/src/plugins/uavobjects/ahrssettings.h | 2 +- ground/src/plugins/uavobjects/ahrssettings.py | 3 ++- ground/src/shared/uavobjectdefinition/ahrssettings.xml | 2 +- 8 files changed, 14 insertions(+), 9 deletions(-) diff --git a/flight/OpenPilot/Modules/AHRSComms/ahrs_comms.c b/flight/OpenPilot/Modules/AHRSComms/ahrs_comms.c index 899b82528..04bf93dbd 100644 --- a/flight/OpenPilot/Modules/AHRSComms/ahrs_comms.c +++ b/flight/OpenPilot/Modules/AHRSComms/ahrs_comms.c @@ -234,7 +234,10 @@ static void ahrscommsTask(void* parameters) { struct opahrs_msg_v1 req; - req.payload.user.v.req.algorithm.algorithm = settings.Algorithm; + if(settings.Algorithm == AHRSSETTINGS_ALGORITHM_INSGPS) + req.payload.user.v.req.algorithm.algorithm = INSGPS_Algo; + if(settings.Algorithm == AHRSSETTINGS_ALGORITHM_SIMPLE) + req.payload.user.v.req.algorithm.algorithm = SIMPLE_Algo; if(( result = PIOS_OPAHRS_SetAlgorithm(&req) ) == OPAHRS_RESULT_OK ) { data.AlgorithmSet = AHRSSTATUS_ALGORITHMSET_TRUE; diff --git a/flight/OpenPilot/UAVObjects/ahrssettings.c b/flight/OpenPilot/UAVObjects/ahrssettings.c index 5c79483f7..a18dd9704 100644 --- a/flight/OpenPilot/UAVObjects/ahrssettings.c +++ b/flight/OpenPilot/UAVObjects/ahrssettings.c @@ -73,7 +73,7 @@ static void setDefaults(UAVObjHandle obj, uint16_t instId) // Initialize object fields to their default values UAVObjGetInstanceData(obj, instId, &data); memset(&data, 0, sizeof(AHRSSettingsData)); - data.Algorithm = 0; + data.Algorithm = 1; data.UpdateRaw = 0; data.UpdateFiltered = 1; data.UpdatePeriod = 20; diff --git a/flight/OpenPilot/UAVObjects/inc/ahrssettings.h b/flight/OpenPilot/UAVObjects/inc/ahrssettings.h index a6dad8df8..26b743e16 100644 --- a/flight/OpenPilot/UAVObjects/inc/ahrssettings.h +++ b/flight/OpenPilot/UAVObjects/inc/ahrssettings.h @@ -67,7 +67,7 @@ typedef struct { // Field information // Field Algorithm information /* Enumeration options for field Algorithm */ -typedef enum { AHRSSETTINGS_ALGORITHM_INSGPS=0 } AHRSSettingsAlgorithmOptions; +typedef enum { AHRSSETTINGS_ALGORITHM_SIMPLE=0, AHRSSETTINGS_ALGORITHM_INSGPS=1 } AHRSSettingsAlgorithmOptions; // Field UpdateRaw information /* Enumeration options for field UpdateRaw */ typedef enum { AHRSSETTINGS_UPDATERAW_FALSE=0, AHRSSETTINGS_UPDATERAW_TRUE=1 } AHRSSettingsUpdateRawOptions; diff --git a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj index 3492a6a76..a00499090 100644 --- a/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj +++ b/flight/Project/OpenPilotOSX/OpenPilotOSX.xcodeproj/project.pbxproj @@ -36,6 +36,7 @@ 657CEEC2121DC054007A1FBE /* navigationdesired.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = navigationdesired.c; sourceTree = ""; }; 657CEEC3121DC054007A1FBE /* navigationsettings.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = navigationsettings.c; sourceTree = ""; }; 657CF024121F49CD007A1FBE /* WMMInternal.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WMMInternal.h; sourceTree = ""; }; + 659ED317122226B60011010E /* ahrssettings.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = ahrssettings.xml; sourceTree = ""; }; 65B35D7F121C261E003EAD18 /* bin.pro */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = bin.pro; sourceTree = ""; }; 65B35D80121C261E003EAD18 /* openpilotgcs */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.script.sh; path = openpilotgcs; sourceTree = ""; }; 65B35D81121C261E003EAD18 /* openpilotgcs.pri */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = openpilotgcs.pri; sourceTree = ""; }; @@ -2551,7 +2552,6 @@ 65B367E9121C2620003EAD18 /* attitudeactual.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = attitudeactual.xml; sourceTree = ""; }; 65B367EA121C2620003EAD18 /* attitudedesired.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = attitudedesired.xml; sourceTree = ""; }; 65B367EB121C2620003EAD18 /* attituderaw.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = attituderaw.xml; sourceTree = ""; }; - 65B367EC121C2620003EAD18 /* attitudesettings.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = attitudesettings.xml; sourceTree = ""; }; 65B367ED121C2620003EAD18 /* exampleobject1.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = exampleobject1.xml; sourceTree = ""; }; 65B367EE121C2620003EAD18 /* exampleobject2.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = exampleobject2.xml; sourceTree = ""; }; 65B367EF121C2620003EAD18 /* examplesettings.xml */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.xml; path = examplesettings.xml; sourceTree = ""; }; @@ -6669,6 +6669,7 @@ isa = PBXGroup; children = ( 655268BC121FBD2900410C6E /* ahrscalibration.xml */, + 659ED317122226B60011010E /* ahrssettings.xml */, 65B367E7121C2620003EAD18 /* ahrsstatus.xml */, 65B367E4121C2620003EAD18 /* actuatorcommand.xml */, 65B367E5121C2620003EAD18 /* actuatordesired.xml */, @@ -6676,7 +6677,6 @@ 65B367E9121C2620003EAD18 /* attitudeactual.xml */, 65B367EA121C2620003EAD18 /* attitudedesired.xml */, 65B367EB121C2620003EAD18 /* attituderaw.xml */, - 65B367EC121C2620003EAD18 /* attitudesettings.xml */, 65209A1812208B0600453371 /* baroaltitude.xml */, 65B367ED121C2620003EAD18 /* exampleobject1.xml */, 65B367EE121C2620003EAD18 /* exampleobject2.xml */, diff --git a/ground/src/plugins/uavobjects/ahrssettings.cpp b/ground/src/plugins/uavobjects/ahrssettings.cpp index 820c682c0..37ec86fde 100644 --- a/ground/src/plugins/uavobjects/ahrssettings.cpp +++ b/ground/src/plugins/uavobjects/ahrssettings.cpp @@ -45,6 +45,7 @@ AHRSSettings::AHRSSettings(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAM QStringList AlgorithmElemNames; AlgorithmElemNames.append("0"); QStringList AlgorithmEnumOptions; + AlgorithmEnumOptions.append("SIMPLE"); AlgorithmEnumOptions.append("INSGPS"); fields.append( new UAVObjectField(QString("Algorithm"), QString(""), UAVObjectField::ENUM, AlgorithmElemNames, AlgorithmEnumOptions) ); QStringList UpdateRawElemNames; @@ -95,7 +96,7 @@ UAVObject::Metadata AHRSSettings::getDefaultMetadata() */ void AHRSSettings::setDefaultFieldValues() { - data.Algorithm = 0; + data.Algorithm = 1; data.UpdateRaw = 0; data.UpdateFiltered = 1; data.UpdatePeriod = 20; diff --git a/ground/src/plugins/uavobjects/ahrssettings.h b/ground/src/plugins/uavobjects/ahrssettings.h index 59bbdc122..1aeaa3b18 100644 --- a/ground/src/plugins/uavobjects/ahrssettings.h +++ b/ground/src/plugins/uavobjects/ahrssettings.h @@ -53,7 +53,7 @@ public: // Field information // Field Algorithm information /* Enumeration options for field Algorithm */ - typedef enum { ALGORITHM_INSGPS=0 } AlgorithmOptions; + typedef enum { ALGORITHM_SIMPLE=0, ALGORITHM_INSGPS=1 } AlgorithmOptions; // Field UpdateRaw information /* Enumeration options for field UpdateRaw */ typedef enum { UPDATERAW_FALSE=0, UPDATERAW_TRUE=1 } UpdateRawOptions; diff --git a/ground/src/plugins/uavobjects/ahrssettings.py b/ground/src/plugins/uavobjects/ahrssettings.py index d3973c95b..565e43390 100644 --- a/ground/src/plugins/uavobjects/ahrssettings.py +++ b/ground/src/plugins/uavobjects/ahrssettings.py @@ -45,7 +45,8 @@ _fields = [ \ '0', ], { - '0' : 'INSGPS', + '0' : 'SIMPLE', + '1' : 'INSGPS', } ), uavobject.UAVObjectField( diff --git a/ground/src/shared/uavobjectdefinition/ahrssettings.xml b/ground/src/shared/uavobjectdefinition/ahrssettings.xml index d03251b35..01131ec7d 100644 --- a/ground/src/shared/uavobjectdefinition/ahrssettings.xml +++ b/ground/src/shared/uavobjectdefinition/ahrssettings.xml @@ -1,6 +1,6 @@ - +