use configurable as a key

This commit is contained in:
Andy Killorin 2025-03-08 19:18:25 -05:00
commit 5b3347bb00
Signed by: ank
GPG key ID: 23F9463ECB67FE8C

View file

@ -12,15 +12,15 @@ pub fn entry(interface: AutoInterface) -> Pin<Box<dyn Future<Output = ()> + Send
#[unsafe(no_mangle)]
pub static NAME: &'static str = "scanseek v1";
const AUTO_GAP: i16 = 140; /// mm tofs must drop to count as a hit
const AUTO_SELF_OCCLUSION: u16 = 130; /// minimum
const AUTO_GAP: Configurable = Configurable::new("auto minimum gap").range(0. .. 300.).default(140.)
.description("distance (mm) distance measurements must instantaneously drop to indicate a detection. This should line up with the size of the smallest robot you compete against");
const AUTO_SELF_OCCLUSION: Configurable = Configurable::new("auto self occlusion").range(0. .. 200.).default(143.)
.description("distance (mm) below which measurements are considered noise in the scan phase");
#[unsafe(no_mangle)]
pub static CONFIGS: &[Configurable] = &[
Configurable::new("auto minimum gap").range(0. .. 300.).default(140.)
.description("distance (mm) distance measurements must instantaneously drop to indicate a detection. This should line up with the size of the smallest robot you compete against"),
Configurable::new("auto self occlusion").range(0. .. 200.).default(143.)
.description("distance (mm) below which measurements are considered noise in the scan phase"),
AUTO_GAP,
AUTO_SELF_OCCLUSION,
];
async fn auto (interface: AutoInterface) {
@ -42,8 +42,11 @@ async fn auto (interface: AutoInterface) {
};
tof_r.update(latest_tof_r as i16);
let auto_gap = interface.conf(&AUTO_GAP);
let auto_self_occlusion = interface.conf(&AUTO_SELF_OCCLUSION);
let detection = |latest: u16, delta: i16| {
delta < AUTO_GAP && latest > AUTO_SELF_OCCLUSION
delta < auto_gap as i16 && latest > auto_self_occlusion as u16
};
if detection(latest_tof_l, tof_l.delta()) || detection(latest_tof_l, tof_l.delta()) {