Skip to content

Commit

Permalink
Create a default for joint names
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Della Vedova <[email protected]>
  • Loading branch information
luca-della-vedova committed Dec 19, 2023
1 parent 411042d commit 9da7259
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions rmf_site_editor/src/workcell/joint.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,25 +31,30 @@ pub fn handle_create_joint_events(
mut commands: Commands,
mut events: EventReader<CreateJoint>,
mut dependents: Query<&mut Dependents>,
frames: Query<(), With<FrameMarker>>,
frames: Query<&NameInWorkcell, With<FrameMarker>>,
) {
for req in events.iter() {
if frames.get(req.parent).is_err() {
let Ok(parent_name) = frames.get(req.parent) else {
error!(
"Requested to create a joint with a parent that is not a frame, \
this is not valid and will be ignored"
);
continue;
}
if frames.get(req.child).is_err() {
};
let Ok(child_name) = frames.get(req.child) else {
error!(
"Requested to create a joint with a child that is not a frame, \
this is not valid and will be ignored"
);
continue;
}
};
let joint_name = if !parent_name.is_empty() && !child_name.is_empty() {
format!("joint-{}-{}", **parent_name, **child_name)
} else {
"new_joint".into()
};
let joint = Joint {
name: NameInWorkcell("new_joint".into()),
name: NameInWorkcell(joint_name),
properties: JointProperties::Fixed,
};
let mut cmd = commands.spawn(Dependents::single(req.child));
Expand Down

0 comments on commit 9da7259

Please sign in to comment.