Skip to content

Commit

Permalink
merge kick conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
bluskript committed Jul 16, 2022
2 parents 86832c0 + a63f683 commit adb332b
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
2 changes: 2 additions & 0 deletions controller/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ pub struct Config {
pub reader: Option<Reader>,
pub strategy: Option<Strategy>,
pub state_randomizer: bool,
pub racing: bool,
pub team: Team,
pub software_switch_initialize_pin: u8,
pub software_switch_toggle_pin: u8,
Expand Down Expand Up @@ -187,6 +188,7 @@ impl Default for Config {
}),
motors: None,
state_randomizer: false,
racing: false,
reader: Some(Reader {
uart_path: "/dev/ttyAMA0".to_string(),
line_sensor_count: 46,
Expand Down
6 changes: 6 additions & 0 deletions controller/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ use controller::{
modules::{
camera, line,
motors::Motors,
racing::Racing,
reader::Reader,
server::StateRecorder,
state::{self, ModuleSync},
Expand Down Expand Up @@ -100,6 +101,7 @@ async fn handle_config_change(cfg: Config) -> Result<Vec<AnyModule>> {
ref motors,
ref server,
ref state_randomizer,
ref racing,
ref reader,
ref strategy,
..
Expand Down Expand Up @@ -147,5 +149,9 @@ async fn handle_config_change(cfg: Config) -> Result<Vec<AnyModule>> {
new_modules.push(Box::new(state_randomizer::StateRandomizer::new()));
}

if *racing {
new_modules.push(Box::new(Racing {}));
}

Ok(new_modules)
}
1 change: 1 addition & 0 deletions controller/src/modules/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pub mod line;
#[cfg(test)]
pub mod line_test;
pub mod motors;
pub mod racing;
pub mod reader;
pub mod server;
pub mod state;
Expand Down
33 changes: 33 additions & 0 deletions controller/src/modules/racing.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
use std::sync::Arc;

use crate::math::vec2::Vec2;

use super::{
state::{ModuleSync, State},
Module,
};
use anyhow::Result;
use async_trait::async_trait;
use parking_lot::RwLock;

pub struct Racing {}

#[async_trait]
impl Module for Racing {
fn name(&self) -> &'static str {
"racing"
}

async fn tick(&mut self, state: &mut Arc<RwLock<State>>, sync: &mut ModuleSync) -> Result<()> {
state.write().move_vector = Some((Vec2::new(0.0, 1.0), false));
Ok(())
}

async fn start(&mut self) -> Result<()> {
Ok(())
}

async fn stop(&mut self) -> Result<()> {
Ok(())
}
}

0 comments on commit adb332b

Please sign in to comment.