Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stabilize E2E test #163

Merged
merged 4 commits into from
Aug 3, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 35 additions & 12 deletions test/src/e2e.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

#include <iostream>
#include <map>
#include <memory>
#include <sstream>
#include <string>
#include <thread>
#include <vector>
Expand Down Expand Up @@ -120,6 +122,7 @@
{
const ros::Time deadline = ros::Time::now() + timeout;
ros::Rate wait(10);
scans_.clear();
while (scans_.size() <= num)
{
wait.sleep();
Expand Down Expand Up @@ -261,20 +264,40 @@
pnh_.setParam("/urg_stamped/debug", true);
ASSERT_NO_FATAL_FAILURE(startUrgStamped());

ASSERT_NO_FATAL_FAILURE(waitScans(300, ros::Duration(10)));

int err_rms = 0;
for (size_t i = 250; i < 300; ++i)
std::shared_ptr<std::stringstream> serr;
bool ok = false;
int err_rms;
for (int retry = 0; retry < 2; retry++)
{
const int index = std::lround(scans_[i]->ranges[0] * 1000);
ASSERT_NE(true_stamps_.find(index), true_stamps_.end()) << "Can not find corresponding ground truth timestamp";
const double err = (true_stamps_[index] - scans_[i]->header.stamp).toSec();
EXPECT_LT(std::abs(err), 0.001)
<< std::setprecision(9) << std::fixed
<< "scan " << i << " gain " << status_msg_->sensor_clock_gain
<< " stamp " << scans_[i]->header.stamp;
err_rms += err * err;
serr.reset(new std::stringstream());
ASSERT_NO_FATAL_FAILURE(waitScans(300, ros::Duration(10)));

err_rms = 0;
int num_fail = 0;
for (size_t i = 250; i < 300; ++i)
{
const int index = std::lround(scans_[i]->ranges[0] * 1000);
ASSERT_NE(true_stamps_.find(index), true_stamps_.end()) << "Can not find corresponding ground truth timestamp";
const double err = (true_stamps_[index] - scans_[i]->header.stamp).toSec();
if (std::abs(err) > 0.001)
{
num_fail++;
*serr << std::setprecision(6) << std::fixed

Check warning on line 285 in test/src/e2e.cpp

View check run for this annotation

Codecov / codecov/patch

test/src/e2e.cpp#L284-L285

Added lines #L284 - L285 were not covered by tests
<< "err " << err << " "
<< std::setprecision(9)
<< "scan " << i << " gain " << status_msg_->sensor_clock_gain
<< " stamp " << scans_[i]->header.stamp << std::endl;

Check warning on line 289 in test/src/e2e.cpp

View check run for this annotation

Codecov / codecov/patch

test/src/e2e.cpp#L288-L289

Added lines #L288 - L289 were not covered by tests
}
err_rms += err * err;
}
if (num_fail == 0)
{
ok = true;
break;
}
std::cerr << "Test attempt " << retry << " failed: " << serr->str() << std::endl;

Check warning on line 298 in test/src/e2e.cpp

View check run for this annotation

Codecov / codecov/patch

test/src/e2e.cpp#L298

Added line #L298 was not covered by tests
}
EXPECT_TRUE(ok) << serr->str();
err_rms = std::sqrt(err_rms / 50);
EXPECT_LT(err_rms, 0.0002);

Expand Down