Skip to content

Commit ba495de

Browse files
xiyuohmxgrey
andauthored
Retry spawning scenes if assets are not ready (#386)
* Created a timeout loop for spawning scenes Signed-off-by: Xiyu Oh <xiyu@openrobotics.org> * Skip serializing door properties if default Signed-off-by: Xiyu Oh <xiyu@openrobotics.org> * Use cycle for retry mechanism Signed-off-by: Xiyu Oh <xiyu@openrobotics.org> * Remove retry mechanism and use wait_for_asset_untyped Signed-off-by: Xiyu Oh <xiyu@openrobotics.org> --------- Signed-off-by: Xiyu Oh <xiyu@openrobotics.org> Co-authored-by: Grey <mxgrey@intrinsic.ai> Co-authored-by: Grey <greyxmike@gmail.com>
1 parent 31bb77c commit ba495de

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

crates/rmf_site_editor/src/site/model.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ fn load_asset_source(
173173
return Err(ModelLoadingErrorKind::InvalidAssetSource(err.to_string()));
174174
}
175175
};
176-
asset_server
176+
let handle = asset_server
177177
.load_untyped_async(&asset_path)
178178
.await
179179
.map_err(|err| {
@@ -187,7 +187,15 @@ fn load_asset_source(
187187
error!("Failed attempt to load asset with [{asset_path}]: {err}");
188188
}
189189
ModelLoadingErrorKind::AssetServerError(err.to_string())
190+
})?;
191+
asset_server
192+
.wait_for_asset_untyped(&handle)
193+
.await
194+
.map_err(|err| {
195+
error!("Failed attempt to load asset with [{asset_path}]: {err}");
196+
ModelLoadingErrorKind::AssetServerError(err.to_string())
190197
})
198+
.map(|_| handle)
191199
}
192200
}
193201
}

crates/rmf_site_format/src/door.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ impl Default for DoorType {
109109
pub struct SingleSlidingDoor {
110110
/// Which side the door slides towards
111111
pub towards: Side,
112+
#[serde(default, skip_serializing_if = "is_default")]
112113
pub position: f32,
113114
}
114115

@@ -132,7 +133,9 @@ impl From<SingleSlidingDoor> for DoorType {
132133
pub struct DoubleSlidingDoor {
133134
/// Length of the left door divided by the length of the right door
134135
pub left_right_ratio: f32,
136+
#[serde(default, skip_serializing_if = "is_default")]
135137
pub left_position: f32,
138+
#[serde(default, skip_serializing_if = "is_default")]
136139
pub right_position: f32,
137140
}
138141

@@ -170,6 +173,7 @@ pub struct SingleSwingDoor {
170173
pub pivot_on: Side,
171174
/// How does the door swing
172175
pub swing: Swing,
176+
#[serde(default, skip_serializing_if = "is_default")]
173177
pub position: f32,
174178
}
175179

@@ -196,7 +200,9 @@ pub struct DoubleSwingDoor {
196200
pub swing: Swing,
197201
/// Length of the left door divided by the length of the right door
198202
pub left_right_ratio: f32,
203+
#[serde(default, skip_serializing_if = "is_default")]
199204
pub left_position: f32,
205+
#[serde(default, skip_serializing_if = "is_default")]
200206
pub right_position: f32,
201207
}
202208

0 commit comments

Comments
 (0)