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

Map View and GeoPoints archetype #6561

Merged
merged 47 commits into from
Oct 26, 2024
Merged

Conversation

tfoldi
Copy link
Contributor

@tfoldi tfoldi commented Jun 13, 2024

What

Map Space View for GNSS/GPS data logged through new GPS Coordinates archetype.

rerun_mapview.mp4
  • Added a new re_space_view_map crate for visualizing Points3D with gps coordinates.
    • map_visualizer_system.rs implements the VisualizerSystem trait. It has only one meaningful function, that takes the Positions3D components and turns into vec<MapEntry> array along with optional Color and Radius components. This vec<MapEntry> is the only field of the MapVisualizerSystem.
    • map_space_view.rs is where the magic happens. It uses walkers slippy map implementation to show an OpenStreetMap or Mapbox map. On the selection_ui you can change the map providers. To view Mapbox maps, you need to set mapbox tokens (you can get free tokens from Mapbox's site) and pass it via the env variable (MAPBOX_ACCESS_TOKEN) or via the blueprint
    • map_windows.rs is a small helper to show the zoom controls and acknowledgment on the UIs.
  • For blueprints I made MapProvider component (enum with providers+styles), and a MapOptions archetype.

The logging of data is performed as follows:

//! Log some GPS coordinates

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let rec = rerun::RecordingStreamBuilder::new("rerun_example_gps_coordinates").spawn()?;

    rec.log(
        "points",
        &rerun::Points3D::new([(47.6344, 19.1397, 0.0), (47.6344, 19.1399, 1.0)]),
    )?;

    Ok(())
}

The blueprint is defined as follows:

"""Use a blueprint to show a map."""

import rerun as rr
import rerun.blueprint as rrb

rr.init("rerun_example_gps_coordinates", spawn=True)

rr.log("points", Points3D([[47.6344, 19.1397, 0], [47.6334, 19.1399, 1]]))

# Create a map view to display the chart.
blueprint = rrb.Blueprint(
    rrb.MapView(
        origin="points",
        name="MapView",
        map_options=rrb.archetypes.MapOptions(provider=rrb.components.MapProvider.MapboxStreets),
    ),
    collapse_panels=True,
)

rr.send_blueprint(blueprint)

The PR is not perfect, but the view is usable.

Please review the changes and evaluate their potential utility for your needs. If you don't like, prefer not to merge just close it - no hard feelings.

To be discussed

  • Check with you guys to see if the name is right at all. Maybe instead of GPS we can go with something better
  • Position3D is limited to f32 instead of f64. This makes it less precise than /NavSatFix

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested the web demo (if applicable):
    • Using my own lame demo app which is not part of the PR.
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG

To run all checks from main, comment on the PR with @rerun-bot full-check.

@tfoldi tfoldi marked this pull request as draft June 13, 2024 15:08
@tfoldi tfoldi marked this pull request as ready for review June 17, 2024 20:50
@tfoldi tfoldi mentioned this pull request Jun 17, 2024
@k-bx
Copy link

k-bx commented Jun 18, 2024

Awesome work! Sorry if it's a noob question, but how do I check this out?

ubuntu@localhost:~/workspace/rerun-tfoldi$ pixi run rerun-web-release
 Pixi task (rerun-build-web-release in default): rustup target add wasm32-unknown-unknown && cargo run -p re_dev_tools -- build-web-viewer --release -g
info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date
    Finished dev [optimized + debuginfo] target(s) in 0.10s
     Running `target/debug/re_dev_tools build-web-viewer --release -g`
Building web viewer…

Compiling Rust to wasm in /home/ubuntu/workspace/rerun-tfoldi/target_wasm…
/home/ubuntu/workspace/rerun-tfoldi> CARGO_ENCODED_RUSTFLAGS="--cfg=web_sys_unstable_apis" RUSTFLAGS="--cfg=web_sys_unstable_apis" "cargo" "build" "--quiet" "--package" "re_viewer" "--lib" "--target" "wasm32-unknown-unknown" "--target-dir" "/home/ubuntu/workspace/rerun-tfoldi/target_wasm" "--no-default-features" "--features=analytics" "--release"
error: package `bitstream-io v2.4.2` cannot be built because it requires rustc 1.79 or newer, while the currently active rustc version is 1.76.0
Either upgrade to rustc 1.79 or newer, or use
cargo update [email protected] --precise ver
where `ver` is the latest version of `bitstream-io` supporting rustc 1.76.0
Error: Failed to build Wasm

@tfoldi
Copy link
Contributor Author

tfoldi commented Jun 18, 2024

