1 #include <gtest/gtest.h> 5 #include "../../../src/core/states/sensor_data.h" 7 #include "../mock_grid_cell.h" 8 #include "../../../src/core/maps/plain_grid_map.h" 9 #include "../../../src/utils/data_generation/map_primitives.h" 10 #include "../../../src/utils/data_generation/grid_map_patcher.h" 11 #include "../../../src/utils/data_generation/laser_scan_generator.h" 25 const double range,
const double angle_rad,
26 const double x,
const double y) {
36 assert(0 &&
"Unknown ScanPoint2D type");
96 const double D_Angle =
deg2rad(3), D_Range = -0.1;
97 auto cartesian_sp = polar_sp.to_cartesian(D_Angle, D_Range);
99 ASSERT_NEAR(polar_sp.range() + D_Range, cartesian_sp.range(),
Acc_Error);
100 ASSERT_NEAR(polar_sp.angle() + D_Angle, cartesian_sp.angle(),
Acc_Error);
101 ASSERT_EQ(polar_sp.is_occupied(), cartesian_sp.is_occupied());
113 const double D_X = -8, D_Y = 4;
114 auto polar_sp = cartesian_sp.to_polar(D_X, D_Y);
116 ASSERT_NEAR(cartesian_sp.x() + D_X, polar_sp.x(),
Acc_Error);
117 ASSERT_NEAR(cartesian_sp.y() + D_Y, polar_sp.y(),
Acc_Error);
118 ASSERT_EQ(cartesian_sp.is_occupied(), polar_sp.is_occupied());
124 const double D_Angle =
deg2rad(23);
125 auto rtp = std::make_shared<RawTrigonometryProvider>();
126 rtp->set_base_angle(D_Angle);
127 auto cartesian_sp = polar_sp.to_cartesian(rtp);
129 ASSERT_NEAR(polar_sp.range(), cartesian_sp.range(),
Acc_Error);
130 ASSERT_NEAR(polar_sp.angle() + D_Angle, cartesian_sp.angle(),
Acc_Error);
131 ASSERT_EQ(polar_sp.is_occupied(), cartesian_sp.is_occupied());
155 auto mp_free_space = cecum_mp.free_space()[0];
157 auto pose =
RobotPose{mp_free_space.left() + mp_free_space.hside_len() / 2,
158 mp_free_space.bot() + mp_free_space.vside_len() / 2,
162 auto scan = lsg.laser_scan_2D(map, pose, 1);
164 const auto D_Angle =
deg2rad(7);
165 auto rotated_scan = scan.to_cartesian(D_Angle);
167 ASSERT_EQ(scan.points().size(), rotated_scan.points().size());
168 for (std::size_t i = 0; i < scan.points().size(); ++i) {
169 check_sp_rotation(D_Angle, scan.points()[i], rotated_scan.points()[i]);
175 int main (
int argc,
char *argv[]) {
176 ::testing::InitGoogleTest(&argc, argv);
177 return RUN_ALL_TESTS();
int main(int argc, char *argv[])
void assert_scan_point(const ScanPoint2D &expected, const ScanPoint2D &actual)
void apply_text_raster(MapType &dst_map, std::istream &src_raster, const DiscretePoint2D &dst_offset, int w_zoom=1, int h_zoom=1)
void check_sp_rotation(double d_angle, const ScanPoint2D &expected, const ScanPoint2D &actual)
static constexpr double Acc_Error
void smoke_check_point(SPPT type, const double range, const double angle_rad, const double x, const double y)
constexpr double deg2rad(double angle_deg)
TEST_F(ScanPoint2DTest, polar1Quad)