use configurable as a key
This commit is contained in:
parent
21e269bc43
commit
5b3347bb00
2 changed files with 20 additions and 9 deletions
|
@ -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()) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
use std::{collections::VecDeque, ops::{Div, Range, Sub}};
|
||||
use std::{collections::VecDeque, ops::{Deref, Div, Index, Range, Sub}};
|
||||
|
||||
use common::{CamState, ControlPacket, SensorData};
|
||||
use anyhow::Result;
|
||||
|
@ -22,7 +22,7 @@ impl AutoInterface {
|
|||
/// request auto enable, fails if the driver does not grant it
|
||||
pub fn enable(&self) -> Result<()> {unimplemented!()}
|
||||
pub fn enabled(&self) -> bool {unimplemented!()}
|
||||
pub fn auto_conf(&self) -> AutoConfig {unimplemented!()}
|
||||
pub fn conf(&self, key: &'static Configurable) -> f32 {unimplemented!()}
|
||||
fn send_message(&self, message: String) {unimplemented!()}
|
||||
}
|
||||
|
||||
|
@ -53,6 +53,14 @@ impl Configurable {
|
|||
}
|
||||
}
|
||||
|
||||
impl Deref for Configurable {
|
||||
type Target = str;
|
||||
|
||||
fn deref(&self) -> &Self::Target {
|
||||
self.name
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for Configurable {
|
||||
fn default() -> Self {
|
||||
Self { name: Default::default(), description: Default::default(), default: Default::default(), min: 0.0, max: 1.0 }
|
||||
|
|
Loading…
Reference in a new issue