Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge latest changes into alpha-dev #446

Closed
wants to merge 16 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
167 changes: 167 additions & 0 deletions data/scenes/dyn/dyn_geom_swap_scene_by_indices.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="UTF-8"?>
<document>
<scene id="dyn_geom_swap_scene" name="DynGeomSwapScene">


<!-- Ground plane -->
<!-- ************ -->
<part id="1">
<filter type="objloader">
<param type="string" key="filepath" value="data/sceneparts/basic/groundplane/groundplane.obj" />
</filter>
<filter type="scale">
<param type="double" key="scale" value="120" />
</filter>
<filter type="translate">
<param type="vec3" key="offset" value="50.0;0;0" />
</filter>
</part>




<!-- Small cube goes sphere for two repetitions then goes big cube -->
<!-- ************************************************************* -->
<part id="2">
<filter type="objloader">
<param type="string" key="filepath" value="data/sceneparts/toyblocks/cube.obj" />
</filter>
<filter type="rotate">
<param key="rotation" type="rotation">
<rot angle_deg="45" axis="z"/>
</param>
</filter>
<filter type="scale">
<param type="double" key="scale" value="0.75" />
</filter>
<filter type="translate">
<param type="vec3" key="offset" value="-40.0;-50.0;0" />
</filter>
<!-- Swap sphere by big cube -->
<swap swapIndices="[3]">
<filter type="objloader">
<param type="string" key="filepath" value="data/sceneparts/toyblocks/cube.obj" />
</filter>
<filter type="rotate">
<param key="rotation" type="rotation">
<rot angle_deg="45" axis="z"/>
</param>
</filter>
<filter type="scale">
<param type="double" key="scale" value="1.5" />
</filter>
<filter type="translate">
<param type="vec3" key="offset" value="-20.0;-60.0;0" />
</filter>
</swap>
<!-- Swap small cube by sphere -->
<swap swapIndices="[1, 2]">
<filter type="objloader">
<param type="string" key="filepath" value="data/sceneparts/toyblocks/sphere.obj" />
</filter>
<filter type="scale">
<param type="double" key="scale" value="1.25" />
</filter>
<filter type="translate">
<param type="vec3" key="offset" value="-30.0;-60.0;0" />
</filter>
</swap>
</part>




<!-- Sphere goes cube goes nothing -->
<!-- ***************************** -->
<part id="3">
<filter type="objloader">
<param type="string" key="filepath" value="data/sceneparts/toyblocks/sphere.obj" />
</filter>
<filter type="scale">
<param type="double" key="scale" value="1.25" />
</filter>
<filter type="translate">
<param type="vec3" key="offset" value="-10.0;-20.0;0" />
</filter>
<!-- Swap sphere by cube -->
<swap swapIndices="[1]">
<filter type="objloader">
<param type="string" key="filepath" value="data/sceneparts/toyblocks/cube.obj" />
</filter>
<filter type="scale">
<param type="double" key="scale" value="2.0" />
</filter>
<filter type="translate">
<param type="vec3" key="offset" value="-40.0;40.0;0" />
</filter>
</swap>
<!-- Swap cube by nothing -->
<swap swapIndices="[2]" force_null="true">
</swap>
</part>




