35 #include <gtest/gtest.h> 41 static const float eps = 1e-6;
48 snapshot_.angle_min = 10.0;
49 snapshot_.angle_increment = 1.0;
50 snapshot_.readings_per_scan = 4;
51 snapshot_.num_scans = 3;
52 snapshot_.ranges.resize(12);
53 for (
unsigned int i=0; i<snapshot_.ranges.size(); i++)
54 snapshot_.ranges[i] = i*100;
59 points_[0] = Point(0,0);
60 points_[1] = Point(3,0);
61 points_[2] = Point(0,2);
62 points_[3] = Point(3,2);
64 points_[4] = Point(2.5, .5);
65 points_[5] = Point(2, 1);
66 points_[6] = Point(1.25, 1.5);
73 geometry_msgs::Point
Point(
float x,
float y)
75 geometry_msgs::Point point;
81 std::vector <geometry_msgs::Point>
points_;
89 EXPECT_NEAR(angles_[0], 10.0,
eps);
90 EXPECT_NEAR(angles_[1], 13.0,
eps);
91 EXPECT_NEAR(angles_[2], 10.0,
eps);
92 EXPECT_NEAR(angles_[3], 13.0,
eps);
93 EXPECT_NEAR(angles_[4], 12.5,
eps);
94 EXPECT_NEAR(angles_[5], 12.0,
eps);
95 EXPECT_NEAR(angles_[6], 11.25,
eps);
107 EXPECT_NEAR(ranges_[0], 0.0,
eps);
108 EXPECT_NEAR(ranges_[1], 300.0,
eps);
109 EXPECT_NEAR(ranges_[2], 800.0,
eps);
110 EXPECT_NEAR(ranges_[3], 1100.0,
eps);
111 EXPECT_NEAR(ranges_[4], 450.0,
eps);
112 EXPECT_NEAR(ranges_[5], 600.0,
eps);
113 EXPECT_NEAR(ranges_[6], 725.0,
eps);
118 points_[6] = Point(-1.0, 0);
119 EXPECT_FALSE(
interpSnapshot(points_, snapshot_, angles_, ranges_));
121 points_[6] = Point(0, -1.0);
122 EXPECT_FALSE(
interpSnapshot(points_, snapshot_, angles_, ranges_));
124 points_[6] = Point(3.1, 1.9);
125 EXPECT_FALSE(
interpSnapshot(points_, snapshot_, angles_, ranges_));
127 points_[6] = Point(2.9, 2.1);
128 EXPECT_FALSE(
interpSnapshot(points_, snapshot_, angles_, ranges_));
131 points_[6] = Point(1, 1);
132 EXPECT_TRUE(
interpSnapshot(points_, snapshot_, angles_, ranges_));
137 int main(
int argc,
char **argv){
138 testing::InitGoogleTest(&argc, argv);
139 return RUN_ALL_TESTS();
int main(int argc, char **argv)
TEST_F(InterpSnapshot_EasyTests, angles)
bool interpSnapshot(const std::vector< geometry_msgs::Point > &points, const calibration_msgs::DenseLaserSnapshot &snapshot, std::vector< float > &pointing_angles, std::vector< float > &ranges)
calibration_msgs::DenseLaserSnapshot snapshot_
std::vector< geometry_msgs::Point > points_
geometry_msgs::Point Point(float x, float y)