aboutsummaryrefslogtreecommitdiff
path: root/src/modules/ekf_att_pos_estimator/estimator_utilities.cpp
diff options
context:
space:
mode:
authorLorenz Meier <lm@inf.ethz.ch>2015-04-03 17:01:32 +0200
committerLorenz Meier <lm@inf.ethz.ch>2015-04-03 17:01:32 +0200
commitcc11e8a0985f1a9790510fb3f19447a6c6946ba1 (patch)
treeec1a57fc67ff2ed92f3bd965ae66edf622dcf374 /src/modules/ekf_att_pos_estimator/estimator_utilities.cpp
parent2b9909d97b446fbb112490d1631e70937beb80bf (diff)
downloadpx4-firmware-cc11e8a0985f1a9790510fb3f19447a6c6946ba1.tar.gz
px4-firmware-cc11e8a0985f1a9790510fb3f19447a6c6946ba1.tar.bz2
px4-firmware-cc11e8a0985f1a9790510fb3f19447a6c6946ba1.zip
EKF: Sync to upstream repo
Diffstat (limited to 'src/modules/ekf_att_pos_estimator/estimator_utilities.cpp')
-rw-r--r--src/modules/ekf_att_pos_estimator/estimator_utilities.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/modules/ekf_att_pos_estimator/estimator_utilities.cpp b/src/modules/ekf_att_pos_estimator/estimator_utilities.cpp
index 83a738463..284a09902 100644
--- a/src/modules/ekf_att_pos_estimator/estimator_utilities.cpp
+++ b/src/modules/ekf_att_pos_estimator/estimator_utilities.cpp
@@ -114,6 +114,27 @@ Mat3f Mat3f::transpose() const
return ret;
}
+void calcvelNED(float (&velNEDr)[3], float gpsCourse, float gpsGndSpd, float gpsVelD)
+{
+ velNEDr[0] = gpsGndSpd*cosf(gpsCourse);
+ velNEDr[1] = gpsGndSpd*sinf(gpsCourse);
+ velNEDr[2] = gpsVelD;
+}
+
+void calcposNED(float (&posNEDr)[3], double lat, double lon, float hgt, double latReference, double lonReference, float hgtReference)
+{
+ posNEDr[0] = earthRadius * (lat - latReference);
+ posNEDr[1] = earthRadius * cos(latReference) * (lon - lonReference);
+ posNEDr[2] = -(hgt - hgtReference);
+}
+
+void calcLLH(float posNEDi[3], double &lat, double &lon, float &hgt, double latRef, double lonRef, float hgtRef)
+{
+ lat = latRef + (double)posNEDi[0] * earthRadiusInv;
+ lon = lonRef + (double)posNEDi[1] * earthRadiusInv / cos(latRef);
+ hgt = hgtRef - posNEDi[2];
+}
+
// overload + operator to provide a vector addition
Vector3f operator+(const Vector3f &vecIn1, const Vector3f &vecIn2)
{