Skip to content

Commit 3f93670

Browse files
backend: libs: autopilot: src: merge incoming new config to the default configs
1 parent 5d91195 commit 3f93670

File tree

1 file changed

+12
-1
lines changed
  • backend/libs/autopilot/src

1 file changed

+12
-1
lines changed

backend/libs/autopilot/src/mod.rs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,20 @@ pub(crate) async fn control_inner(
9595
}
9696
Action::SetActuatorsConfig(new_config) => {
9797
let mut manager = MANAGER.get().context("Not available")?.write().await;
98+
let mut new_config = new_config.to_owned();
99+
100+
let base_config = &manager
101+
.settings
102+
.actuators
103+
.get(&actuators_control.camera_uuid)
104+
.map(api::ActuatorsConfig::from)
105+
.unwrap_or(api::ActuatorsConfig::from(&CameraActuators::default()));
106+
107+
new_config = merge_struct::merge(base_config, &new_config.clone())
108+
.context("Failing to merge structs")?;
98109

99110
manager
100-
.update_config(&actuators_control.camera_uuid, new_config, false)
111+
.update_config(&actuators_control.camera_uuid, &new_config, false)
101112
.await?;
102113

103114
let config: &api::ActuatorsConfig = &manager

0 commit comments

Comments
 (0)