Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef CARTOGRAPHER_SENSOR_INTERNAL_TEST_HELPERS_H_
00018 #define CARTOGRAPHER_SENSOR_INTERNAL_TEST_HELPERS_H_
00019
00020 #include <string>
00021 #include <tuple>
00022
00023 #include "absl/memory/memory.h"
00024 #include "cartographer/common/time.h"
00025 #include "cartographer/sensor/collator_interface.h"
00026 #include "cartographer/sensor/imu_data.h"
00027 #include "cartographer/sensor/internal/dispatchable.h"
00028 #include "cartographer/sensor/odometry_data.h"
00029 #include "cartographer/sensor/timed_point_cloud_data.h"
00030 #include "gmock/gmock.h"
00031
00032 namespace cartographer {
00033 namespace sensor {
00034
00035 MATCHER_P(Near, point, std::string(negation ? "Doesn't" : "Does") + " match.") {
00036 return arg.isApprox(point, 0.001f);
00037 }
00038
00039 namespace testing {
00040
00041 typedef std::tuple<int , std::string ,
00042 common::Time>
00043 CollatorOutput;
00044
00045 struct CollatorInput {
00046 static CollatorInput CreateImuData(int trajectory_id,
00047 const std::string& sensor_id, int time) {
00048 return CollatorInput{
00049 trajectory_id,
00050 MakeDispatchable(sensor_id, ImuData{common::FromUniversal(time)}),
00051 CollatorOutput{trajectory_id, sensor_id, common::FromUniversal(time)}};
00052 }
00053 static CollatorInput CreateTimedPointCloudData(int trajectory_id,
00054 const std::string& sensor_id,
00055 int time) {
00056 return CollatorInput{
00057 trajectory_id,
00058 MakeDispatchable(
00059 sensor_id,
00060 TimedPointCloudData{
00061 common::FromUniversal(time), Eigen::Vector3f::Zero(), {}}),
00062 CollatorOutput{trajectory_id, sensor_id, common::FromUniversal(time)}};
00063 }
00064 static CollatorInput CreateOdometryData(int trajectory_id,
00065 const std::string& sensor_id,
00066 int time) {
00067 return CollatorInput{
00068 trajectory_id,
00069 MakeDispatchable(sensor_id,
00070 OdometryData{common::FromUniversal(time),
00071 transform::Rigid3d::Identity()}),
00072 CollatorOutput{trajectory_id, sensor_id, common::FromUniversal(time)}};
00073 }
00074 void MoveToCollator(CollatorInterface* collator) {
00075 collator->AddSensorData(trajectory_id, std::move(data));
00076 }
00077
00078 const int trajectory_id;
00079 std::unique_ptr<Data> data;
00080 const CollatorOutput expected_output;
00081 };
00082
00083 }
00084 }
00085 }
00086
00087 #endif // CARTOGRAPHER_SENSOR_INTERNAL_TEST_HELPERS_H_