load config from real file
This commit is contained in:
parent
ce223621d1
commit
9e43e6a943
4 changed files with 29 additions and 7 deletions
|
@ -5,13 +5,14 @@ use interface::auto::{AutoInterface, Configurable};
|
|||
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub fn entry(interface: AutoInterface) -> Pin<Box<dyn Future<Output = ()> + Send>> {
|
||||
pub fn entry(interface: AutoInterface) -> Pin<Box<dyn Future<Output = ()>>> {
|
||||
Box::pin(auto(interface))
|
||||
}
|
||||
|
||||
#[unsafe(no_mangle)]
|
||||
pub static NAME: &'static str = "scanseek v1";
|
||||
|
||||
|
||||
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.)
|
||||
|
@ -23,7 +24,7 @@ pub static CONFIGS: &[Configurable] = &[
|
|||
AUTO_SELF_OCCLUSION,
|
||||
];
|
||||
|
||||
async fn auto (interface: AutoInterface) {
|
||||
async fn auto (mut interface: AutoInterface) {
|
||||
let mut tof_l = Stats::new();
|
||||
let mut tof_r = Stats::new();
|
||||
loop {
|
||||
|
|
|
@ -3,6 +3,7 @@ use std::{collections::VecDeque, ops::{Deref, Div, Index, Range, Sub}, sync::Arc
|
|||
use common::{CamState, ControlPacket, SensorData, TelemetryPacket};
|
||||
use anyhow::{Context, Ok, Result};
|
||||
use eframe::Storage;
|
||||
use libloading::{Library, Symbol};
|
||||
use tokio::sync::{self, broadcast, mpsc, watch};
|
||||
|
||||
pub struct AutoConfig {
|
||||
|
@ -11,14 +12,14 @@ pub struct AutoConfig {
|
|||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct AutoInterface<'s> {
|
||||
pub struct AutoInterface {
|
||||
command_sender: Option<mpsc::Sender<ControlPacket>>,
|
||||
data_receiver: watch::Receiver<TelemetryPacket>,
|
||||
config: &'s dyn Storage,
|
||||
config: &'static dyn Storage,
|
||||
enabled: bool,
|
||||
}
|
||||
|
||||
impl<'s> AutoInterface<'s> {
|
||||
impl AutoInterface {
|
||||
/// change active command, fails if not in control
|
||||
pub async fn run_command(&self, command: ControlPacket) -> Result<()> {
|
||||
self.command_sender.as_ref().context("no sender")?.send(command).await?;
|
||||
|
@ -100,3 +101,21 @@ pub trait Auto {
|
|||
fn default_configs() -> [Configurable];
|
||||
fn name() -> &'static str;
|
||||
}
|
||||
|
||||
|
||||
pub fn get_confs() -> Result<()> {
|
||||
let lib = unsafe {Library::new("../auto/target/release/libauto.so")?};
|
||||
|
||||
let configurations: Symbol<&&[Configurable]> = unsafe {lib.get(b"CONFIGS").unwrap()};
|
||||
|
||||
for config in configurations.iter() {
|
||||
println!("co {}", config.name);
|
||||
println!("co {:?}", config.description);
|
||||
}
|
||||
|
||||
let name: Symbol<&&'static str> = unsafe {lib.get(b"NAME").unwrap()};
|
||||
println!("na {:?}", *name);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
|
|
@ -93,7 +93,6 @@ const AUTO_GAP: Configurable = Configurable::new("auto minimum gap").range(0. ..
|
|||
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] = &[
|
||||
AUTO_GAP,
|
||||
AUTO_SELF_OCCLUSION,
|
||||
|
|
|
@ -2,7 +2,7 @@ use std::{fmt::format, ops::ControlFlow, result, sync::{atomic::Ordering, Arc},
|
|||
|
||||
use anyhow::{Context, Ok, Result};
|
||||
use atomic_float::AtomicF32;
|
||||
use interface::{combatlog::{combat_logger, CombatData}, POWER_THRESHOLD};
|
||||
use interface::{auto::get_confs, combatlog::{combat_logger, CombatData}, POWER_THRESHOLD};
|
||||
use common::{ControlPacket, TelemetryPacket};
|
||||
use cpal::traits::{DeviceTrait, HostTrait, StreamTrait};
|
||||
use egui_toast::{Toast, ToastKind};
|
||||
|
@ -13,6 +13,9 @@ use tokio::{io::{AsyncReadExt, AsyncWriteExt, BufWriter, WriteHalf}, net::{tcp::
|
|||
|
||||
|
||||
fn main() -> Result<()> {
|
||||
get_confs().unwrap();
|
||||
panic!("got too far");
|
||||
|
||||
let (logging_sender, combatlog) = mpsc::channel(64);
|
||||
|
||||
// assumes pulseaudio system with f32 samples and 2204 sample packets
|
||||
|
|
Loading…
Reference in a new issue