Replay: fixed log rate detection
This commit is contained in:
parent
fcd7611248
commit
84d45cce40
@ -526,6 +526,7 @@ bool Replay::find_log_info(struct log_information &info)
|
||||
int samplecount = 0;
|
||||
uint64_t prev = 0;
|
||||
uint64_t smallest_delta = 0;
|
||||
uint64_t total_delta = 0;
|
||||
prev = 0;
|
||||
const uint16_t samples_required = 1000;
|
||||
while (samplecount < samples_required) {
|
||||
@ -557,17 +558,22 @@ bool Replay::find_log_info(struct log_information &info)
|
||||
samplecount = 0;
|
||||
prev = 0;
|
||||
smallest_delta = 0;
|
||||
total_delta = 0;
|
||||
}
|
||||
if (streq(type, clock_source)) {
|
||||
if (prev == 0) {
|
||||
prev = reader.last_clock_timestamp;
|
||||
} else {
|
||||
uint64_t delta = reader.last_clock_timestamp - prev;
|
||||
if (smallest_delta == 0 || delta < smallest_delta) {
|
||||
smallest_delta = delta;
|
||||
if (delta < 40000 && delta > 1000) {
|
||||
if (smallest_delta == 0 || delta < smallest_delta) {
|
||||
smallest_delta = delta;
|
||||
}
|
||||
samplecount++;
|
||||
total_delta += delta;
|
||||
}
|
||||
samplecount++;
|
||||
}
|
||||
prev = reader.last_clock_timestamp;
|
||||
}
|
||||
|
||||
if (streq(type, "IMU2")) {
|
||||
@ -585,7 +591,10 @@ bool Replay::find_log_info(struct log_information &info)
|
||||
return false;
|
||||
}
|
||||
|
||||
float rate = 1.0e6f/smallest_delta;
|
||||
float average_delta = total_delta / samplecount;
|
||||
float rate = 1.0e6f/average_delta;
|
||||
printf("average_delta=%.2f smallest_delta=%lu samplecount=%lu\n",
|
||||
average_delta, (unsigned long)smallest_delta, (unsigned long)samplecount);
|
||||
if (rate < 100) {
|
||||
info.update_rate = 50;
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user