Skip to content

Commit dfc50b2

Browse files
feat: add color profiles for all trad cv missions
1 parent 6ed7316 commit dfc50b2

5 files changed

Lines changed: 29 additions & 8 deletions

File tree

src/main.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,12 @@ async fn run_mission(mission: &str, cancel: CancellationToken) -> Result<()> {
438438
gate_target().await,
439439
))
440440
.execute()),
441-
"octagon" => ctwrap!(octagon(static_context().await, &config.missions.octagon).execute()),
441+
"octagon" => ctwrap!(octagon(
442+
static_context().await,
443+
&config.missions.octagon,
444+
&config.get_color_profile().unwrap()
445+
)
446+
.execute()),
442447
"buoy_circle" => ctwrap!(buoy_circle_sequence(&FullActionContext::new(
443448
control_board().await,
444449
meb().await,
@@ -477,7 +482,11 @@ async fn run_mission(mission: &str, cancel: CancellationToken) -> Result<()> {
477482
.unwrap();
478483
Ok(())
479484
}
480-
"slalom" => ctwrap!(slalom(static_context().await, &config.missions.slalom)),
485+
"slalom" => ctwrap!(slalom(
486+
static_context().await,
487+
&config.missions.slalom,
488+
&config.get_color_profile().unwrap()
489+
)),
481490
"sonar" => {
482491
let _ = sonar(static_context().await, &config.sonar, cancel).await;
483492
Ok(())

src/missions/octagon.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use tokio_serial::SerialStream;
33

44
use crate::{
55
act_nest,
6-
config::octagon::Config,
6+
config::{octagon::Config, ColorProfile},
77
missions::{
88
action::{
99
ActionChain, ActionConcurrent, ActionDataConditional, ActionSequence, ActionWhile,
@@ -43,6 +43,7 @@ pub fn octagon<
4343
>(
4444
context: &'static Con,
4545
config: &Config,
46+
color_profile: &ColorProfile,
4647
) -> impl ActionExec<()> + 'static {
4748
const FULL_SPEED_Y: f32 = 0.7;
4849
const FULL_SPEED_X: f32 = 0.0;

src/missions/slalom.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ use crate::{
2020
config::{
2121
slalom::{Config, Side::*},
2222
sonar::Config as SonarConfig,
23+
ColorProfile,
2324
},
2425
missions::{
2526
action::ActionExec,
@@ -34,6 +35,7 @@ pub async fn slalom<
3435
>(
3536
context: &Con,
3637
config: &Config,
38+
color_profile: &ColorProfile,
3739
) {
3840
use crate::vision::slalom::Slalom;
3941
#[cfg(feature = "logging")]
@@ -42,7 +44,10 @@ pub async fn slalom<
4244
let cb = context.get_control_board();
4345
let _ = cb.bno055_periodic_read(true).await;
4446

45-
let mut vision = VisionNormAngle::<Con, Slalom, f64>::new(context, Slalom::default());
47+
let mut vision = VisionNormAngle::<Con, Slalom, f64>::new(
48+
context,
49+
Slalom::from_color_profile(color_profile),
50+
);
4651

4752
let initial_yaw = loop {
4853
if let Some(initial_angle) = cb.responses().get_angles().await {

src/vision/path_cv.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,17 +73,17 @@ impl PathCV {
7373
}
7474

7575
impl PathCV {
76-
pub fn from_color_profile(color_profile: &ColorProfile) -> Self {
77-
Self::new(color_profile.orange.clone(), Size::from((400, 300)))
78-
}
79-
8076
pub fn new(color_bounds: RangeInclusive<Yuv>, size: Size) -> Self {
8177
Self {
8278
color_bounds,
8379
size,
8480
image: Mat::default().into(),
8581
}
8682
}
83+
84+
pub fn from_color_profile(color_profile: &ColorProfile) -> Self {
85+
Self::new(color_profile.orange.clone(), Size::from((400, 300)))
86+
}
8787
}
8888

8989
impl Default for PathCV {

src/vision/slalom.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use crate::config::ColorProfile;
2+
13
use super::{image_prep::resize, MatWrapper, PosVector, VisualDetection, VisualDetector, Yuv};
24
use opencv::{
35
core::{in_range, Point, Scalar, Size, Vector},
@@ -24,6 +26,10 @@ impl Slalom {
2426
image: Mat::default().into(),
2527
}
2628
}
29+
30+
pub fn from_color_profile(color_profile: &ColorProfile) -> Self {
31+
Self::new(color_profile.orange.clone(), Size::from((400, 300)))
32+
}
2733
}
2834

2935
// TODO: Change these to match slalom, not path

0 commit comments

Comments
 (0)