Skip to content

Conversation

@misha7b
Copy link
Contributor

@misha7b misha7b commented Feb 9, 2025

No description provided.

Copy link
Collaborator

@davidbeechey davidbeechey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good, sorry for the delay in accelerometer. Optical flow is merged now so that can be added to your sensor reading logic and passed to your localiser :)

@misha7b misha7b force-pushed the localizer_board_code branch from 764037a to 9e26cca Compare March 20, 2025 18:43
Comment on lines 71 to 111
loop {
// Wait for new Keyence stripe count.
let stripe_count1 = receiver1.get().await;
let stripe_count2 = receiver2.get().await;

let flow = optical_flow.get_motion().await.unwrap();
let optical_data: Vec<f64, 2> = Vec::from_slice(&[flow.x as f64, flow.y as f64]).unwrap();

defmt::info!(
"New Keyence stripe counts: sensor1 = {}, sensor2 = {}",
stripe_count1,
stripe_count2
);

// Create the sensor data. (no accelerometer data)
let keyence_data: Vec<u32, 2> = Vec::from_slice(&[stripe_count1, stripe_count2]).unwrap();
let accelerometer_data: RawAccelerometerData<NUM_ACCELEROMETERS, NUM_AXIS> =
RawAccelerometerData::from_slice(&[
Vec::from_slice(&[0.0, 0.0, 9.81]).unwrap(),
Vec::from_slice(&[0.0, 0.0, 9.81]).unwrap(),
Vec::from_slice(&[0.0, 0.0, 9.81]).unwrap(),
Vec::from_slice(&[0.0, 0.0, 9.81]).unwrap(),
])
.unwrap();

match localizer.iteration(optical_data, keyence_data, accelerometer_data) {
Ok(()) => {
defmt::info!(
"Iteration OK: displacement = {} m, velocity = {} m/s, acceleration = {} m/s**2",
localizer.displacement,
localizer.velocity,
localizer.acceleration
);
}
Err(e) => {
defmt::error!("Iteration error: {:?}", e);
}
}

Timer::after(Duration::from_millis(100)).await;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the way this loop is written at the moment all of the sensors will need to have their value read before the localiser is updated. Is probs better to check if any value has been updated instead so that it's updating as often as possible

JoelHorrocks added a commit to Hyp-ed/hyped-2026 that referenced this pull request Nov 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants