15 #include <gtest/gtest.h>
20 #include <range/v3/range/conversion.hpp>
22 #if BELUGA_ROS_VERSION == 1
23 #include <boost/smart_ptr.hpp>
32 #if BELUGA_ROS_VERSION == 2
33 return std::make_shared<beluga_ros::msg::LaserScan>();
34 #elif BELUGA_ROS_VERSION == 1
35 return boost::make_shared<beluga_ros::msg::LaserScan>();
39 TEST(TestLaserScan, MinMaxRangeFromMessage) {
41 message->ranges = std::vector<float>{1., 2., 3.};
45 ASSERT_EQ(scan.min_range(), 10.);
46 ASSERT_EQ(scan.max_range(), 100.);
49 TEST(TestLaserScan, MinMaxRangeFromConstructor) {
54 constexpr
auto kMaxBeams = 100UL;
55 constexpr
auto kMinRange = 15.;
56 constexpr
auto kMaxRange = 95.;
58 ASSERT_EQ(scan.min_range(), 15.);
59 ASSERT_EQ(scan.max_range(), 95.);
62 TEST(TestLaserScan, LimitMaxBeams) {
64 message->ranges = std::vector<float>{1., 2., 3.};
66 constexpr
auto kMaxBeams = 2UL;
68 auto ranges = scan.ranges() | ranges::to<std::vector>;
69 ASSERT_EQ(ranges.size(), 2UL);
72 TEST(TestLaserScan, AngleIncrements) {
74 message->ranges = std::vector<float>{1., 2., 3.};
79 message->angle_increment = 0.1F;
81 constexpr
auto kMaxBeams = 100UL;
83 auto angles = scan.angles() | ranges::to<std::vector>;
84 ASSERT_NEAR(angles[0], 0.0, 0.001);
85 ASSERT_NEAR(angles[1], 0.1, 0.001);
86 ASSERT_NEAR(angles[2], 0.2, 0.001);