<!-- Small cube goes mid goes big goes bigger -->
<!-- **************************************** -->
<part id="4">
<filter type="objloader">
<param type="string" key="filepath" value="data/sceneparts/toyblocks/cube.obj" />
</filter>
<filter type="rotate">
<param key="rotation" type="rotation">
<rot angle_deg="45" axis="z"/>
</param>
</filter>
<filter type="scale">
<param type="double" key="scale" value="0.75" />
</filter>
<filter type="translate">
<param type="vec3" key="offset" value="-20.0;10.0;0" />
</filter>
<!-- Swap big cube by bigger cube -->
<swap swapIndices="[3]">
<filter type="rotate">
<param key="rotation" type="rotation">
<rot angle_deg="45" axis="z"/>
</param>
</filter>
<filter type="scale">
<param type="double" key="scale" value="3.5" />
</filter>
<filter type="translate">
<param type="vec3" key="offset" value="-42.0;12.0;0.0" />
</filter>
</swap>
<!-- Swap small cube by mid cube -->
<swap swapIndices="[1]">
<filter type="rotate">
<param key="rotation" type="rotation">
<rot angle_deg="45" axis="z"/>
</param>
</filter>
<filter type="scale">
<param type="double" key="scale" value="2.0" />
</filter>
<filter type="translate">
<param type="vec3" key="offset" value="-22.0;12.0;0" />
</filter>
</swap>
<!-- Swap mid cube by big cube -->
<swap swapIndices="[2]">
<filter type="rotate">
<param key="rotation" type="rotation">
<rot angle_deg="45" axis="z"/>
</param>
</filter>
<filter type="scale">
<param type="double" key="scale" value="3.0" />
</filter>
<filter type="translate">
<param type="vec3" key="offset" value="-18.0;11.0;0.0" />
</filter>
</swap>
</part>
</scene>
</document>
14 changes: 7 additions & 7 deletions data/surveys/dyn/tls_tree1_dyn.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
<scannerSettings id="tls" active="true" pulseFreq_hz="600000" verticalResolution_deg="0.04" horizontalResolution_deg="0.04"/>
<survey name="tls_tree1_dyn" platform="data/platforms.xml#tripod" scanner="data/scanners_tls.xml#riegl_vz400" scene="data/scenes/dyn/tree1_dyn.xml#tree1">
<leg>
<platformSettings x="3.0000" y="0.0000" z="0" onGround="true"/>
<platformSettings x="3.0000" y="0.0000" z="0" onGround="false"/>
<scannerSettings template="tls" headRotateStart_deg="45.0000" headRotateStop_deg="135.0000" trajectoryTimeInterval_s="0.05"/>
</leg>
<leg>
<platformSettings x="1.5000" y="2.5981" z="0" onGround="true"/>
<platformSettings x="1.5000" y="2.5981" z="0" onGround="false"/>
<scannerSettings template="tls" headRotateStart_deg="105.0000" headRotateStop_deg="195.0000" trajectoryTimeInterval_s="0.05"/>
</leg>
<leg>
<platformSettings x="-1.5000" y="2.5981" z="0" onGround="true"/>
<platformSettings x="-1.5000" y="2.5981" z="0" onGround="false"/>
<scannerSettings template="tls" headRotateStart_deg="-195.0000" headRotateStop_deg="-105.0000" trajectoryTimeInterval_s="0.05"/>
</leg>
<leg>
<platformSettings x="-3.0000" y="0.0000" z="0" onGround="true"/>
<platformSettings x="-3.0000" y="0.0000" z="0" onGround="false"/>
<scannerSettings template="tls" headRotateStart_deg="-135.0000" headRotateStop_deg="-45.0000" trajectoryTimeInterval_s="0.05"/>
</leg>
<leg>
<platformSettings x="-1.5000" y="-2.5981" z="0" onGround="true"/>
<platformSettings x="-1.5000" y="-2.5981" z="0" onGround="false"/>
<scannerSettings template="tls" headRotateStart_deg="-75.0000" headRotateStop_deg="15.0000" trajectoryTimeInterval_s="0.05"/>
</leg>
<leg>
<platformSettings x="1.5000" y="-2.5981" z="0" onGround="true"/>
<platformSettings x="1.5000" y="-2.5981" z="0" onGround="false"/>
<scannerSettings template="tls" headRotateStart_deg="-15.0000" headRotateStop_deg="75.0000" trajectoryTimeInterval_s="0.05"/>
</leg>

</survey>
</document>


14 changes: 7 additions & 7 deletions data/surveys/dyn/tls_tree1_static.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,30 @@
<scannerSettings id="tls" active="true" pulseFreq_hz="600000" verticalResolution_deg="0.04" horizontalResolution_deg="0.04"/>
<survey name="tls_tree1_static" platform="data/platforms.xml#tripod" scanner="data/scanners_tls.xml#riegl_vz400" scene="data/scenes/dyn/tree1_static.xml#tree1">
<leg>
<platformSettings x="3.0000" y="0.0000" z="0" onGround="true"/>
<platformSettings x="3.0000" y="0.0000" z="0" onGround="false"/>
<scannerSettings template="tls" headRotateStart_deg="45.0000" headRotateStop_deg="135.0000" trajectoryTimeInterval_s="0.05"/>
</leg>
<leg>
<platformSettings x="1.5000" y="2.5981" z="0" onGround="true"/>
<platformSettings x="1.5000" y="2.5981" z="0" onGround="false"/>
<scannerSettings template="tls" headRotateStart_deg="105.0000" headRotateStop_deg="195.0000" trajectoryTimeInterval_s="0.05"/>
</leg>
<leg>
<platformSettings x="-1.5000" y="2.5981" z="0" onGround="true"/>
<platformSettings x="-1.5000" y="2.5981" z="0" onGround="false"/>
<scannerSettings template="tls" headRotateStart_deg="-195.0000" headRotateStop_deg="-105.0000" trajectoryTimeInterval_s="0.05"/>
</leg>
<leg>
<platformSettings x="-3.0000" y="0.0000" z="0" onGround="true"/>
<platformSettings x="-3.0000" y="0.0000" z="0" onGround="false"/>
<scannerSettings template="tls" headRotateStart_deg="-135.0000" headRotateStop_deg="-45.0000" trajectoryTimeInterval_s="0.05"/>
</leg>
<leg>
<platformSettings x="-1.5000" y="-2.5981" z="0" onGround="true"/>
<platformSettings x="-1.5000" y="-2.5981" z="0" onGround="false"/>
<scannerSettings template="tls" headRotateStart_deg="-75.0000" headRotateStop_deg="15.0000" trajectoryTimeInterval_s="0.05"/>
</leg>
<leg>
<platformSettings x="1.5000" y="-2.5981" z="0" onGround="true"/>
<platformSettings x="1.5000" y="-2.5981" z="0" onGround="false"/>
<scannerSettings template="tls" headRotateStart_deg="-15.0000" headRotateStop_deg="75.0000" trajectoryTimeInterval_s="0.05"/>
</leg>

