28 #include "gtest/gtest.h" 34 using test::CollatorInput;
37 TEST(TrajectoryCollator, OrderingMultipleTrajectories) {
38 const int kTrajectoryId[] = {4, 7};
39 const std::array<std::string, 2> kSensorId = {{
"my_points",
"some_imu"}};
41 std::vector<CollatorInput> input_data;
43 input_data.push_back(CollatorInput::CreateTimedPointCloudData(
44 kTrajectoryId[0], kSensorId[0], 0));
45 input_data.push_back(CollatorInput::CreateTimedPointCloudData(
46 kTrajectoryId[1], kSensorId[0], 0));
48 CollatorInput::CreateImuData(kTrajectoryId[1], kSensorId[1], 0));
50 CollatorInput::CreateImuData(kTrajectoryId[0], kSensorId[1], 0));
51 input_data.push_back(CollatorInput::CreateTimedPointCloudData(
52 kTrajectoryId[1], kSensorId[0], 100));
53 input_data.push_back(CollatorInput::CreateTimedPointCloudData(
54 kTrajectoryId[0], kSensorId[0], 50));
56 CollatorInput::CreateImuData(kTrajectoryId[0], kSensorId[1], 60));
57 input_data.push_back(CollatorInput::CreateTimedPointCloudData(
58 kTrajectoryId[1], kSensorId[0], 150));
60 CollatorInput::CreateImuData(kTrajectoryId[1], kSensorId[1], 120));
62 std::vector<CollatorOutput> received;
63 TrajectoryCollator collator;
64 collator.AddTrajectory(
66 std::unordered_set<std::string>(kSensorId.begin(), kSensorId.end()),
67 [&received, kTrajectoryId](
const std::string& sensor_id,
68 std::unique_ptr<Data> data) {
69 received.push_back(
CollatorOutput(kTrajectoryId[0], data->GetSensorId(),
72 collator.AddTrajectory(
74 std::unordered_set<std::string>(kSensorId.begin(), kSensorId.end()),
75 [&received, kTrajectoryId](
const std::string& sensor_id,
76 std::unique_ptr<Data> data) {
77 received.push_back(
CollatorOutput(kTrajectoryId[1], data->GetSensorId(),
82 input_data[0].MoveToCollator(&collator);
83 input_data[1].MoveToCollator(&collator);
84 EXPECT_EQ(0, received.size());
85 input_data[2].MoveToCollator(&collator);
86 input_data[3].MoveToCollator(&collator);
87 EXPECT_EQ(2, received.size());
88 EXPECT_EQ(input_data[1].expected_output, received[0]);
89 EXPECT_EQ(input_data[0].expected_output, received[1]);
92 input_data[4].MoveToCollator(&collator);
93 EXPECT_EQ(3, received.size());
94 EXPECT_EQ(input_data[2].expected_output, received[2]);
96 input_data[5].MoveToCollator(&collator);
97 EXPECT_EQ(4, received.size());
98 EXPECT_EQ(input_data[3].expected_output, received[3]);
99 input_data[6].MoveToCollator(&collator);
100 EXPECT_EQ(5, received.size());
101 EXPECT_EQ(input_data[5].expected_output, received[4]);
104 input_data[7].MoveToCollator(&collator);
105 EXPECT_EQ(5, received.size());
106 input_data[8].MoveToCollator(&collator);
107 EXPECT_EQ(7, received.size());
108 EXPECT_EQ(input_data[4].expected_output, received[5]);
109 EXPECT_EQ(input_data[8].expected_output, received[6]);
111 EXPECT_FALSE(collator.GetBlockingTrajectoryId().has_value());
113 collator.FinishTrajectory(kTrajectoryId[0]);
114 collator.FinishTrajectory(kTrajectoryId[1]);
116 ASSERT_EQ(input_data.size(), received.size());
std::tuple< int, std::string, common::Time > CollatorOutput
TEST(TrajectoryConnectivityStateTest, UnknownTrajectory)