test_sonar_lut.cpp
Go to the documentation of this file.
1 /*********************************************************************
2  * C++ unit test for dbw_mkz_can/sonar_lut.h
3  *********************************************************************/
4 
5 #include <gtest/gtest.h>
6 
7 // File under test
9 using namespace dbw_mkz_can;
10 
11 // Test converting sonar ranges
13 {
14  EXPECT_EQ((float) 0.00, sonarMetersFromBits(0));
15  EXPECT_EQ((float) 0.30, sonarMetersFromBits(1));
16  EXPECT_EQ((float) 0.45, sonarMetersFromBits(2));
17  EXPECT_EQ((float) 0.60, sonarMetersFromBits(3));
18  EXPECT_EQ((float) 0.75, sonarMetersFromBits(4));
19  EXPECT_EQ((float) 0.90, sonarMetersFromBits(5));
20  EXPECT_EQ((float) 1.05, sonarMetersFromBits(6));
21  EXPECT_EQ((float) 1.20, sonarMetersFromBits(7));
22  EXPECT_EQ((float) 1.35, sonarMetersFromBits(8));
23  EXPECT_EQ((float) 1.50, sonarMetersFromBits(9));
24  EXPECT_EQ((float) 1.65, sonarMetersFromBits(10));
25  EXPECT_EQ((float) 1.80, sonarMetersFromBits(11));
26  EXPECT_EQ((float) 1.95, sonarMetersFromBits(12));
27  EXPECT_EQ((float) 2.10, sonarMetersFromBits(13));
28  EXPECT_EQ((float) 2.25, sonarMetersFromBits(14));
29  EXPECT_EQ((float) 2.40, sonarMetersFromBits(15));
30  EXPECT_EQ((float)15.15, sonarMetersFromBits(100));
31 }
32 
33 // Test converting sonar colors
35 {
36  const uint32_t RED = 0xC0FF0000; // rgba = RED
37  const uint32_t YLW = 0xC0FFFF00; // rgba = YELLOW
38  const uint32_t GRN = 0xC000FF00; // rgba = GREEN
39 
40  EXPECT_EQ(RED, sonarColorFromRange(-INFINITY));
41  EXPECT_EQ(RED, sonarColorFromRange(0.00));
42  EXPECT_EQ(RED, sonarColorFromRange(0.30));
43  EXPECT_EQ(RED, sonarColorFromRange(0.45));
44  EXPECT_EQ(RED, sonarColorFromRange(0.60));
45  EXPECT_EQ(YLW, sonarColorFromRange(0.75));
46  EXPECT_EQ(YLW, sonarColorFromRange(0.90));
47  EXPECT_EQ(YLW, sonarColorFromRange(1.05));
48  EXPECT_EQ(YLW, sonarColorFromRange(1.20));
49  EXPECT_EQ(GRN, sonarColorFromRange(1.35));
50  EXPECT_EQ(GRN, sonarColorFromRange(1.50));
51  EXPECT_EQ(GRN, sonarColorFromRange(INFINITY));
52 }
53 
55 
56 int main(int argc, char **argv)
57 {
58  testing::InitGoogleTest(&argc, argv);
59  return RUN_ALL_TESTS();
60 }
61 
static float sonarMetersFromBits(uint8_t bits)
Definition: sonar_lut.h:58
TEST(sonar_lut, sonarMetersFromBits)
int main(int argc, char **argv)
: Create test for sonarBuildPointCloud2()
static uint32_t sonarColorFromRange(float range)
Definition: sonar_lut.h:61


dbw_mkz_can
Author(s): Kevin Hallenbeck
autogenerated on Fri May 14 2021 02:47:08