</survey>
</document>


8 changes: 5 additions & 3 deletions pytests/test_demo_scenes.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def test_arbaro_tls_pyh():

def eval_arbaro_tls(dirname):
assert (dirname / 'leg000_points.las').exists()
assert abs((dirname / 'leg000_points.las').stat().st_size - 22_704_249) < MAX_DIFFERENCE_BYTES
assert abs((dirname / 'leg000_points.las').stat().st_size - 22_698_181) < MAX_DIFFERENCE_BYTES
assert (dirname / 'leg001_points.las').exists()
assert abs((dirname / 'leg001_points.las').stat().st_size - 14_381_469) < MAX_DIFFERENCE_BYTES
with open(dirname / 'leg000_trajectory.txt', 'r') as f:
Expand Down Expand Up @@ -296,7 +296,9 @@ def eval_quadcopter(dirname):
[-7.00000e+01, -2.87225e+01, 7.13900e-03],
[-7.00000e+01, -2.84326e+01, 8.83900e-03],
[-7.00000e+01, -2.81384e+01, 1.53900e-03]])
np.testing.assert_allclose(data[100:120, :], expected, atol=1e-12)
# atol for numpy assert moved to 1e-3 from 1e-12 due to discrepancies
# between local and remote (GitHub action) results
np.testing.assert_allclose(data[100:120, :], expected, atol=1e-3)
assert speed_from_traj(dirname / 'leg000_trajectory.txt') == pytest.approx(10.0, 0.001)
assert speed_from_traj(dirname / 'leg002_trajectory.txt') == pytest.approx(7.0, 0.001)
assert speed_from_traj(dirname / 'leg004_trajectory.txt') == pytest.approx(4.0, 0.001)
Expand Down Expand Up @@ -454,7 +456,7 @@ def test_dyn_exe():

def eval_dyn(dirname):
assert (dirname / 'leg000_points.laz').exists()
assert abs((dirname / 'leg000_points.laz').stat().st_size - 4_181_700) < MAX_DIFFERENCE_BYTES
assert abs((dirname / 'leg000_points.laz').stat().st_size - 4_174_789) < MAX_DIFFERENCE_BYTES
# clean up
if DELETE_FILES_AFTER:
shutil.rmtree(dirname)
4 changes: 2 additions & 2 deletions pytests/test_gpsStartTimeFlag.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ def test_gpsStartTimeFlag_exe():
r2_sum = sha256sum(r2 / 'leg000_points.xyz')
r3_sum = sha256sum(r3 / 'leg000_points.xyz')
assert r2_sum == r3_sum
assert r2_sum == '41313dfe46ed34fcb9733af03a4d5e52487fd4579014f13dc00c609b53813229' or \
assert r2_sum == 'b74ffe17e057020ce774df749f8425700a928a5148bb5e6a1f5aeb69f607ae04' or \
r2_sum == '984cfbbc5a54ab10a566ea901363218f35da569dbab5cd102424ab27794074ae' # linux checksum
assert r1_sum != r2_sum

Expand Down Expand Up @@ -94,7 +94,7 @@ def test_gpsStartTimeFlag_pyh():
r2_sum = sha256sum(r2 / 'leg000_points.xyz')
r3_sum = sha256sum(r3 / 'leg000_points.xyz')
assert r2_sum == r3_sum
assert r2_sum == '41313dfe46ed34fcb9733af03a4d5e52487fd4579014f13dc00c609b53813229' or \
assert r2_sum == 'b74ffe17e057020ce774df749f8425700a928a5148bb5e6a1f5aeb69f607ae04' or \
r2_sum == '984cfbbc5a54ab10a566ea901363218f35da569dbab5cd102424ab27794074ae' # linux checksum
assert r1_sum != r2_sum

