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 Space View and GPS Coordinates archetype (Mapbox/OSM support) #6561

Open
wants to merge 43 commits into
base: main
Choose a base branch
from

Conversation

tfoldi
Copy link

@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
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
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
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
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 2 times, most recently from a14d6ab to 1b5568f Compare June 25, 2024 14:49
@patrickelectric
Copy link

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

@tfoldi
Copy link
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants