Skip to content

Commit

Permalink
chk
Browse files Browse the repository at this point in the history
  • Loading branch information
ryescholin committed Jun 1, 2024
1 parent db72a2b commit 6bc842e
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions pod-operation/src/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,24 @@ impl StateMachine {
/// Perform operations when the pod is running
fn _running_periodic(&mut self) -> State {
info!("Rolling Running state");
let encoder_value = self.wheel_encoder.measure().expect("wheel encoder faulted"); // Read the encoder value
if encoder_value > STOP_THRESHOLD {

let encoder_value = self.wheel_encoder.lock().unwrap();
let distance = encoder_value.get_distance();
let velocity: f32 = encoder_value.get_velocity();
drop(encoder_value);

let full_json = json!({
"distance": distance,
"velocity": velocity,
});

self.io
.of("/control-station")
.unwrap()
.emit("serverResponse", full_json)
.ok();

if StateMachine::_should_stop(distance, velocity) {
return State::Stopped;
}

Expand Down

0 comments on commit 6bc842e

Please sign in to comment.