Skip to content

Commit e1a033b

Browse files
committed
AP_NavEKF3: make logging a core concern
Also dissolve some methods only used for logging
1 parent 9146293 commit e1a033b

File tree

6 files changed

+184
-448
lines changed

6 files changed

+184
-448
lines changed

libraries/AP_NavEKF3/AP_NavEKF3.cpp

Lines changed: 0 additions & 100 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,39 +1239,6 @@ void NavEKF3::getMagXYZ(int8_t instance, Vector3f &magXYZ) const
12391239
}
12401240
}
12411241

1242-
// return the magnetometer in use for the specified instance
1243-
uint8_t NavEKF3::getActiveMag(int8_t instance) const
1244-
{
1245-
if (instance < 0 || instance >= num_cores) instance = primary;
1246-
if (core) {
1247-
return core[instance].getActiveMag();
1248-
} else {
1249-
return 255;
1250-
}
1251-
}
1252-
1253-
// return the baro in use for the specified instance
1254-
uint8_t NavEKF3::getActiveBaro(int8_t instance) const
1255-
{
1256-
if (instance < 0 || instance >= num_cores) instance = primary;
1257-
if (core) {
1258-
return core[instance].getActiveBaro();
1259-
} else {
1260-
return 255;
1261-
}
1262-
}
1263-
1264-
// return the GPS in use for the specified instance
1265-
uint8_t NavEKF3::getActiveGPS(int8_t instance) const
1266-
{
1267-
if (instance < 0 || instance >= num_cores) instance = primary;
1268-
if (core) {
1269-
return core[instance].getActiveGPS();
1270-
} else {
1271-
return 255;
1272-
}
1273-
}
1274-
12751242
// return the airspeed sensor in use for the specified instance
12761243
uint8_t NavEKF3::getActiveAirspeed(int8_t instance) const
12771244
{
@@ -1408,15 +1375,6 @@ void NavEKF3::getInnovations(int8_t instance, Vector3f &velInnov, Vector3f &posI
14081375
}
14091376
}
14101377

1411-
// publish output observer angular, velocity and position tracking error
1412-
void NavEKF3::getOutputTrackingError(int8_t instance, Vector3f &error) const
1413-
{
1414-
if (instance < 0 || instance >= num_cores) instance = primary;
1415-
if (core) {
1416-
core[instance].getOutputTrackingError(error);
1417-
}
1418-
}
1419-
14201378
// return the innovation consistency test ratios for the velocity, position, magnetometer and true airspeed measurements
14211379
void NavEKF3::getVariances(int8_t instance, float &velVar, float &posVar, float &hgtVar, Vector3f &magVar, float &tasVar, Vector2f &offset) const
14221380
{
@@ -1426,15 +1384,6 @@ void NavEKF3::getVariances(int8_t instance, float &velVar, float &posVar, float
14261384
}
14271385
}
14281386

1429-
// return the diagonals from the covariance matrix for the specified instance
1430-
void NavEKF3::getStateVariances(int8_t instance, float stateVar[24]) const
1431-
{
1432-
if (instance < 0 || instance >= num_cores) instance = primary;
1433-
if (core) {
1434-
core[instance].getStateVariances(stateVar);
1435-
}
1436-
}
1437-
14381387
// get a source's velocity innovations for the specified instance. Set instance to -1 for the primary instance
14391388
// returns true on success and results are placed in innovations and variances arguments
14401389
bool NavEKF3::getVelInnovationsAndVariancesForSource(int8_t instance, AP_NavEKF_Source::SourceXY source, Vector3f &innovations, Vector3f &variances) const
@@ -1538,15 +1487,6 @@ void NavEKF3::writeExtNavVelData(const Vector3f &vel, float err, uint32_t timeSt
15381487
}
15391488

15401489
// return data for debugging optical flow fusion
1541-
void NavEKF3::getFlowDebug(int8_t instance, float &varFlow, float &gndOffset, float &flowInnovX, float &flowInnovY, float &auxInnov,
1542-
float &HAGL, float &rngInnov, float &range, float &gndOffsetErr) const
1543-
{
1544-
if (instance < 0 || instance >= num_cores) instance = primary;
1545-
if (core) {
1546-
core[instance].getFlowDebug(varFlow, gndOffset, flowInnovX, flowInnovY, auxInnov, HAGL, rngInnov, range, gndOffsetErr);
1547-
}
1548-
}
1549-
15501490
/*
15511491
* Write body frame linear and angular displacement measurements from a visual odometry sensor
15521492
*
@@ -1603,19 +1543,6 @@ uint32_t NavEKF3::getBodyFrameOdomDebug(int8_t instance, Vector3f &velInnov, Vec
16031543
return ret;
16041544
}
16051545

1606-
// return data for debugging EKF-GSF yaw estimator
1607-
// return false if data not available
1608-
bool NavEKF3::getDataEKFGSF(int8_t instance, float &yaw_composite, float &yaw_composite_variance, float yaw[N_MODELS_EKFGSF], float innov_VN[N_MODELS_EKFGSF], float innov_VE[N_MODELS_EKFGSF], float weight[N_MODELS_EKFGSF]) const
1609-
{
1610-
if (instance < 0 || instance >= num_cores) instance = primary;
1611-
if (core) {
1612-
if (core[instance].getDataEKFGSF(yaw_composite, yaw_composite_variance, yaw, innov_VN, innov_VE, weight)) {
1613-
return true;
1614-
}
1615-
}
1616-
return false;
1617-
}
1618-
16191546
// parameter conversion of EKF3 parameters
16201547
void NavEKF3::convert_parameters()
16211548
{
@@ -1717,18 +1644,6 @@ void NavEKF3::convert_parameters()
17171644
}
17181645
}
17191646

1720-
// return data for debugging range beacon fusion
1721-
bool NavEKF3::getRangeBeaconDebug(int8_t instance, uint8_t &ID, float &rng, float &innov, float &innovVar, float &testRatio, Vector3f &beaconPosNED,
1722-
float &offsetHigh, float &offsetLow, Vector3f &posNED) const
1723-
{
1724-
if (instance < 0 || instance >= num_cores) instance = primary;
1725-
if (core) {
1726-
return core[instance].getRangeBeaconDebug(ID, rng, innov, innovVar, testRatio, beaconPosNED, offsetHigh, offsetLow, posNED);
1727-
} else {
1728-
return false;
1729-
}
1730-
}
1731-
17321647
// called by vehicle code to specify that a takeoff is happening
17331648
// causes the EKF to compensate for expected barometer errors due to rotor wash ground interaction
17341649
// causes the EKF to start the EKF-GSF yaw estimator
@@ -2073,21 +1988,6 @@ void NavEKF3::updateLaneSwitchPosDownResetData(uint8_t new_primary, uint8_t old_
20731988

20741989
}
20751990

2076-
/*
2077-
get timing statistics structure
2078-
*/
2079-
void NavEKF3::getTimingStatistics(int8_t instance, struct ekf_timing &timing) const
2080-
{
2081-
if (instance < 0 || instance >= num_cores) {
2082-
instance = primary;
2083-
}
2084-
if (core) {
2085-
core[instance].getTimingStatistics(timing);
2086-
} else {
2087-
memset(&timing, 0, sizeof(timing));
2088-
}
2089-
}
2090-
20911991
// Writes the default equivalent airspeed in m/s to be used in forward flight if a measured airspeed is required and not available.
20921992
void NavEKF3::writeDefaultAirSpeed(float airspeed)
20931993
{

libraries/AP_NavEKF3/AP_NavEKF3.h

Lines changed: 0 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,6 @@ class NavEKF3 {
141141

142142
// return the sensor in use for the specified instance
143143
// An out of range instance (eg -1) returns data for the primary instance
144-
uint8_t getActiveMag(int8_t instance) const;
145-
uint8_t getActiveBaro(int8_t instance) const;
146-
uint8_t getActiveGPS(int8_t instance) const;
147144
uint8_t getActiveAirspeed(int8_t instance) const;
148145

149146
// Return estimated magnetometer offsets
@@ -189,16 +186,10 @@ class NavEKF3 {
189186
// An out of range instance (eg -1) returns data for the primary instance
190187
void getInnovations(int8_t index, Vector3f &velInnov, Vector3f &posInnov, Vector3f &magInnov, float &tasInnov, float &yawInnov) const;
191188

192-
// publish output observer angular, velocity and position tracking error
193-
void getOutputTrackingError(int8_t instance, Vector3f &error) const;
194-
195189
// return the innovation consistency test ratios for the specified instance
196190
// An out of range instance (eg -1) returns data for the primary instance
197191
void getVariances(int8_t instance, float &velVar, float &posVar, float &hgtVar, Vector3f &magVar, float &tasVar, Vector2f &offset) const;
198192

199-
// return the diagonals from the covariance matrix for the specified instance
200-
void getStateVariances(int8_t instance, float stateVar[24]) const;
201-
202193
// get a source's velocity innovations for the specified instance. Set instance to -1 for the primary instance
203194
// returns true on success and results are placed in innovations and variances arguments
204195
bool getVelInnovationsAndVariancesForSource(int8_t instance, AP_NavEKF_Source::SourceXY source, Vector3f &innovations, Vector3f &variances) const WARN_IF_UNUSED;
@@ -251,27 +242,6 @@ class NavEKF3 {
251242
*/
252243
uint32_t getBodyFrameOdomDebug(int8_t instance, Vector3f &velInnov, Vector3f &velInnovVar) const;
253244

254-
// return data for debugging optical flow fusion for the specified instance
255-
// An out of range instance (eg -1) returns data for the primary instance
256-
void getFlowDebug(int8_t instance, float &varFlow, float &gndOffset, float &flowInnovX, float &flowInnovY, float &auxInnov, float &HAGL, float &rngInnov, float &range, float &gndOffsetErr) const;
257-
258-
/*
259-
Returns the following data for debugging range beacon fusion
260-
ID : beacon identifier
261-
rng : measured range to beacon (m)
262-
innov : range innovation (m)
263-
innovVar : innovation variance (m^2)
264-
testRatio : innovation consistency test ratio
265-
beaconPosNED : beacon NED position (m)
266-
offsetHigh : high hypothesis for range beacons system vertical offset (m)
267-
offsetLow : low hypothesis for range beacons system vertical offset (m)
268-
posNED : North,East,Down position estimate of receiver from 3-state filter
269-
270-
returns true if data could be found, false if it could not
271-
*/
272-
bool getRangeBeaconDebug(int8_t instance, uint8_t &ID, float &rng, float &innov, float &innovVar, float &testRatio, Vector3f &beaconPosNED,
273-
float &offsetHigh, float &offsetLow, Vector3f &posNED) const;
274-
275245
/*
276246
* Writes the measurement from a yaw angle sensor
277247
*
@@ -395,9 +365,6 @@ class NavEKF3 {
395365
// allow the enable flag to be set by Replay
396366
void set_enable(bool enable) { _enable.set_enable(enable); }
397367

398-
// get timing statistics structure
399-
void getTimingStatistics(int8_t instance, struct ekf_timing &timing) const;
400-
401368
/*
402369
check if switching lanes will reduce the normalised
403370
innovations. This is called when the vehicle code is about to
@@ -424,10 +391,6 @@ class NavEKF3 {
424391
// Writes the default equivalent airspeed in m/s to be used in forward flight if a measured airspeed is required and not available.
425392
void writeDefaultAirSpeed(float airspeed);
426393

427-
// log debug data for yaw estimator
428-
// return false if data not available
429-
bool getDataEKFGSF(int8_t instance, float &yaw_composite, float &yaw_composite_variance, float yaw[N_MODELS_EKFGSF], float innov_VN[N_MODELS_EKFGSF], float innov_VE[N_MODELS_EKFGSF], float weight[N_MODELS_EKFGSF]) const;
430-
431394
// parameter conversion
432395
void convert_parameters();
433396

@@ -611,20 +574,6 @@ class NavEKF3 {
611574
// checks for alignment
612575
bool coreBetterScore(uint8_t new_core, uint8_t current_core) const;
613576

614-
// logging functions shared by cores:
615-
void Log_Write_XKF1(uint8_t core, uint64_t time_us) const;
616-
void Log_Write_XKF2(uint8_t core, uint64_t time_us) const;
617-
void Log_Write_XKF3(uint8_t core, uint64_t time_us) const;
618-
void Log_Write_XKF4(uint8_t core, uint64_t time_us) const;
619-
void Log_Write_XKF5(uint8_t core, uint64_t time_us) const;
620-
void Log_Write_XKFS(uint8_t core, uint64_t time_us) const;
621-
void Log_Write_Quaternion(uint8_t core, uint64_t time_us) const;
622-
void Log_Write_Beacon(uint8_t core, uint64_t time_us) const;
623-
void Log_Write_BodyOdom(uint8_t core, uint64_t time_us) const;
624-
void Log_Write_State_Variances(uint8_t core, uint64_t time_us) const;
625-
void Log_Write_Timing(uint8_t core, uint64_t time_us) const;
626-
void Log_Write_GSF(uint8_t core, uint64_t time_us) const;
627-
628577
// position, velocity and yaw source control
629578
AP_NavEKF_Source sources;
630579
};

0 commit comments

Comments
 (0)