open-rmf / rmf_site

Experimental visualizer for dense buildings in RMF
32 stars 13 forks source link

Fix level alignment when levels have no measurements #212

Closed luca-della-vedova closed 5 months ago

luca-della-vedova commented 5 months ago

Bug fix

Fixed bug

Legacy traffic editor allows having levels with no measurements, it actually only uses measurements for the reference level and uses fiducials instead to compute the transform between other levels and the reference. The code path would do a divide by 0 if there was a level with no measurements and result in a NaN alignment / silent failure in importing the project.

Fix applied

This PR makes sure we don't divide by 0 and initializes the scale to the same "sensible" default that is used in traffic editor (5 cm per pixel).

To test it, try to run the site editor and import https://github.com/open-rmf/roscon_workshop/blob/main/roscon_maps/maps/workshop/workshop.building.yaml before and after this PR. The first will panic (panic is actually caused by an external library when we pass it NaN values, not the site editor), with the PR it should load correctly.

I checked and the map seems to be imported with the same scale as traffic editor after the fix.