Skip to content

Commit

Permalink
Merge pull request #447 from 3dgeo-heidelberg/resolution
Browse files Browse the repository at this point in the history
Bring latest dev changes to alpha-dev
  • Loading branch information
han16nah authored May 22, 2024
2 parents 6cc3373 + 26e3a67 commit e576163
Show file tree
Hide file tree
Showing 28 changed files with 596 additions and 62 deletions.
9 changes: 5 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,13 @@ jobs:
- name: Install Helios
run: |
python -m pip install -v .
env:
SETUPTOOLS_SCM_SUBPROCESS_TIMEOUT: "120"

- name: Run tests
# Disable MacOS for now - we do not yet officially support it and we need to invest a bit
# more efforts into investigating broken LAZ files written by Helios on MacOS.
if: runner.os != 'macOS'
# Disable MacOS for now - we do not yet officially support it and we need to invest a bit
# more efforts into investigating broken LAZ files written by Helios on MacOS.
# - macos-latest
run: |
python -m pytest -m exe
python -m pytest -m pyh
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 @@ -114,7 +114,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 @@ -290,7 +290,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 @@ -448,7 +450,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)
2 changes: 1 addition & 1 deletion pytests/test_pyhelios.py
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,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 @@ -84,4 +84,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 @@ -236,7 +236,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 @@ -578,7 +585,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

0 comments on commit e576163

Please sign in to comment.