Either upgrade to rustc 1.79 or newer, or use
cargo update [email protected] --precise ver
where ver is the latest version of bitstream-io supporting rustc 1.76.0
Error: Failed to build Wasm

New rerun needs rust version 1.79 while you have only 1.76. Update your rust toolchain and try it again.

@k-bx
Copy link

k-bx commented Jun 18, 2024

Ah, needed to update the rust-toolchain file. All good, compiled fine!

@Wumpf Wumpf requested a review from jleibs June 18, 2024 11:50
@tfoldi
Copy link
Contributor Author

tfoldi commented Jun 19, 2024

Few changes we discussed:

  • Remove GpsCoordinate archetype
  • Add ViewCoordinates.LAT_LON_ALT enum value to indicate that a Position3D represents lat/lon/alt values
  • Use ViewCoordinates in view heuristics to select the right heuristics for view
  • due to walkers' reqwest dependency it should be an optional feature

@jleibs
Copy link
Member

jleibs commented Jun 19, 2024

* Add `ViewCoordinates.LAT_LON_ALT` enum value to indicate that a `Position3D` represents lat/lon/alt values 
* Use `ViewCoordinates` in view heuristics to select the right heuristics for view

I talked this one over with some folks and the desire is to keep ViewCoordinates separate and somewhat dedicated to interpretation of camera-orientation, as distinct from data semantics.

I'm going to put together a proposal for a new archetype, probably named something like CRS (CoordinateReferenceSystem). We can start with this somewhat dedicated to the mapping use-cases, but I think it could be helpful for other things like CAD import where it might be useful to carry context like unit-sizes.

@jleibs
Copy link
Member

jleibs commented Jun 19, 2024

Here's my proposal for adding a very simple CRS type as an indicator: #6601

@tfoldi
Copy link
Contributor Author

tfoldi commented Jun 21, 2024

The new image crate depends on a newer version of Rust by default unless you disable it by setting default-features = false. Since walkers enables default features, this is causing the Rust build to fail on CI. I will look into how this can be addressed in the original repository.

The current cargo tree:

    ├── re_data_source v0.17.0-alpha.4 (/Users/.../rerun/crates/re_data_source)
    │   ├── re_data_loader v0.17.0-alpha.4 (/Users/.../rerun/crates/re_data_loader)
    │   │   ├── image v0.25.1
    │   │   │   ├── ravif v0.11.5
    │   │   │   │   ├── rav1e v0.7.1
    │   │   │   │   │   ├── bitstream-io v2.4.2  <--- this requires 1.79

In image's Cargo.toml:

ravif = { version = "0.11.2", default-features = false, optional = true }

@tfoldi
Copy link
Contributor Author

tfoldi commented Jun 22, 2024

  • Removed GpsCoordinates in favor of pure Points3D.
  • Removed default features from image in walkers repo so now the code works with older rustc.
  • Formatted/linted/removed all gps position related stuff
  • Added ZoomLevel and Secret components for the map options archetype
    • Secret component displayed as password field in selection_ui

What is left from what we discussed:

  1. add feature flags to make the map view optional

For 1, I'm open to your suggestions. Should the feature be enabled or disabled by default? Either way, how should the CI/CD integration work? Should we test all features by default or test combinations of features?

@tfoldi tfoldi marked this pull request as ready for review June 24, 2024 11:45
@tfoldi tfoldi force-pushed the feat/mapbox-view branch 3 times, most recently from 1b5568f to 12d432d Compare June 28, 2024 14:37
@patrickelectric
Copy link

@tfoldi nice work! Excited to see it merged :)

@tfoldi
Copy link
Contributor Author

tfoldi commented Jun 30, 2024

Extended the nuScenes example with MapView to have at least one example using the new view:

nuscenes_mapview.mp4

@journaux
Copy link

journaux commented Aug 12, 2024

would this support plotting a scatter of points across the map (instead of a single point/track) ? from the PR seems yes a la rr.log("points", Points3D([[47.6344, 19.1397, 0], [47.6334, 19.1399, 1]])) however the visual confused me (centers on a single point)

@tfoldi
Copy link
Contributor Author

tfoldi commented Aug 12, 2024

would this support plotting a scatter of points across the map (instead of a single point/track) ? from the PR seems yes a la rr.log("points", Points3D([[47.6344, 19.1397, 0], [47.6334, 19.1399, 1]])) however the visual confused me (centers on a single point)

yes, it does support multiple points

@journaux
Copy link

journaux commented Aug 15, 2024

good to know ! curious if team/egui has evaluated integrating cesium

