mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-11-29 07:24:13 +01:00
OP-119 Flight: Converted HomeLocation object to use cm for the home base instead of floating point.
git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@1382 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
parent
2596f43511
commit
b32184d1ec
@ -380,8 +380,10 @@ static void load_gps_position(struct opahrs_msg_v1_req_update * update)
|
|||||||
update->gps.groundspeed = data.Groundspeed;
|
update->gps.groundspeed = data.Groundspeed;
|
||||||
update->gps.heading = data.Heading;
|
update->gps.heading = data.Heading;
|
||||||
update->gps.quality = 0;
|
update->gps.quality = 0;
|
||||||
double LLA[3] = {(double) data.Latitude, (double) data.Longitude, (double) data.Altitude};
|
// TODO: replace with conversion from degrees * 10e6 to degrees when the GPS format updated
|
||||||
double ECEF[3] = {(double) home.ECEF[0], (double) home.ECEF[1], (double) home.ECEF[2]};
|
double LLA[3] = {(double) data.Latitude, (double) data.Longitude, (double) data.Altitude};
|
||||||
|
// convert from cm back to meters
|
||||||
|
double ECEF[3] = {(double) (home.ECEF[0] / 100), (double) (home.ECEF[1] / 100), (double) (home.ECEF[2] / 100)};
|
||||||
LLA2Base(LLA, ECEF, (float (*)[3]) home.RNE, update->gps.NED);
|
LLA2Base(LLA, ECEF, (float (*)[3]) home.RNE, update->gps.NED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,9 +189,9 @@ static void setHomeLocation(PositionActualData * gpsData)
|
|||||||
LLA2ECEF(LLA, ECEF);
|
LLA2ECEF(LLA, ECEF);
|
||||||
// TODO: Currently UAVTalk only supports float but these conversions use double
|
// TODO: Currently UAVTalk only supports float but these conversions use double
|
||||||
// need to find out if they require that precision and if so extend UAVTAlk
|
// need to find out if they require that precision and if so extend UAVTAlk
|
||||||
home.ECEF[0] = ECEF[0];
|
home.ECEF[0] = (int32_t) (ECEF[0] * 100);
|
||||||
home.ECEF[1] = ECEF[1];
|
home.ECEF[1] = (int32_t) (ECEF[1] * 100);
|
||||||
home.ECEF[2] = ECEF[2];
|
home.ECEF[2] = (int32_t) (ECEF[2] * 100);
|
||||||
|
|
||||||
// Compute magnetic flux direction at home location
|
// Compute magnetic flux direction at home location
|
||||||
WMM_GetMagVector(LLA[0], LLA[1], LLA[2], 8, 17, 2010, &home.Be[0]);
|
WMM_GetMagVector(LLA[0], LLA[1], LLA[2], 8, 17, 2010, &home.Be[0]);
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#define HOMELOCATION_H
|
#define HOMELOCATION_H
|
||||||
|
|
||||||
// Object constants
|
// Object constants
|
||||||
#define HOMELOCATION_OBJID 4244719376U
|
#define HOMELOCATION_OBJID 3590360786U
|
||||||
#define HOMELOCATION_NAME "HomeLocation"
|
#define HOMELOCATION_NAME "HomeLocation"
|
||||||
#define HOMELOCATION_METANAME "HomeLocationMeta"
|
#define HOMELOCATION_METANAME "HomeLocationMeta"
|
||||||
#define HOMELOCATION_ISSINGLEINST 1
|
#define HOMELOCATION_ISSINGLEINST 1
|
||||||
@ -61,7 +61,7 @@ typedef struct {
|
|||||||
int32_t Latitude;
|
int32_t Latitude;
|
||||||
int32_t Longitude;
|
int32_t Longitude;
|
||||||
float Altitude;
|
float Altitude;
|
||||||
float ECEF[3];
|
int32_t ECEF[3];
|
||||||
float RNE[9];
|
float RNE[9];
|
||||||
float Be[3];
|
float Be[3];
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ HomeLocation::HomeLocation(): UAVDataObject(OBJID, ISSINGLEINST, ISSETTINGS, NAM
|
|||||||
ECEFElemNames.append("0");
|
ECEFElemNames.append("0");
|
||||||
ECEFElemNames.append("1");
|
ECEFElemNames.append("1");
|
||||||
ECEFElemNames.append("2");
|
ECEFElemNames.append("2");
|
||||||
fields.append( new UAVObjectField(QString("ECEF"), QString("m"), UAVObjectField::FLOAT32, ECEFElemNames, QStringList()) );
|
fields.append( new UAVObjectField(QString("ECEF"), QString("cm"), UAVObjectField::INT32, ECEFElemNames, QStringList()) );
|
||||||
QStringList RNEElemNames;
|
QStringList RNEElemNames;
|
||||||
RNEElemNames.append("0");
|
RNEElemNames.append("0");
|
||||||
RNEElemNames.append("1");
|
RNEElemNames.append("1");
|
||||||
|
@ -47,7 +47,7 @@ public:
|
|||||||
qint32 Latitude;
|
qint32 Latitude;
|
||||||
qint32 Longitude;
|
qint32 Longitude;
|
||||||
float Altitude;
|
float Altitude;
|
||||||
float ECEF[3];
|
qint32 ECEF[3];
|
||||||
float RNE[9];
|
float RNE[9];
|
||||||
float Be[3];
|
float Be[3];
|
||||||
|
|
||||||
@ -72,7 +72,7 @@ public:
|
|||||||
|
|
||||||
|
|
||||||
// Constants
|
// Constants
|
||||||
static const quint32 OBJID = 4244719376U;
|
static const quint32 OBJID = 3590360786U;
|
||||||
static const QString NAME;
|
static const QString NAME;
|
||||||
static const bool ISSINGLEINST = 1;
|
static const bool ISSINGLEINST = 1;
|
||||||
static const bool ISSETTINGS = 1;
|
static const bool ISSETTINGS = 1;
|
||||||
|
@ -81,7 +81,7 @@ _fields = [ \
|
|||||||
),
|
),
|
||||||
uavobject.UAVObjectField(
|
uavobject.UAVObjectField(
|
||||||
'ECEF',
|
'ECEF',
|
||||||
'f',
|
'i',
|
||||||
3,
|
3,
|
||||||
[
|
[
|
||||||
'0',
|
'0',
|
||||||
@ -126,7 +126,7 @@ _fields = [ \
|
|||||||
|
|
||||||
class HomeLocation(uavobject.UAVObject):
|
class HomeLocation(uavobject.UAVObject):
|
||||||
## Object constants
|
## Object constants
|
||||||
OBJID = 4244719376
|
OBJID = 3590360786
|
||||||
NAME = "HomeLocation"
|
NAME = "HomeLocation"
|
||||||
METANAME = "HomeLocationMeta"
|
METANAME = "HomeLocationMeta"
|
||||||
ISSINGLEINST = 1
|
ISSINGLEINST = 1
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
<field name="Latitude" units="deg * 10e6" type="int32" elements="1" defaultvalue="0"/>
|
<field name="Latitude" units="deg * 10e6" type="int32" elements="1" defaultvalue="0"/>
|
||||||
<field name="Longitude" units="deg * 10e6" type="int32" elements="1" defaultvalue="0"/>
|
<field name="Longitude" units="deg * 10e6" type="int32" elements="1" defaultvalue="0"/>
|
||||||
<field name="Altitude" units="m over geoid" type="float" elements="1" defaultvalue="0"/>
|
<field name="Altitude" units="m over geoid" type="float" elements="1" defaultvalue="0"/>
|
||||||
<field name="ECEF" units="m" type="float" elements="3" defaultvalue="0,0,0"/>
|
<field name="ECEF" units="cm" type="int32" elements="3" defaultvalue="0,0,0"/>
|
||||||
<field name="RNE" units="" type="float" elements="9" defaultvalue="0,0,0,0,0,0,0,0,0"/>
|
<field name="RNE" units="" type="float" elements="9" defaultvalue="0,0,0,0,0,0,0,0,0"/>
|
||||||
<field name="Be" units="" type="float" elements="3" defaultvalue="0,0,0"/>
|
<field name="Be" units="" type="float" elements="3" defaultvalue="0,0,0"/>
|
||||||
<access gcs="readwrite" flight="readwrite"/>
|
<access gcs="readwrite" flight="readwrite"/>
|
||||||
|
Loading…
Reference in New Issue
Block a user