test_isa_model.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2022-2023 RaccoonLab.
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, version 3.
7  *
8  * This program is distributed in the hope that it will be useful, but
9  * WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  * General Public License for more details.
12  *
13  * You should have received a copy of the GNU General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Author: Dmitry Ponomarev <ponomarevda96@gmail.com>
17  */
18 
19 #include <gtest/gtest.h>
20 #include <cmath>
21 #include <iostream>
22 #include <geographiclib_conversions/geodetic_conv.hpp>
23 #include "sensors_isa_model.hpp"
24 #include <ros/ros.h>
25 
26 
27 TEST(IsaModel, diffPressureHpaMax){
28  Eigen::Vector3d gpsPosition(55.7544426, 48.742684, 0),
29  linVelNed(100, 0, 0),
30  enuPosition(0, 0, 0);
31  geodetic_converter::GeodeticConverter geodeticConverter;
32  geodeticConverter.initialiseReference(gpsPosition[0], gpsPosition[1], gpsPosition[2]);
33  geodeticConverter.enu2Geodetic(enuPosition[0], enuPosition[1], enuPosition[2],
34  &gpsPosition[0], &gpsPosition[1], &gpsPosition[2]);
35  double expectedDiffPressureHpa = 61.25;
36 
37  float temperatureKelvin, absPressureHpa, diffPressureHpa;
38  SensorModelISA::EstimateAtmosphere(gpsPosition, linVelNed,
39  temperatureKelvin, absPressureHpa, diffPressureHpa);
40  EXPECT_NEAR(diffPressureHpa, expectedDiffPressureHpa, 0.01);
41 }
42 TEST(IsaModel, diffPressureHpaZero){
43  Eigen::Vector3d gpsPosition(55.7544426, 48.742684, 0),
44  linVelNed(0, 0, 0),
45  enuPosition(0, 0, 0);
46  geodetic_converter::GeodeticConverter geodeticConverter;
47  geodeticConverter.initialiseReference(gpsPosition[0], gpsPosition[1], gpsPosition[2]);
48  geodeticConverter.enu2Geodetic(enuPosition[0], enuPosition[1], enuPosition[2],
49  &gpsPosition[0], &gpsPosition[1], &gpsPosition[2]);
50  double expectedDiffPressureHpa = 0;
51 
52  float temperatureKelvin, absPressureHpa, diffPressureHpa;
53  SensorModelISA::EstimateAtmosphere(gpsPosition, linVelNed,
54  temperatureKelvin, absPressureHpa, diffPressureHpa);
55  EXPECT_NEAR(diffPressureHpa, expectedDiffPressureHpa, 0.01);
56 }
57 TEST(IsaModel, diffPressureHpaMin){
58  Eigen::Vector3d gpsPosition(55.7544426, 48.742684, 0),
59  linVelNed(-100, 0, 0),
60  enuPosition(0, 0, 0);
61  geodetic_converter::GeodeticConverter geodeticConverter;
62  geodeticConverter.initialiseReference(gpsPosition[0], gpsPosition[1], gpsPosition[2]);
63  geodeticConverter.enu2Geodetic(enuPosition[0], enuPosition[1], enuPosition[2],
64  &gpsPosition[0], &gpsPosition[1], &gpsPosition[2]);
65  double expectedDiffPressureHpa = 61.25;
66 
67  float temperatureKelvin, absPressureHpa, diffPressureHpa;
68  SensorModelISA::EstimateAtmosphere(gpsPosition, linVelNed,
69  temperatureKelvin, absPressureHpa, diffPressureHpa);
70  EXPECT_NEAR(diffPressureHpa, expectedDiffPressureHpa, 0.01);
71 }
72 
73 
74 int main(int argc, char *argv[]){
75  testing::InitGoogleTest(&argc, argv);
76  ros::init(argc, argv, "isa_model_test");
77  return RUN_ALL_TESTS();
78 }
int main(int argc, char *argv[])
void EstimateAtmosphere(const Eigen::Vector3d &gpsPosition, const Eigen::Vector3d &linVelNed, float &temperatureKelvin, float &absPressureHpa, float &diffPressureHpa)
ROSCPP_DECL void init(int &argc, char **argv, const std::string &name, uint32_t options=0)
TEST(IsaModel, diffPressureHpaMax)


inno_vtol_dynamics
Author(s): Roman Fedorenko, Dmitry Ponomarev, Ezra Tal, Winter Guerra
autogenerated on Sat Jul 1 2023 02:13:44