Expand Down
2 changes: 1 addition & 1 deletion pytests/test_pyhelios.py
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ def test_output(export_to_file):
measurements_array, trajectory_array = pyhelios.outputToNumpy(output)

np.testing.assert_allclose(measurements_array[0, :3], np.array([474500.3, 5473580.0, 107.0001]), rtol=0.000001)
assert measurements_array.shape == (2412, 17)
assert measurements_array.shape == (2407, 17)
assert trajectory_array.shape == (9, 7)
if export_to_file:
assert Path(output.outpath).parent.parent == Path(WORKING_DIR) / "output" / "als_hd_demo"
Expand Down
6 changes: 6 additions & 0 deletions src/assetloading/SpectralLibrary.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,4 +79,10 @@ class SpectralLibrary {
* @param scene Scene with materials which reflectance must be setted
*/
void setReflectances(Scene* scene);

/**
* @brief Obtain the default reflectance of the spectral library.
* @see SpectralLibrary::defaultReflectance
*/
inline double getDefaultReflectance(){return defaultReflectance;}
};
3 changes: 2 additions & 1 deletion src/assetloading/SwapOnRepeatHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ SwapOnRepeatHandler::SwapOnRepeatHandler() :
discardOnReplay(false),
holistic(false),
onSwapFirstPlay(false),
keepCRS(true),
baseline(nullptr)
{}

Expand Down Expand Up @@ -58,7 +59,7 @@ void SwapOnRepeatHandler::doSwap(ScenePart &sp){
std::deque<AbstractGeometryFilter *> filters = swapFilters.front();
swapFilters.pop_front();
currentTimeToLive = timesToLive.front();
timesToLive.pop_front();
timesToLive.pop_front();

// Apply filters
bool firstIter = true;
Expand Down
18 changes: 18 additions & 0 deletions src/assetloading/SwapOnRepeatHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,11 @@ class SwapOnRepeatHandler {
* swap.
*/
bool onSwapFirstPlay;
/**
* @brief True if the handler requires to keep the current scene's CRS
* bounding box (default), False otherwise.
*/
bool keepCRS;

public:
/**
Expand Down Expand Up @@ -179,6 +184,19 @@ class SwapOnRepeatHandler {
* @see SwapOnRepeatHandler::mPrimitives
*/
std::vector<Primitive *> & getBaselinePrimitives();
/**
* @brief Set the keepCRS flag.
* @param keepCRS The new keepCRS flag for the handler.
* @see SwapOnRepeatHandler::keepCRS
*/
inline void setKeepCRS(bool const keepCRS) {this->keepCRS = keepCRS;}
/**
* @brief Check whether the current keepCRS flag.
* @return True if the handler requires to keep the current scene's CRS,
* False otherwise.
* @see SwapOnRepeatHandler::keepCRS
*/
inline bool isKeepCRS() const {return keepCRS;}

protected:
// *** UTIL METHODS *** //
Expand Down
9 changes: 8 additions & 1 deletion src/assetloading/XmlSceneLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,14 @@ shared_ptr<SwapOnRepeatHandler> XmlSceneLoader::loadScenePartSwaps(
"int",
1
));
bool const keepCRS = boost::get<bool>(XmlUtils::getAttribute(
swapNodes,
"keepCRS",
"bool",
sorh->isKeepCRS()
));
sorh->pushTimeToLive(swapStep);
sorh->setKeepCRS(keepCRS);
tinyxml2::XMLElement *filterNodes =
swapNodes->FirstChildElement("filter");
std::deque<AbstractGeometryFilter *> swapFilters;
Expand Down Expand Up @@ -577,7 +584,7 @@ void XmlSceneLoader::handleDynamicSceneAttributes(
))
);
// Apply automatic CRS translation when requested
glm::dvec3 const &shift = scene->getBBoxCRS()->getMin();
glm::dvec3 const &shift = scene->getBBoxCRS()->getCentroid();
size_t const numDynObjects = scene->numDynObjects();
for (size_t i = 0; i < numDynObjects; ++i) {
std::shared_ptr<DynSequentiableMovingObject> dsmo =
Expand Down
3 changes: 3 additions & 0 deletions src/assetloading/XmlSurveyLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ XmlSurveyLoader::createSurveyFromXml(
(float)survey->scanner->getWavelength(), assetsDir + "spectra");
spectralLibrary.readReflectances();
spectralLibrary.setReflectances(survey->scanner->platform->scene.get());
survey->scanner->platform->scene->setDefaultReflectance(
spectralLibrary.getDefaultReflectance()
);

// Update materials for all swap on repeat handlers
for(std::shared_ptr<ScenePart> sp : survey->scanner->platform->scene->parts){
Expand Down
Loading
Loading