Helios++
Helios software for LiDAR simulations
SurveyCopyTest.h
1 #pragma once
2 
3 #include "BaseTest.h"
4 #include <Survey.h>
5 #include <OscillatingMirrorBeamDeflector.h>
6 #include <HelicopterPlatform.h>
7 #include <FullWaveformPulseDetector.h>
8 #include <scanner/SingleScanner.h>
9 
10 namespace HeliosTests{
17 class SurveyCopyTest : public BaseTest{
18 public:
19  // *** CONSTRUCTOR *** //
20  // ********************* //
24  SurveyCopyTest() : BaseTest("Survey copy test"){}
25 
26  // *** R U N *** //
27  // *************** //
31  bool run() override;
32 };
33 
35  // Build base Survey
36  std::shared_ptr<Survey> survey = std::make_shared<Survey>();
37  survey->name = "MySurvey";
38  survey->numRuns = 1;
39  survey->simSpeedFactor = 1;
40  std::list<int> pulseFreqs;
41  pulseFreqs.push_back(100);
42  pulseFreqs.push_back(30);
43  pulseFreqs.push_back(70);
44  survey->scanner = std::make_shared<SingleScanner>(
45  0.1,
46  glm::dvec3(2.0, 3.0, 0.0),
47  Rotation(0.0, 0.0, 0.0, 0.0, true),
48  pulseFreqs,
49  4.0,
50  "MyScanner",
51  80.5,
52  3.0,
53  0.9,
54  0.7,
55  0.8,
56  100,
57  false,
58  false,
59  false,
60  true
61  );
62  survey->scanner->setScannerHead(std::make_shared<ScannerHead>(
63  glm::dvec3(0.4, 0.7, 0.1), 0.067
64  ));
65  survey->scanner->setBeamDeflector(
66  std::make_shared<OscillatingMirrorBeamDeflector>(
67  3.141592,
68  1400.5,
69  70.8,
70  1
71  ));
72  survey->scanner->platform = std::make_shared<HelicopterPlatform>();
73  survey->scanner->setDetector(std::make_shared<FullWaveformPulseDetector>(
74  survey->scanner,
75  1.5,
76  0.1
77  ));
78  survey->legs.push_back(std::make_shared<Leg>());
79  survey->legs[0]->mPlatformSettings = std::make_shared<PlatformSettings>();
80  survey->legs[0]->mPlatformSettings->onGround = false;
81  survey->scanner->platform->scene = std::make_shared<Scene>();
82  std::shared_ptr<Scene> baseScene = survey->scanner->platform->scene;
83  baseScene->primitives.push_back(new Triangle(
84  Vertex(), Vertex(), Vertex()
85  ));
86  baseScene->primitives[0]->part = std::make_shared<ScenePart>();
87  baseScene->primitives[0]->part->mPrimitives.push_back(
88  baseScene->primitives[0]);
89  baseScene->primitives[0]->part->onRayIntersectionMode = "TRANSMITTIVE";
90  baseScene->primitives.push_back(new DetailedVoxel(
91  glm::dvec3(0.0, 0.0, 0.5),
92  2.15,
93  std::vector<int>({1,2}),
94  std::vector<double>({0.1, 0.2, 0.3})
95  ));
96  baseScene->primitives[1]->material = std::make_shared<Material>();
97  baseScene->primitives[1]->material->ka[0] = 1.1;
98  baseScene->primitives[1]->material->ks[1] = 1.2;
99 
100  // Copy base Survey
101  std::shared_ptr<Survey> copy = std::make_shared<Survey>(*survey);
102 
103  // Do some changes on copy
104  copy->name = "CopiedSurvey";
105  copy->numRuns = 0;
106  copy->scanner->name = "CopiedScanner";
107  Rotation &copyMRA =
108  copy->scanner->getScannerHead()->getMountRelativeAttitudeByReference();
109  copyMRA.setQ3(copyMRA.getQ3() + 0.1);
110  copy->scanner->getBeamDeflector()->cfg_device_scanFreqMax_Hz += 1.0;
111  copy->scanner->platform->cfg_device_relativeMountPosition.x += 0.01;
112  HelicopterPlatform *hp =
113  ((HelicopterPlatform *)copy->scanner->platform.get());
114  glm::dvec3 & speedXy = hp->getSpeedXyByReference();
115  speedXy.x += 0.1;
116  Rotation & r = hp->getRotationByReference();
117  r.setQ2(r.getQ2()+0.1);
118  copy->scanner->getFWFSettings().minEchoWidth += 0.001;
119  copy->legs[0]->mPlatformSettings->onGround = true;
120  std::shared_ptr<Scene> copyScene = copy->scanner->platform->scene;
121  copyScene->primitives[0]->getVertices()[0].pos.x += 0.1;
122  copyScene->primitives[0]->part->onRayIntersectionArgument += 0.034;
123  copyScene->primitives[1]->material->ks[1] += 0.1;
124  DetailedVoxel *copyDv = (DetailedVoxel *) copyScene->primitives[1];
125  (*copyDv)[1] += 0.1;
126 
127  // Validate copy
128  if(copy->name == survey->name) return false;
129  if(copy->numRuns == survey->numRuns) return false;
130  if(copy->simSpeedFactor != survey->simSpeedFactor) return false;
131  if(copy->scanner->name == survey->scanner->name) return false;
132  if(copy->scanner->getNumTimeBins()!=survey->scanner->getNumTimeBins())
133  return false;
134  if(copy->scanner->isCalcEchowidth() != survey->scanner->isCalcEchowidth())
135  return false;
136  if(copy->scanner->getFWFSettings().minEchoWidth ==
137  survey->scanner->getFWFSettings().minEchoWidth)
138  return false;
139  if(copy->scanner->getFWFSettings().apertureDiameter !=
140  survey->scanner->getFWFSettings().apertureDiameter)
141  return false;
142  if(copy->scanner->getScannerHead()->getRotatePerSecMax() !=
143  survey->scanner->getScannerHead()->getRotatePerSecMax())
144  return false;
145  Rotation &baseMRA = survey->scanner->getScannerHead()
146  ->getMountRelativeAttitudeByReference();
147  if(copyMRA.getQ0()!=baseMRA.getQ0() || copyMRA.getQ3()==baseMRA.getQ3())
148  return false;
149  if(copy->scanner->getBeamDeflector()->cfg_device_scanFreqMin_Hz !=
150  survey->scanner->getBeamDeflector()->cfg_device_scanFreqMin_Hz)
151  return false;
152  if(copy->scanner->getBeamDeflector()->cfg_device_scanFreqMax_Hz ==
153  survey->scanner->getBeamDeflector()->cfg_device_scanFreqMax_Hz)
154  return false;
155  if(copy->scanner->platform->cfg_device_relativeMountPosition.x ==
156  survey->scanner->platform->cfg_device_relativeMountPosition.x)
157  return false;
158  if(copy->scanner->platform->cfg_device_relativeMountPosition.y !=
159  survey->scanner->platform->cfg_device_relativeMountPosition.y)
160  return false;
161  HelicopterPlatform *copyHp =
162  (HelicopterPlatform *) copy->scanner->platform.get();
163  HelicopterPlatform *baseHp =
164  (HelicopterPlatform *) survey->scanner->platform.get();
165  glm::dvec3 &copySpeedXy = copyHp->getSpeedXyByReference();
166  glm::dvec3 &baseSpeedXy = baseHp->getSpeedXyByReference();
167  if(copySpeedXy.x == baseSpeedXy.x) return false;
168  if(copySpeedXy.y != baseSpeedXy.y) return false;
169  Rotation &copyRot = copyHp->getRotationByReference();
170  Rotation &baseRot = baseHp->getRotationByReference();
171  if(copyRot.getQ1() != baseRot.getQ1()) return false;
172  if(copyRot.getQ2() == baseRot.getQ2()) return false;
173  if(copy->legs[0]->mPlatformSettings->onGround ==
174  survey->legs[0]->mPlatformSettings->onGround)
175  return false;
176  if(copy->legs[0]->mPlatformSettings->stopAndTurn !=
177  survey->legs[0]->mPlatformSettings->stopAndTurn)
178  return false;
179  if(copyScene->primitives[0]->getVertices()[0].pos.x ==
180  baseScene->primitives[0]->getVertices()[0].pos.x)
181  return false;
182  if(copyScene->primitives[0]->getVertices()[0].pos.y !=
183  baseScene->primitives[0]->getVertices()[0].pos.y)
184  return false;
185  if(copyScene->primitives[0]->part->onRayIntersectionArgument ==
186  baseScene->primitives[0]->part->onRayIntersectionArgument)
187  return false;
188  if(copyScene->primitives[0]->part->onRayIntersectionMode !=
189  baseScene->primitives[0]->part->onRayIntersectionMode)
190  return false;
191  if(copyScene->primitives[1]->material->ka[0] !=
192  baseScene->primitives[1]->material->ka[0])
193  return false;
194  if(copyScene->primitives[1]->material->ks[1] ==
195  baseScene->primitives[1]->material->ks[1])
196  return false;
197  DetailedVoxel *baseDv = (DetailedVoxel *) baseScene->primitives[1];
198  copyDv = (DetailedVoxel *) copyScene->primitives[1];
199  if((*baseDv)[0] != (*copyDv)[0]) return false;
200  if((*baseDv)[1] == (*copyDv)[1]) return false;
201 
202  return true;
203 }
204 
205 }
Class which extends Voxel to support AMAPVox format with extra features.
Definition: DetailedVoxel.h:15
Class representing a helicopter platform.
Definition: HelicopterPlatform.h:12
Rotation & getRotationByReference()
Obtain rotation assistance r by reference.
Definition: HelicopterPlatform.h:244
glm::dvec3 & getSpeedXyByReference()
Obtain xy speed vector by reference.
Definition: HelicopterPlatform.h:239
BaseTest class.
Definition: BaseTest.h:20
Test survey copy.
Definition: SurveyCopyTest.h:17
bool run() override
Definition: SurveyCopyTest.h:34
SurveyCopyTest()
Survey copy test constructor.
Definition: SurveyCopyTest.h:24
Definition: Rotation.h:80
double getQ2() const
Get the second coordinate of the vectorial part of the quaternion.
Definition: Rotation.h:130
double getQ1() const
Get the first coordinate of the vectorial part of the quaternion.
Definition: Rotation.h:122
double getQ3() const
Get the third coordinate of the vectorial part of the quaternion.
Definition: Rotation.h:137
double getQ0() const
Get the scalar coordinate of the quaternion.
Definition: Rotation.h:115
Class representing triangle primitive.
Definition: Triangle.h:13
Class representing a vertex.
Definition: Vertex.h:14