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

Adds a setting for default lane size #135

Closed
wants to merge 5 commits into from

Conversation

arjo129
Copy link
Member

@arjo129 arjo129 commented May 26, 2023

This PR adds a setting for default lane size. It can be found by going to Edit -> Preferences.... We need to find a way to persist this. Note this setting does not change per-lane widths as those should be handled differently.

This PR adds a setting for default lane size. It can be found by going
to `Edit -> Preferences...`. We need to find a way to persist this. Note
this setting does not change per-lane widths as those should be handled
differently.

Signed-off-by: Arjo Chakravarty <[email protected]>
Moves preferences to `rmf_site_format` crate. This is necessary for
saving items. `File > Open` does not work correctly for some reason.

Signed-off-by: Arjo Chakravarty <[email protected]>
Signed-off-by: Arjo Chakravarty <[email protected]>
Signed-off-by: Arjo Chakravarty <[email protected]>
Signed-off-by: Arjo Chakravarty <[email protected]>
@arjo129 arjo129 marked this pull request as ready for review May 30, 2023 07:46
Copy link
Member

@luca-della-vedova luca-della-vedova left a comment

Choose a reason for hiding this comment

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

A good start on the feature, not sure whether it's ok for the long term but probed a bit around the implementation and found a few issues that should be addressed if we want to get this in.

It seems that when the default lane width is set and a new lane is created a fair bit of glitches appear, as in the video below:

Screencast.from.2023-06-06.15-23-32.webm

Specifically the beginning and end of each lane go back to the original width. Measurements are also scaled

Comment on lines +97 to +103
// TODO(arjo): Refactor so no panics
let preferences = site_properties
.get_single()
.unwrap_or(&Default::default())
.preferences
.unwrap_or_default();

Copy link
Member

Choose a reason for hiding this comment

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

This won't really work when there are multiple sites opened, a better approach would be to look at the CurrentWorkspace resource which points the Entity of the current site and get the SiteProperties component of that entity.

To break it just open a project, then Ctrl-O to open a new project, this feature will then not work anymore

Comment on lines +268 to +272
let preferences = site_properties
.get_single()
.unwrap_or(&Default::default())
.preferences
.unwrap_or_default();
Copy link
Member

Choose a reason for hiding this comment

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

Same as the other case of single query for site properties (a lot of these throughout the code, will not point out all the other ones)

Comment on lines +40 to +43
if props.preferences.is_none() {
props.preferences = Some(Default::default());
println!("Setting default value");
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about the approach of setting the Option to Some(Default::default()) as soon as it's detected to be None, it feels like it kinda defeats the purpose of it being an option in the first place and we could just have a Default implementation with the current default lane width for preferences?

ui.horizontal(|ui| {
ui.label("Default Lane Width: ");
let lane_width_entry = DragValue::new(&mut preferences.default_lane_width)
.clamp_range(0.0..=10000.0);
Copy link
Member

Choose a reason for hiding this comment

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

0.0 is a bit of a risky lower bound that would make it completely invisible, I'd suggest making it something that is not completely invisible but still covers the lowest common case (maybe 0.1 m?)

@@ -7,6 +7,7 @@ use crate::{
Navigation, OrientationConstraint, PixelsPerMeter, Pose, RankingsInLevel, ReverseLane,
Rotation, Site, SiteProperties, DEFAULT_NAV_GRAPH_COLORS,
};
use bevy::prelude::default;
Copy link
Member

Choose a reason for hiding this comment

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

This is unnecessary, you can just use Default::default() below, also every bevy specific instruction in the rmf_site_format crate should be behind a bevy feature flag, we are trying to keep the basic serialization / deserialization bevy independent so third party crates can use the format without pulling in such a large dependency

@arjo129
Copy link
Member Author

arjo129 commented Jun 7, 2023

Will fix these however in another conversation with @mxgrey he mentioned the following crate: https://github.com/ForesightMiningSoftwareCorporation/bevy_polyline

This removes the need for this feature. Will probably use this instead.

@arjo129
Copy link
Member Author

arjo129 commented Jul 18, 2023

Closing in favor of #152

@arjo129 arjo129 closed this Jul 18, 2023
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.

When working with large worlds (Kilometer Scale) default hard coded anchor and lane sizes don't work well
2 participants