Browse Source

ekf2 replay logic:

support recent change in ekf2 module which made it only publish the output
when an ekf update was occuring. in case the ekf2 module does not update
the replay module will be informed and will thus not wait for an update
but continue preparing the next sample of sensor data
sbg
tumbili 9 years ago
parent
commit
4da93a316d
  1. 13
      src/modules/ekf2/ekf2_main.cpp
  2. 12
      src/modules/ekf2_replay/ekf2_replay_main.cpp

13
src/modules/ekf2/ekf2_main.cpp

@ -468,7 +468,6 @@ void Ekf2::task_main() @@ -468,7 +468,6 @@ void Ekf2::task_main()
// run the EKF update and output
if (_ekf->update()) {
// generate vehicle attitude quaternion data
struct vehicle_attitude_s att = {};
_ekf->copy_quaternion(att.q);
@ -626,6 +625,18 @@ void Ekf2::task_main() @@ -626,6 +625,18 @@ void Ekf2::task_main()
orb_publish(ORB_ID(vehicle_global_position), _vehicle_global_position_pub, &global_pos);
}
}
} else if (_replay_mode) {
// in replay mode we have to tell the replay module not to wait for an update
// we do this by publishing an attitude with zero timestamp
struct vehicle_attitude_s att = {};
att.timestamp = 0;
if (_att_pub == nullptr) {
_att_pub = orb_advertise(ORB_ID(vehicle_attitude), &att);
} else {
orb_publish(ORB_ID(vehicle_attitude), _att_pub, &att);
}
}
// publish estimator status

12
src/modules/ekf2_replay/ekf2_replay_main.cpp

@ -436,6 +436,13 @@ void Ekf2Replay::logIfUpdated() @@ -436,6 +436,13 @@ void Ekf2Replay::logIfUpdated()
// update attitude
struct vehicle_attitude_s att = {};
orb_copy(ORB_ID(vehicle_attitude), _att_sub, &att);
// if the timestamp of the attitude is zero, then this means that the ekf did not
// do an update so we can ignore this message and just continue
if (att.timestamp == 0) {
return;
}
memset(&log_message.body.att.q_w, 0, sizeof(log_ATT_s));
log_message.type = LOG_ATT_MSG;
@ -695,8 +702,9 @@ void Ekf2Replay::task_main() @@ -695,8 +702,9 @@ void Ekf2Replay::task_main()
read_first_header = true;
if (header[0] != HEAD_BYTE1 || header[1] != HEAD_BYTE2) {
PX4_WARN("bad log header\n");
if ((header[0] != HEAD_BYTE1 || header[1] != HEAD_BYTE2)) {
// we assume that the log file is finished here
PX4_WARN("Done!");
_task_should_exit = true;
continue;
}

Loading…
Cancel
Save