Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
84a4ed3
Move non-widget RobotProperty stuff out of widgets and fix wrong
xiyuoh Sep 5, 2025
62db8b5
Merge remote-tracking branch 'origin/main' into xiyu/fix_properties
xiyuoh Sep 5, 2025
3d451cf
Cleanup
xiyuoh Sep 5, 2025
e8f7bf2
Cleaner initialization
xiyuoh Sep 9, 2025
19e9e93
Better fix for overwriting
xiyuoh Sep 9, 2025
116d038
Make IsStatic optional
xiyuoh Sep 9, 2025
0359b9a
Add commands
xiyuoh Sep 9, 2025
37a8b7c
Make a bunch of systems -> observers
xiyuoh Oct 2, 2025
4e64c12
Merge branch 'main' into xiyu/fix_properties
xiyuoh Oct 3, 2025
98699d4
Revert making update_model_instances into observers
xiyuoh Oct 3, 2025
a08c036
Better support for multi-kind RobotProperty
xiyuoh Oct 3, 2025
916a471
Fix slotcar overwriting robot properties
xiyuoh Oct 3, 2025
840da45
Merge remote-tracking branch 'origin/main' into xiyu/fix_properties
xiyuoh Oct 3, 2025
de31bf4
Introduce EmptyRobotProperty
xiyuoh Oct 6, 2025
ac22d44
Move registration logic to site module
xiyuoh Oct 6, 2025
d59c399
Style
xiyuoh Oct 6, 2025
41d2a43
CI
xiyuoh Oct 6, 2025
15bff39
Fix unable to enable Amb/Mech System
xiyuoh Oct 8, 2025
9a1325d
Enable EmptyRobotProperty for Mobility and PowerSource
xiyuoh Oct 13, 2025
66bc2eb
Merge remote-tracking branch 'origin/main' into xiyu/fix_properties
xiyuoh Oct 13, 2025
6e54e79
Review comments
xiyuoh Oct 21, 2025
cea8006
Merge remote-tracking branch 'origin/main' into xiyu/fix_properties
xiyuoh Oct 21, 2025
e385f04
Merge branch 'main' into xiyu/fix_properties
xiyuoh Oct 23, 2025
e5089be
Merge branch 'main' into xiyu/fix_properties
xiyuoh Oct 24, 2025
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
20 changes: 19 additions & 1 deletion crates/rmf_site_editor/src/site/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,9 @@ pub use measurement::*;
pub mod model;
pub use model::*;

pub mod model_property;
pub use model_property::*;

pub mod modifier;
pub use modifier::*;

Expand Down Expand Up @@ -310,8 +313,23 @@ impl Plugin for SitePlugin {
PropertyPlugin::<OnLevel<Entity>, Robot>::default(),
SlotcarSdfPlugin,
MaterialPlugin::<ExtendedMaterial<StandardMaterial, LaneArrowMaterial>>::default(),
InfiniteGridPlugin,
))
.add_plugins((
RobotPropertiesPlugin::default(),
RobotPropertyPlugin::<Mobility, RecallMobility>::default(),
RobotPropertyPlugin::<Collision, RecallCollision>::default(),
RobotPropertyPlugin::<PowerDissipation, RecallPowerDissipation>::default(),
RobotPropertyPlugin::<PowerSource, RecallPowerSource>::default(),
EmptyRobotPropertyPlugin::<Mobility>::new(),
EmptyRobotPropertyPlugin::<Collision>::new(),
EmptyRobotPropertyPlugin::<PowerSource>::new(),
RobotPropertyKindPlugin::<DifferentialDrive, Mobility, RecallDifferentialDrive>::default(),
RobotPropertyKindPlugin::<CircleCollision, Collision, RecallCircleCollision>::default(),
RobotPropertyKindPlugin::<AmbientSystem, PowerDissipation, RecallAmbientSystem>::default(),
RobotPropertyKindPlugin::<MechanicalSystem, PowerDissipation, RecallMechanicalSystem>::default(),
RobotPropertyKindPlugin::<Battery, PowerSource, RecallBattery>::default(),
))
.add_plugins((InfiniteGridPlugin,))
.add_issue_type(&DUPLICATED_DOOR_NAME_ISSUE_UUID, "Duplicate door name")
.add_issue_type(&DUPLICATED_LIFT_NAME_ISSUE_UUID, "Duplicate lift name")
.add_issue_type(
Expand Down
92 changes: 92 additions & 0 deletions crates/rmf_site_editor/src/site/model_property.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright (C) 2025 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::site::{AssetSource, IsStatic, ModelProperty, Scale};
use bevy::{
ecs::{component::ComponentId, system::EntityCommands},
prelude::*,
};
use std::collections::HashMap;

/// Function that inserts a default property into an entity
pub type InsertModelPropertyFn = fn(EntityCommands);

pub fn get_insert_model_property_fn<T: Component + Default>() -> InsertModelPropertyFn {
|mut e_commands| {
e_commands.insert(T::default());
}
}

/// Function that removes a property, if it exists, from an entity
pub type RemoveModelPropertyFn = fn(EntityCommands);

pub fn get_remove_model_property_fn<T: Component + Default>() -> RemoveModelPropertyFn {
|mut e_commands| {
e_commands.remove::<T>();
}
}

/// This resource keeps track of all the properties that can be configured for a model description.
#[derive(Resource)]
pub struct ModelPropertyData {
pub required: HashMap<ComponentId, (String, InsertModelPropertyFn, RemoveModelPropertyFn)>,
pub optional: HashMap<ComponentId, (String, InsertModelPropertyFn, RemoveModelPropertyFn)>,
}

impl FromWorld for ModelPropertyData {
fn from_world(world: &mut World) -> Self {
let mut required = HashMap::new();
world.register_component::<ModelProperty<AssetSource>>();
required.insert(
world
.components()
.component_id::<ModelProperty<AssetSource>>()
.unwrap(),
(
"Asset Source".to_string(),
get_insert_model_property_fn::<ModelProperty<AssetSource>>(),
get_remove_model_property_fn::<ModelProperty<AssetSource>>(),
),
);
world.register_component::<ModelProperty<Scale>>();
required.insert(
world
.components()
.component_id::<ModelProperty<Scale>>()
.unwrap(),
(
"Scale".to_string(),
get_insert_model_property_fn::<ModelProperty<Scale>>(),
get_remove_model_property_fn::<ModelProperty<Scale>>(),
),
);
world.register_component::<ModelProperty<IsStatic>>();
required.insert(
world
.components()
.component_id::<ModelProperty<IsStatic>>()
.unwrap(),
(
"Is Static".to_string(),
get_insert_model_property_fn::<IsStatic>(),
get_remove_model_property_fn::<IsStatic>(),
),
);
let optional = HashMap::new();
Self { required, optional }
}
}
Loading