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

Introducing model descriptions and instances #242

Open
wants to merge 61 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
ce017cb
Scenarios V2
reuben-thomas Jun 27, 2024
f00141d
Use groups
reuben-thomas Jul 1, 2024
6167ec1
Add scale and static to instances
reuben-thomas Jul 1, 2024
03cace2
fix description names
reuben-thomas Jul 2, 2024
0010b9f
Added convert function for model instance
reuben-thomas Jul 2, 2024
243b2b4
Merge remote-tracking branch 'upstream/main' into scenarios
reuben-thomas Jul 2, 2024
8386209
add from group list
reuben-thomas Jul 8, 2024
9f30004
redefine description, instances, scenarios
reuben-thomas Jul 10, 2024
1215fa9
scenario panel prototype
reuben-thomas Jul 11, 2024
1c25265
senario menu
reuben-thomas Jul 12, 2024
7adb5c6
improve scenario selector ui
reuben-thomas Jul 16, 2024
ce9f345
functional scenario switching
reuben-thomas Jul 17, 2024
97f8dbf
additions
reuben-thomas Jul 17, 2024
537ff76
Description inspector prototype
reuben-thomas Jul 18, 2024
b3f232d
organize instance and group properties
reuben-thomas Jul 19, 2024
c284a64
model description inspector plugin
reuben-thomas Jul 23, 2024
8cf25e7
Add differential drive
reuben-thomas Jul 23, 2024
9c96e32
deletions
reuben-thomas Jul 24, 2024
f6124a2
remove task view
reuben-thomas Jul 24, 2024
e84dc58
edit scenarios
reuben-thomas Jul 25, 2024
6d0a7e8
fix description deletions, instances without parent
reuben-thomas Jul 25, 2024
63fb8b9
scenarios: fix undos, allow for different instance types
reuben-thomas Jul 26, 2024
443a3fe
fix misplaced cfg(feature)
reuben-thomas Jul 26, 2024
ecb9bb7
fix base tasks
reuben-thomas Jul 27, 2024
5a8ef05
fix styling
reuben-thomas Jul 27, 2024
c896ea8
move all scenario viewer from mapf
reuben-thomas Jul 29, 2024
f7a24be
fixes, address comment
reuben-thomas Jul 31, 2024
69ea1df
Add instances to creation
reuben-thomas Jul 31, 2024
9963a8f
model selection
reuben-thomas Jul 31, 2024
a944432
add collision radius
reuben-thomas Jul 31, 2024
94ccc5c
allow ignore for occupancy calculation
reuben-thomas Jul 31, 2024
4b413a2
delete scenarios
reuben-thomas Aug 1, 2024
d95be3b
add saving
reuben-thomas Aug 2, 2024
42f25c2
Merge branch 'main' into scenarios
xiyuoh Oct 10, 2024
4729bef
Reduce unnecessary diff
xiyuoh Oct 11, 2024
afddc82
Remove description entity from model instances supported highlighting…
xiyuoh Oct 14, 2024
bb13ee0
Cleanup creation with place_object()
xiyuoh Oct 17, 2024
8ffcfe6
Limit model instance creation to spawn with existing model descriptio…
xiyuoh Oct 17, 2024
1d8aa7d
Avoid duplicate variable names
xiyuoh Oct 29, 2024
af5a2d5
Simplify printouts
xiyuoh Oct 29, 2024
c6eebf4
Remove unnecessary Without in deletion and minor corrections in scenario
xiyuoh Oct 29, 2024
e2b365c
Switch model instances to spawn 2d
xiyuoh Oct 30, 2024
f0fa12c
Clarify wait for units (assuming seconds)
xiyuoh Oct 30, 2024
ad5ba6e
Align delete scenario button
xiyuoh Oct 30, 2024
d331a79
Cleanup
xiyuoh Nov 4, 2024
5786bae
Do not display scenarios that do not belong to this site
xiyuoh Nov 4, 2024
7b01c91
Remove unnecessary diffs/code and duplicate variable names
xiyuoh Nov 12, 2024
d450cd7
Spawning model descriptions via fuel
xiyuoh Nov 13, 2024
83f3d85
Style
xiyuoh Nov 13, 2024
de9b60e
Tidy up inspect differential drive
xiyuoh Nov 14, 2024
90a60ba
Display Description for instance entities only instead of not-descrip…
xiyuoh Nov 14, 2024
acb39b9
Modify Task implementation
xiyuoh Nov 14, 2024
1c2cdcf
Merge branch 'main' into xiyu/scenarios
xiyuoh Nov 15, 2024
057e186
Use deletion filter for instance removal
xiyuoh Nov 15, 2024
94b54a9
Fix style - macro not derived for WaitFor task
xiyuoh Nov 15, 2024
6ad0ea7
Trigger model instance visibility update when creating new levels
xiyuoh Nov 15, 2024
8c19eed
Remove unnecessary Eq
xiyuoh Nov 15, 2024
5aed94f
Search for ignore parent entities when calculating grid
xiyuoh Dec 10, 2024
3a6ad1d
Remove unused imports
xiyuoh Dec 10, 2024
cc29375
Update wasm-bindgen dependency
xiyuoh Dec 11, 2024
01fca32
Consistent capitalization
xiyuoh Dec 11, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 46 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rmf_site_editor/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ tera = "1.19.1"
ehttp = { version = "0.4", features = ["native-async"] }
nalgebra = "0.32.5"
anyhow = "*"
strum = "*"

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
clap = { version = "4.0.10", features = ["color", "derive", "help", "usage", "suggestions"] }
Expand Down
8 changes: 6 additions & 2 deletions rmf_site_editor/src/interaction/cursor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ use crate::{
use bevy::{ecs::system::SystemParam, prelude::*, window::PrimaryWindow};
use bevy_mod_raycast::primitives::{rays::Ray3d, Primitive3d};

use rmf_site_format::{FloorMarker, Model, WallMarker, WorkcellModel};
use rmf_site_format::{FloorMarker, ModelInstance, WallMarker, WorkcellModel};
use std::collections::HashSet;

/// A resource that keeps track of the unique entities that play a role in
Expand Down Expand Up @@ -125,7 +125,11 @@ impl Cursor {
}

// TODO(luca) reduce duplication here
pub fn set_model_preview(&mut self, commands: &mut Commands, model: Option<Model>) {
pub fn set_model_instance_preview(
&mut self,
commands: &mut Commands,
model: Option<ModelInstance<Entity>>,
) {
self.remove_preview(commands);
self.preview_model = if let Some(model) = model {
let e = commands.spawn(model).insert(Pending).id();
Expand Down
4 changes: 4 additions & 0 deletions rmf_site_editor/src/interaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ pub use lift::*;
pub mod light;
pub use light::*;

pub mod model;
pub use model::*;

pub mod model_preview;
pub use model_preview::*;

Expand Down Expand Up @@ -197,6 +200,7 @@ impl Plugin for InteractionPlugin {
.add_systems(
Update,
(
update_model_instance_visual_cues.after(SelectionServiceStages::Select),
update_lane_visual_cues.after(SelectionServiceStages::Select),
update_edge_visual_cues.after(SelectionServiceStages::Select),
update_point_visual_cues.after(SelectionServiceStages::Select),
Expand Down
98 changes: 98 additions & 0 deletions rmf_site_editor/src/interaction/model.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright (C) 2024 Open Source Robotics Foundation
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

use crate::{interaction::*, site::*};
use bevy::prelude::*;

pub fn update_model_instance_visual_cues(
model_descriptions: Query<
(Entity, &Selected, &Hovered),
(
With<ModelMarker>,
With<Group>,
Or<(Changed<Hovered>, Changed<Selected>)>,
),
>,
mut model_instances: Query<
(
Entity,
&mut Selected,
&mut Hovered,
&mut Affiliation<Entity>,
Option<Ref<Tasks<Entity>>>,
),
(With<ModelMarker>, Without<Group>),
>,
mut locations: Query<&mut Selected, (With<LocationTags>, Without<ModelMarker>)>,
mut removed_components: RemovedComponents<Tasks<Entity>>,
) {
for (instance_entity, mut instance_selected, mut instance_hovered, affiliation, tasks) in
&mut model_instances
{
let mut is_description_selected = false;
if let Some(description_entity) = affiliation.0 {
if let Ok((_, description_selected, description_hovered)) =
model_descriptions.get(description_entity)
{
if description_selected.cue() {
instance_selected
.support_selected
.insert(description_entity);
is_description_selected = true;
} else {
instance_selected
.support_selected
.remove(&description_entity);
}
if description_hovered.cue() {
instance_hovered.support_hovering.insert(description_entity);
} else {
instance_hovered
.support_hovering
.remove(&description_entity);
}
}
}

// When an instance is selected, select all locations supporting it
if let Some(tasks) = tasks {
// When tasks for an instance have changed, reset all locations from supporting this instance
if tasks.is_changed() {
for mut location_selected in locations.iter_mut() {
location_selected.support_selected.remove(&instance_entity);
}
}

if let Some(task_location) = tasks.0.first().and_then(|t| t.location()) {
if let Ok(mut location_selected) = locations.get_mut(task_location.0) {
if instance_selected.cue() && !is_description_selected {
location_selected.support_selected.insert(instance_entity);
} else {
location_selected.support_selected.remove(&instance_entity);
}
}
}
}
}

// When instances are removed, prevent any location from supporting them
for removed in removed_components.read() {
for mut location_selected in locations.iter_mut() {
location_selected.support_selected.remove(&removed);
}
}
}
4 changes: 2 additions & 2 deletions rmf_site_editor/src/interaction/select/place_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

use crate::{interaction::select::*, site::Model};
use crate::{interaction::select::*, site::ModelInstance};
use bevy::ecs::system::SystemParam;

#[derive(Default)]
Expand Down Expand Up @@ -62,7 +62,7 @@ pub struct ObjectPlacement<'w, 's> {
}

impl<'w, 's> ObjectPlacement<'w, 's> {
pub fn place_object_2d(&mut self, object: Model, level: Entity) {
pub fn place_object_2d(&mut self, object: ModelInstance<Entity>, level: Entity) {
let state = self
.commands
.spawn(SelectorInput(PlaceObject2d { object, level }))
Expand Down
6 changes: 3 additions & 3 deletions rmf_site_editor/src/interaction/select/place_object_2d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
*/

use crate::{interaction::select::*, site::Model};
use crate::{interaction::select::*, site::ModelInstance};
use bevy::prelude::Input as UserInput;

pub const PLACE_OBJECT_2D_MODE_LABEL: &'static str = "place_object_2d";
Expand Down Expand Up @@ -101,7 +101,7 @@ pub fn build_place_object_2d_workflow(
}

pub struct PlaceObject2d {
pub object: Model,
pub object: ModelInstance<Entity>,
pub level: Entity,
}

Expand All @@ -117,7 +117,7 @@ pub fn place_object_2d_setup(
let mut access = access.get_mut(&key).or_broken_buffer()?;
let state = access.newest_mut().or_broken_buffer()?;

cursor.set_model_preview(&mut commands, Some(state.object.clone()));
cursor.set_model_instance_preview(&mut commands, Some(state.object.clone()));
set_visibility(cursor.dagger, &mut visibility, false);
set_visibility(cursor.halo, &mut visibility, false);

Expand Down
12 changes: 6 additions & 6 deletions rmf_site_editor/src/interaction/select/place_object_3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
use crate::{
interaction::select::*,
site::{
Anchor, AnchorBundle, Dependents, FrameMarker, Model, NameInSite, NameInWorkcell, Pending,
SiteID, WorkcellModel,
Anchor, AnchorBundle, Dependents, FrameMarker, ModelInstance, NameInSite, NameInWorkcell,
Pending, SiteID, WorkcellModel,
},
widgets::canvas_tooltips::CanvasTooltips,
};
Expand Down Expand Up @@ -148,7 +148,7 @@ pub struct PlaceObject3d {

#[derive(Clone, Debug)]
pub enum PlaceableObject {
Model(Model),
ModelInstance(ModelInstance<Entity>),
Anchor,
VisualMesh(WorkcellModel),
CollisionMesh(WorkcellModel),
Expand All @@ -174,9 +174,9 @@ pub fn place_object_3d_setup(
set_visibility(cursor.dagger, &mut visibility, true);
set_visibility(cursor.halo, &mut visibility, true);
}
PlaceableObject::Model(m) => {
PlaceableObject::ModelInstance(m) => {
// Spawn the model as a child of the cursor
cursor.set_model_preview(&mut commands, Some(m.clone()));
cursor.set_model_instance_preview(&mut commands, Some(m.clone()));
set_visibility(cursor.dagger, &mut visibility, false);
set_visibility(cursor.halo, &mut visibility, false);
}
Expand Down Expand Up @@ -466,7 +466,7 @@ pub fn on_placement_chosen_3d(
NameInWorkcell("Unnamed".to_string()),
))
.id(),
PlaceableObject::Model(object) => {
PlaceableObject::ModelInstance(object) => {
let model_id = commands.spawn((object, VisualCue::outline())).id();
// Create a parent anchor to contain the new model in
commands
Expand Down
Loading
Loading