Skip to content

Commit

Permalink
Add the full state to step response (#171)
Browse files Browse the repository at this point in the history
* Add full_state info to simulation step response

* Upd submodule

---------

Co-authored-by: Thomas Lohse <thomas.k.lohse@gmail.com>
  • Loading branch information
seblund and t-lohse authored Aug 23, 2023
1 parent 4b41c9d commit b338fa2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[submodule "Ecdar-ProtoBuf"]
path = Ecdar-ProtoBuf
url = https://github.com/Ecdar/Ecdar-ProtoBuf.git
branch = futureproof1
branch = main
2 changes: 1 addition & 1 deletion Ecdar-ProtoBuf
Submodule Ecdar-ProtoBuf updated 1 files
+4 −0 query.proto
16 changes: 13 additions & 3 deletions src/ProtobufServer/ecdar_requests/simulation_requests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use crate::{
services::{SimulationStartRequest, SimulationStepRequest, SimulationStepResponse},
ConcreteEcdarBackend,
},
System::specifics::SpecificDecision,
System::specifics::{SpecificDecision, SpecificState},
};

use super::request_util::simulation_info_to_transition_system;
Expand All @@ -23,13 +23,19 @@ impl ConcreteEcdarBackend {
let transition_system = simulation_info_to_transition_system(&simulation_info, &mut cache);

// Get the decisions from the initial state and convert them to proto
let initial = Decision::get_initial_decisions(&transition_system)
let decisions = Decision::get_initial_decisions(&transition_system)
.into_iter()
.map(|i| SpecificDecision::from_decision(&i, &*transition_system).into())
.collect();

let state = transition_system.get_initial_state();

let full_state =
state.map(|state| SpecificState::from_state(&state, &*transition_system).into());

Ok(SimulationStepResponse {
new_decision_points: initial,
full_state,
new_decision_points: decisions,
})
}

Expand All @@ -45,6 +51,9 @@ impl ConcreteEcdarBackend {
let system = simulation_info_to_transition_system(&simulation_info, &mut cache);

let chosen_decision = request_message.chosen_decision.unwrap();

let full_state = chosen_decision.destination.clone();

let chosen_decision = proto_decision_to_decision(chosen_decision, &system);

let decision_points = chosen_decision.resolve(&system);
Expand All @@ -55,6 +64,7 @@ impl ConcreteEcdarBackend {
.collect();

Ok(SimulationStepResponse {
full_state,
new_decision_points: decision_points,
})
}
Expand Down

0 comments on commit b338fa2

Please sign in to comment.