25 #include "cartographer/sensor/proto/sensor.pb.h" 26 #include "gtest/gtest.h" 32 TEST(Collator, Ordering) {
33 const std::array<string, 4> kSensorId = {
34 {
"horizontal_rangefinder",
"vertical_rangefinder",
"imu",
"odometry"}};
43 std::vector<std::pair<string, Data>> received;
45 collator.AddTrajectory(
46 0, std::unordered_set<string>(kSensorId.begin(), kSensorId.end()),
47 [&received](
const string& sensor_id, std::unique_ptr<Data> data) {
48 received.push_back(std::make_pair(sensor_id, *data));
51 constexpr
int kTrajectoryId = 0;
54 collator.AddSensorData(kTrajectoryId, kSensorId[0],
55 common::make_unique<Data>(zero));
56 collator.AddSensorData(kTrajectoryId, kSensorId[1],
57 common::make_unique<Data>(zero));
58 collator.AddSensorData(kTrajectoryId, kSensorId[2],
59 common::make_unique<Data>(zero));
60 collator.AddSensorData(kTrajectoryId, kSensorId[3],
61 common::make_unique<Data>(zero));
63 collator.AddSensorData(kTrajectoryId, kSensorId[0],
64 common::make_unique<Data>(first));
65 collator.AddSensorData(kTrajectoryId, kSensorId[3],
66 common::make_unique<Data>(sixth));
67 collator.AddSensorData(kTrajectoryId, kSensorId[0],
68 common::make_unique<Data>(fourth));
69 collator.AddSensorData(kTrajectoryId, kSensorId[1],
70 common::make_unique<Data>(second));
71 collator.AddSensorData(kTrajectoryId, kSensorId[1],
72 common::make_unique<Data>(fifth));
73 collator.AddSensorData(kTrajectoryId, kSensorId[2],
74 common::make_unique<Data>(third));
76 ASSERT_EQ(7, received.size());
78 EXPECT_EQ(kSensorId[0], received[4].first);
80 EXPECT_EQ(kSensorId[1], received[5].first);
82 EXPECT_EQ(kSensorId[2], received[6].first);
86 ASSERT_EQ(10, received.size());
87 EXPECT_EQ(kSensorId[0], received[7].first);
89 EXPECT_EQ(kSensorId[1], received[8].first);
91 EXPECT_EQ(kSensorId[3], received[9].first);
Time FromUniversal(const int64 ticks)
int64 ToUniversal(const Time time)