-> its rendering pipeline for large set of N points may be faster
-> it has 3d terrain capability

@k-bx
Copy link

k-bx commented Oct 3, 2024

Hey, still very keen to see this. What's the current blocker?

@samorr
Copy link

samorr commented Oct 14, 2024

The same from my side, will it be continued?
Is there any plan to make GPS coordinates using float64? With 32 bits it's very 'rough'

@tfoldi
Copy link
Contributor Author

tfoldi commented Oct 17, 2024

The same from my side, will it be continued?

I’m open to continuing this, but it's largely dependent on the Rerun team's priorities. As you may have seen from the PR history, I tried to keep it up-to-date for a few versions but eventually paused due to the complexity involved. There are many moving parts in Rerun, and with so much auto-generated code and changing internals, maintaining consistency across view-related PRs isn’t straightforward.

I received two key comments from @jleibs:

  1. Introduce new archetype for minimal CoordinateReferenceSystem (CRS) #6601: Suggestion to introduce a new CoordinateReferenceSystem type as type indicator. Personally, I’m not sure this is necessary on day one. We could potentially move forward by logging Position3D types and setting the view to Map in the blueprint.
  2. The walker egui component brings in the reqwest crate, so making it an optional feature might be a cleaner approach.

On June 22nd, I asked a few questions regarding these points, but since I didn’t receive any responses, so I paused further updates. That said, I’m happy to rebase the PR to the latest main branch if there’s a realistic chance it could be merged.

@abey79
Copy link
Member

abey79 commented Oct 18, 2024

@tfoldi First, thanks again for your contribution, and for putting up with our slow responses so far. With 0.19 out and the huge push on the dataframe and video fronts, we are now ready to focus on other areas—and this one is high up our list. Starting on Monday, I'll make it my priority to help you land this PR.

Would you be willing to rebase it to latest main? My plan would then be to dive in, give it a thorough review, and help (including hands-on) to land it sooner than later.

As for the "feature flag": yes we want one, that is disabled by default (at least initially). This will give us more confidence to land stuff before they are 100% polished. To be clear, by "feature flag", we don't necessarily mean a Cargo-style feature, but a global application setting which dynamically enable/disable the map view in the viewer. That's often how we signify to users that a particular view is "in beta". (For illustration, I recently removed the feature flag we had on the dataframe view in this PR).

Edit: users already have to explicitly opt-in by logging a new, specific GeoPoints archetype. So we do need another "experimental" option to check.

Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewing via request of @abey79

Walkers debug log is a bit spammy, we should add it to CRATES_AT_INFO_LEVEL since in the dev environment we default to debug log level otherwise

It's a bit unclear to me which components/archetype should be marked as experimental if any. Blueprint / control of the map is very different from 2D view and we likely want to iterate to get them closer. But given that that likely means iterating on both it's probably moot.

I generally looked over the actual mechanics of the view only briefly and rough form, docs and whatever else caught my interest ;-)

Overall pretty amazing piece of work. There's a tiny bit more polish / surprise-reduction I'd like to see even on this first version, see comments :)

@Wumpf Wumpf self-requested a review October 25, 2024 16:23
Copy link
Member

@Wumpf Wumpf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚢

@samorr
Copy link

samorr commented Oct 25, 2024

Hi, maybe this is a little bit premature, but I would very much like to use these functionalities soon. Do you have any estimates on when there's going to be an official release with these changes?

@abey79
Copy link
Member

abey79 commented Oct 25, 2024

Hi, maybe this is a little bit premature, but I would very much like to use these functionalities soon. Do you have any estimates on when there's going to be an official release with these changes?

We intend for that to happen relatively soon (couple of weeks ish), but no promises! There should however be at least a development build available sometime next week.

@abey79 abey79 changed the title Map Space View and GPS Coordinates archetype (Mapbox/OSM support) Map View and GeoPoints archetype Oct 26, 2024
@abey79 abey79 merged commit 3af2270 into rerun-io:main Oct 26, 2024
32 of 33 checks passed
@tfoldi tfoldi deleted the feat/mapbox-view branch October 26, 2024 11:38
@Wumpf
Copy link
Member

Wumpf commented Oct 27, 2024

@samorr the latest development build should have this already now! :)
https://github.com/rerun-io/rerun/releases/tag/prerelease

@samorr
Copy link

samorr commented Oct 27, 2024

@samorr the latest development build should have this already now! :)

https://github.com/rerun-io/rerun/releases/tag/prerelease

Thanks! I will use it already tomorrow! 😁

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request feat-map-view Everything related to the map view include in changelog ui concerns graphical user interface
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants