Code Monkey home page Code Monkey logo

Comments (6)

kopp avatar kopp commented on June 30, 2024

@mantkiew you seem to have provided the Geocentric code, do you have a good idea?

from lanelet2.

kopp avatar kopp commented on June 30, 2024

Or to make the code more consistent: For ECEF we do know the origin: It's the center of the earth. So how about for GeocentricProjector we set the origin to GpsPoint{.lat = 90, .lon = 0, .ele = -6356752.3}, i.e. the center of the earth?

from lanelet2.

mantkiew avatar mantkiew commented on June 30, 2024

Hi, the tutorial shows using loadRobust, which does not take any origin, just the projector. https://github.com/fzi-forschungszentrum-informatik/Lanelet2/blob/33e797a5f4c3ac4cf4f63316fcd6965c9cf0cf57/lanelet2_examples/scripts/tutorial.py#L192C35-L192C35

I think it's the same with load, not sure why it would complain about not providing the origin.

There's the old API, where you can give just an origin and it creates some bad default projector, but that should not be used. Always create the projector you want and use that consistently.

from lanelet2.

kopp avatar kopp commented on June 30, 2024

Hi @mantkiew , thanks for the reply. I tried that but failed, see below.

I think just passing a projector does make sense -- and the projectors which need an origin actually 'carry their own' origin with them (they get constructed from it). The load API allows to pass only a projector, if that has the origin set. If not, we get the error I was reporting. My feeling is, that in the ECEF case we either should provide an origin (e.g. center of the earth) to satisfy this check or disable this check for projectors which do not need an origin.

For full reproducibility, here my console log:

% pip install lanelet2
Collecting lanelet2
...
Successfully installed lanelet2-1.2.1


% wget https://github.com/fzi-forschungszentrum-informatik/Lanelet2/raw/master/lanelet2_maps/res/mapping_example.osm
....
2023-12-05 16:53:22 (1.27 MB/s) - ‘mapping_example.osm’ saved [594826/594826]


% python
Python 3.8.10 (default, Nov 22 2023, 10:22:35) 
[GCC 9.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lanelet2
>>> ecef_projector = lanelet2.projection.GeocentricProjector()
>>> m = lanelet2.io.loadRobust("mapping_example.osm", ecef_projector)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
RuntimeError: You must pass an origin when loading a map with georeferenced (lat/lon) data!

So looking at the code I think load and loadRobust do the same thing, while one throws and the other prints.

from lanelet2.

mantkiew avatar mantkiew commented on June 30, 2024

This is the culprit (handleDefaultProjector throws the exception) :

const Projector& projector() const {
if (projector_->origin().isDefault) {
handleDefaultProjector();
}
return *projector_;
}

The GeocentricProjector does not use origin at all, because it's hardcoded in the underlying LibGeographic C++ library, and so it only has the default one defined in the class Projector:

explicit Projector(Origin origin = Origin::defaultOrigin()) : origin_{origin} {}

So, to fix this: the GeocentricProjector should overwrite the origin with whatever value that is different from the default projector.

from lanelet2.

mantkiew avatar mantkiew commented on June 30, 2024

@poggenhans @immel-f this PR fixes this error. It also adds usage demonstration to tutorial.py.

from lanelet2.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.