test_ixblue_ins_driver.cpp
Go to the documentation of this file.
1 #include <gtest/gtest.h>
2 
3 #include "../src/ros_publisher.h"
4 
5 TEST(ROSPublisherTester, CanFillANavSatFixMsg)
6 {
8  pos.latitude_deg = 1.2345;
9  pos.longitude_deg = 9.8745;
10  pos.altitude_m = 123.456;
11 
13  posDev.north_stddev_m = 0.3;
14  posDev.east_stddev_m = 1.2;
15  posDev.north_east_corr = 2.7;
16  posDev.altitude_stddev_m = 4.5;
17 
19  nav.position = pos;
20  nav.positionDeviation = posDev;
21 
22  const sensor_msgs::NavSatFixPtr msg = ROSPublisher::toNavSatFixMsg(nav);
23  ASSERT_NE(msg, nullptr);
24  EXPECT_EQ(msg->latitude, pos.latitude_deg);
25  EXPECT_EQ(msg->longitude, pos.longitude_deg);
26  EXPECT_EQ(msg->altitude, pos.altitude_m);
27  EXPECT_EQ(msg->position_covariance_type, sensor_msgs::NavSatFix::COVARIANCE_TYPE_DIAGONAL_KNOWN);
28  EXPECT_EQ(msg->position_covariance[0], posDev.east_stddev_m * posDev.east_stddev_m);
29  EXPECT_EQ(msg->position_covariance[4], posDev.north_stddev_m * posDev.north_stddev_m);
30  EXPECT_EQ(msg->position_covariance[8], posDev.altitude_stddev_m * posDev.altitude_stddev_m);
31 }
32 
33 TEST(ROSPublisherTester, CannotFillANavSatFixMsgIfNoPositionInNav)
34 {
36  const sensor_msgs::NavSatFixPtr msg = ROSPublisher::toNavSatFixMsg(nav);
37  EXPECT_EQ(msg, nullptr);
38 }
39 
40 TEST(ROSPublisherTester, CanFillANavSatFixMsgButNoCovarianceIfNoPositionDeviationInNav)
41 {
43  pos.latitude_deg = 1.2345;
44  pos.longitude_deg = 9.8745;
45  pos.altitude_m = 123.456;
46 
48  nav.position = pos;
49 
50  const sensor_msgs::NavSatFixPtr msg = ROSPublisher::toNavSatFixMsg(nav);
51  ASSERT_NE(msg, nullptr);
52  EXPECT_EQ(msg->latitude, pos.latitude_deg);
53  EXPECT_EQ(msg->longitude, pos.longitude_deg);
54  EXPECT_EQ(msg->altitude, pos.altitude_m);
55  EXPECT_EQ(msg->position_covariance_type, sensor_msgs::NavSatFix::COVARIANCE_TYPE_UNKNOWN);
56 }
57 
58 TEST(ROSPublisherTester, CanFillANavSatFixMsgWithWestLong)
59 {
61  pos.latitude_deg = -23.454; // stdbin output [-90°,+90°]
62  pos.longitude_deg = 270.34; // stdbin output [0°,360°[
63  pos.altitude_m = 123.456;
64 
66  nav.position = pos;
67 
68  const sensor_msgs::NavSatFixPtr msg = ROSPublisher::toNavSatFixMsg(nav);
69  ASSERT_NE(msg, nullptr);
70  EXPECT_EQ(msg->latitude, -23.454);
71  EXPECT_DOUBLE_EQ(msg->longitude, -89.66);
72  EXPECT_EQ(msg->altitude, pos.altitude_m);
73  EXPECT_EQ(msg->position_covariance_type,
74  sensor_msgs::NavSatFix::COVARIANCE_TYPE_UNKNOWN);
75 }
76 
77 int main(int argc, char** argv)
78 {
79  ::testing::InitGoogleTest(&argc, argv);
80  return RUN_ALL_TESTS();
81 }
msg
boost::optional< Position > position
static sensor_msgs::NavSatFixPtr toNavSatFixMsg(const ixblue_stdbin_decoder::Data::BinaryNav &navData)
boost::optional< PositionDeviation > positionDeviation
int main(int argc, char **argv)
TEST(ROSPublisherTester, CanFillANavSatFixMsg)
int pos


ixblue_ins_driver
Author(s): Adrien BARRAL , Laure LE BRETON
autogenerated on Wed Jan 27 2021 03:37:01