memory_blocs_parser_extended_navigation.test.cc
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 
10 
11 using namespace ixblue_stdbin_decoder;
12 
13 TEST(MemoryBocksParser, ParseRotationAccelerationVesselFrame)
14 {
15  // xv1 : -1.5f (0xbfc00000), xv2 : 1.25f( 0x3fa00000 ), xv3 : 12.55f
16  // (0x4148cccd)
17  // clang-format off
18  const std::vector<uint8_t> memory{
19  0xbf, 0xc0, 0x00, 0x00,
20  0x3f, 0xa0, 0x00, 0x00,
21  0x41, 0x48, 0xcc, 0xcd
22  };
23  // clang-format on
24  auto buffer = boost::asio::buffer(memory.data(), memory.size());
25 
27  Data::BinaryNav binaryNav;
28  parser.parse(buffer, binaryNav);
29 
30  ASSERT_TRUE(binaryNav.rotationAccelerationVesselFrame.is_initialized());
31  ASSERT_FLOAT_EQ(-1.5, binaryNav.rotationAccelerationVesselFrame.get().xv1_degsec2);
32  ASSERT_FLOAT_EQ(1.25, binaryNav.rotationAccelerationVesselFrame.get().xv2_degsec2);
33  ASSERT_FLOAT_EQ(12.55, binaryNav.rotationAccelerationVesselFrame.get().xv3_degsec2);
34 
35  // We also check that buffer was completly consumed by parser.
36  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
37 }
38 
39 TEST(MemoryBocksParser, ParseRotationAccelerationVesselFrameDeviation)
40 {
41  // xv1SD : -1.5f (0xbfc00000), xv2SD : 1.25f( 0x3fa00000 ), xv3SD : 12.55f
42  // (0x4148cccd)
43  // clang-format off
44  const std::vector<uint8_t> memory{
45  0xbf, 0xc0, 0x00, 0x00,
46  0x3f, 0xa0, 0x00, 0x00,
47  0x41, 0x48, 0xcc, 0xcd
48  };
49  // clang-format on
50  auto buffer = boost::asio::buffer(memory.data(), memory.size());
51 
53  Data::BinaryNav binaryNav;
54  parser.parse(buffer, binaryNav);
55 
56  ASSERT_TRUE(binaryNav.rotationAccelerationVesselFrameDeviation.is_initialized());
57  ASSERT_FLOAT_EQ(
58  -1.5,
59  binaryNav.rotationAccelerationVesselFrameDeviation.get().xv1_stddev_degsec2);
60  ASSERT_FLOAT_EQ(
61  1.25,
62  binaryNav.rotationAccelerationVesselFrameDeviation.get().xv2_stddev_degsec2);
63  ASSERT_FLOAT_EQ(
64  12.55,
65  binaryNav.rotationAccelerationVesselFrameDeviation.get().xv3_stddev_degsec2);
66 
67  // We also check that buffer was completly consumed by parser.
68  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
69 }
70 
71 TEST(MemoryBocksParser, ParseRawRotationRateVesselFrame)
72 {
73  // xv1 : -1.5f (0xbfc00000), xv2 : 1.25f( 0x3fa00000 ), xv3 : 12.55f
74  // (0x4148cccd)
75  // clang-format off
76  const std::vector<uint8_t> memory{
77  0xbf, 0xc0, 0x00, 0x00,
78  0x3f, 0xa0, 0x00, 0x00,
79  0x41, 0x48, 0xcc, 0xcd
80  };
81  // clang-format on
82  auto buffer = boost::asio::buffer(memory.data(), memory.size());
83 
85  Data::BinaryNav binaryNav;
86  parser.parse(buffer, binaryNav);
87 
88  ASSERT_TRUE(binaryNav.rawRotationRateVesselFrame.is_initialized());
89  ASSERT_FLOAT_EQ(-1.5, binaryNav.rawRotationRateVesselFrame.get().xv1_degsec);
90  ASSERT_FLOAT_EQ(1.25, binaryNav.rawRotationRateVesselFrame.get().xv2_degsec);
91  ASSERT_FLOAT_EQ(12.55, binaryNav.rawRotationRateVesselFrame.get().xv3_degsec);
92 
93  // We also check that buffer was completly consumed by parser.
94  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
95 }
96 
97 TEST(MemoryBocksParser, ParseVehicleAttitudeHeading)
98 {
99  // xv1 : -1.5f (0xbfc00000), xv2 : 1.25f( 0x3fa00000 ), xv3 : 12.55f
100  // (0x4148cccd)
101  // clang-format off
102  const std::vector<uint8_t> memory{
103  0xbf, 0xc0, 0x00, 0x00,
104  0x3f, 0xa0, 0x00, 0x00,
105  0x41, 0x48, 0xcc, 0xcd
106  };
107  // clang-format on
108  auto buffer = boost::asio::buffer(memory.data(), memory.size());
109 
111  Data::BinaryNav binaryNav;
112  parser.parse(buffer, binaryNav);
113 
114  ASSERT_TRUE(binaryNav.vehicleAttitudeHeading.is_initialized());
115  ASSERT_FLOAT_EQ(-1.5, binaryNav.vehicleAttitudeHeading.get().heading_deg);
116  ASSERT_FLOAT_EQ(1.25, binaryNav.vehicleAttitudeHeading.get().roll_deg);
117  ASSERT_FLOAT_EQ(12.55, binaryNav.vehicleAttitudeHeading.get().pitch_deg);
118 
119  // We also check that buffer was completly consumed by parser.
120  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
121 }
122 
123 TEST(MemoryBocksParser, ParseVehicleAttitudeHeadingDeviation)
124 {
125  // xv1SD : -1.5f (0xbfc00000), xv2SD : 1.25f( 0x3fa00000 ), xv3SD : 12.55f
126  // (0x4148cccd)
127  // clang-format off
128  const std::vector<uint8_t> memory{
129  0xbf, 0xc0, 0x00, 0x00,
130  0x3f, 0xa0, 0x00, 0x00,
131  0x41, 0x48, 0xcc, 0xcd
132  };
133  // clang-format on
134  auto buffer = boost::asio::buffer(memory.data(), memory.size());
135 
137  Data::BinaryNav binaryNav;
138  parser.parse(buffer, binaryNav);
139 
140  ASSERT_TRUE(binaryNav.vehicleAttitudeHeadingDeviation.is_initialized());
141  ASSERT_FLOAT_EQ(-1.5,
142  binaryNav.vehicleAttitudeHeadingDeviation.get().heading_stddev_deg);
143  ASSERT_FLOAT_EQ(1.25,
144  binaryNav.vehicleAttitudeHeadingDeviation.get().roll_stddev_deg);
145  ASSERT_FLOAT_EQ(12.55,
146  binaryNav.vehicleAttitudeHeadingDeviation.get().pitch_stddev_deg);
147 
148  // We also check that buffer was completly consumed by parser.
149  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
150 }
151 
152 TEST(MemoryBocksParser, ParseVehiclePosition)
153 {
154  // latitude : 25.68d (0x4039ae147ae147ae), longitude : -4.75d (0xc013000000000000),
155  // altitude ref : 1 (0x01), altitude : 154.21f (0x43 1a 35 c3)
156  // clang-format off
157  const std::vector<uint8_t> memory{
158  0x40, 0x39, 0xae, 0x14,
159  0x7a, 0xe1, 0x47, 0xae,
160  0xc0, 0x13, 0x00, 0x00,
161  0x00, 0x00, 0x00, 0x00,
162  0x01,
163  0x43, 0x1a, 0x35, 0xc3
164  };
165  // clang-format on
166  auto buffer = boost::asio::buffer(memory.data(), memory.size());
167 
169  Data::BinaryNav binaryNav;
170  parser.parse(buffer, binaryNav);
171 
172  ASSERT_TRUE(binaryNav.vehiclePosition.is_initialized());
173  ASSERT_DOUBLE_EQ(25.68, binaryNav.vehiclePosition.get().latitude_deg);
174  ASSERT_DOUBLE_EQ(-4.75, binaryNav.vehiclePosition.get().longitude_deg);
175  ASSERT_EQ(1, binaryNav.vehiclePosition.get().altitude_ref);
176  ASSERT_FLOAT_EQ(154.21, binaryNav.vehiclePosition.get().altitude_m);
177 
178  // We also check that buffer was completly consumed by parser.
179  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
180 }
181 
182 TEST(MemoryBocksParser, ParseVehiclePositionDeviation)
183 {
184  // NorthSD : 1.25f( 0x3fa00000 ), EastSD : 12.55f (0x4148cccd), NEcorr : -1.5f
185  // (0xbfc00000), altSD : -0.005f(0xbba3d70a)
186  // clang-format off
187  const std::vector<uint8_t> memory{
188  0x3f, 0xa0, 0x00, 0x00,
189  0x41, 0x48, 0xcc, 0xcd,
190  0xbf, 0xc0, 0x00, 0x00,
191  0xbb, 0xa3, 0xd7, 0x0a
192  };
193  // clang-format on
194  auto buffer = boost::asio::buffer(memory.data(), memory.size());
195 
197  Data::BinaryNav binaryNav;
198  parser.parse(buffer, binaryNav);
199 
200  ASSERT_TRUE(binaryNav.vehiclePositionDeviation.is_initialized());
201  ASSERT_FLOAT_EQ(1.25, binaryNav.vehiclePositionDeviation.get().north_stddev_m);
202  ASSERT_FLOAT_EQ(12.55, binaryNav.vehiclePositionDeviation.get().east_stddev_m);
203  ASSERT_FLOAT_EQ(-1.5, binaryNav.vehiclePositionDeviation.get().north_east_corr);
204  ASSERT_FLOAT_EQ(-0.005, binaryNav.vehiclePositionDeviation.get().altitude_stddev_m);
205 
206  // We also check that buffer was completly consumed by parser.
207  ASSERT_EQ(0, boost::asio::buffer_size(buffer));
208 }
209 
210 int main(int argc, char** argv)
211 {
212  ::testing::InitGoogleTest(&argc, argv);
213  return RUN_ALL_TESTS();
214 }
boost::optional< RawRotationRateVesselFrame > rawRotationRateVesselFrame
Definition: stdbin.h:106
TEST(MemoryBocksParser, ParseRotationAccelerationVesselFrame)
boost::optional< VehicleAttitudeHeadingDeviation > vehicleAttitudeHeadingDeviation
Definition: stdbin.h:108
boost::optional< VehiclePositionDeviation > vehiclePositionDeviation
Definition: stdbin.h:110
boost::optional< RotationAccelerationVesselFrameDeviation > rotationAccelerationVesselFrameDeviation
Definition: stdbin.h:105
boost::optional< VehiclePosition > vehiclePosition
Definition: stdbin.h:109
boost::optional< RotationAccelerationVesselFrame > rotationAccelerationVesselFrame
Definition: stdbin.h:103
boost::optional< VehicleAttitudeHeading > vehicleAttitudeHeading
Definition: stdbin.h:107
int main(int argc, char **argv)


ixblue_stdbin_decoder
Author(s): Adrien BARRAL , Laure LEBROTON
autogenerated on Sat Jan 9 2021 03:13:21