-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Indicate role using LED eye colors #119
Changes from 2 commits
8be05a7
90dcf8d
8fa1136
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -3,7 +3,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH}; | |||||
use color_eyre::Result; | ||||||
use context_attribute::context; | ||||||
use framework::{MainOutput, PerceptionInput}; | ||||||
use types::{Ball, CycleTime, Eye, FilteredWhistle, Leds, PrimaryState, Rgb}; | ||||||
use types::{Ball, CycleTime, Eye, FilteredWhistle, Leds, PrimaryState, Rgb, Role}; | ||||||
|
||||||
pub struct LedStatus { | ||||||
blink_state: bool, | ||||||
|
@@ -20,6 +20,7 @@ pub struct CycleContext { | |||||
pub primary_state: Input<PrimaryState, "primary_state">, | ||||||
pub cycle_time: Input<CycleTime, "cycle_time">, | ||||||
pub filtered_whistle: Input<FilteredWhistle, "filtered_whistle">, | ||||||
pub role: Input<Role, "role">, | ||||||
|
||||||
pub balls_bottom: PerceptionInput<Option<Vec<Ball>>, "VisionBottom", "balls?">, | ||||||
pub balls_top: PerceptionInput<Option<Vec<Ball>>, "VisionTop", "balls?">, | ||||||
|
@@ -147,6 +148,7 @@ impl LedStatus { | |||||
at_least_one_ball_data_bottom, | ||||||
last_ball_data_top_too_old, | ||||||
last_ball_data_bottom_too_old, | ||||||
*context.role, | ||||||
); | ||||||
|
||||||
let ears = if context.filtered_whistle.is_detected { | ||||||
|
@@ -176,6 +178,7 @@ impl LedStatus { | |||||
at_least_one_ball_data_bottom: bool, | ||||||
last_ball_data_top_too_old: bool, | ||||||
last_ball_data_bottom_too_old: bool, | ||||||
role: Role, | ||||||
) -> (Eye, Eye) { | ||||||
match primary_state { | ||||||
PrimaryState::Unstiff => { | ||||||
|
@@ -199,6 +202,16 @@ impl LedStatus { | |||||
} else { | ||||||
None | ||||||
}; | ||||||
let right_eye = match role { | ||||||
Role::Loser => Eye::loser_eye(), | ||||||
Role::Striker => Eye::striker_eye(), | ||||||
Role::StrikerSupporter => Eye::striker_support_eye(), | ||||||
Role::DefenderLeft | Role::DefenderRight => Eye::defender_eye(), | ||||||
Role::Keeper => Eye::keeper_eye(), | ||||||
Role::ReplacementKeeper => Eye::keeper_replacement_eye(), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Role::Searcher => Eye::searcher_eye(), | ||||||
_ => Eye::default() | ||||||
}; | ||||||
( | ||||||
Eye { | ||||||
color_at_0: ball_color_top | ||||||
|
@@ -216,7 +229,7 @@ impl LedStatus { | |||||
color_at_315: ball_color_top | ||||||
.unwrap_or_else(|| ball_background_color.unwrap_or(Rgb::BLACK)), | ||||||
}, | ||||||
Eye::default(), | ||||||
right_eye, | ||||||
) | ||||||
} | ||||||
} | ||||||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -26,6 +26,99 @@ pub struct Eye { | |||||
pub color_at_315: Rgb, | ||||||
} | ||||||
|
||||||
impl Eye { | ||||||
pub fn loser_eye() -> Eye { | ||||||
Eye { | ||||||
color_at_0: Rgb::new(255, 150, 255), | ||||||
color_at_45: Rgb::new(25, 0, 25), | ||||||
color_at_90: Rgb::new(255, 200, 25), | ||||||
color_at_135: Rgb::new(55, 0, 255), | ||||||
color_at_180: Rgb::new(255, 0, 25), | ||||||
color_at_225: Rgb::new(25, 30, 255), | ||||||
color_at_270: Rgb::new(255, 0, 255), | ||||||
color_at_315: Rgb::new(255, 10, 5), | ||||||
} | ||||||
} | ||||||
|
||||||
pub fn striker_eye() -> Eye { | ||||||
Eye { | ||||||
color_at_0: Rgb::new(255, 0, 0), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. User Rgb::Red |
||||||
color_at_45: Rgb::new(255, 0, 0), | ||||||
color_at_90: Rgb::new(255, 0, 0), | ||||||
color_at_135: Rgb::new(255, 0, 0), | ||||||
color_at_180: Rgb::new(255, 0, 0), | ||||||
color_at_225: Rgb::new(255, 0, 0), | ||||||
color_at_270: Rgb::new(255, 0, 0), | ||||||
color_at_315: Rgb::new(255, 0, 0), | ||||||
} | ||||||
} | ||||||
|
||||||
pub fn striker_support_eye() -> Eye { | ||||||
Eye { | ||||||
color_at_0: Rgb::new(255, 255, 0), | ||||||
color_at_45: Rgb::new(255, 255, 0), | ||||||
color_at_90: Rgb::new(255, 255, 0), | ||||||
color_at_135: Rgb::new(255, 255, 0), | ||||||
color_at_180: Rgb::new(255, 255, 0), | ||||||
color_at_225: Rgb::new(255, 255, 0), | ||||||
color_at_270: Rgb::new(255, 255, 0), | ||||||
color_at_315: Rgb::new(255, 255, 0), | ||||||
} | ||||||
} | ||||||
|
||||||
pub fn defender_eye() -> Eye { | ||||||
Eye { | ||||||
color_at_0: Rgb::new(255, 255, 255), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use rgb::white. |
||||||
color_at_45: Rgb::new(255, 255, 255), | ||||||
color_at_90: Rgb::new(255, 255, 255), | ||||||
color_at_135: Rgb::new(255, 255, 255), | ||||||
color_at_180: Rgb::new(255, 255, 255), | ||||||
color_at_225: Rgb::new(255, 255, 255), | ||||||
color_at_270: Rgb::new(255, 255, 255), | ||||||
color_at_315: Rgb::new(255, 255, 255), | ||||||
} | ||||||
} | ||||||
|
||||||
pub fn keeper_eye() -> Eye { | ||||||
Eye { | ||||||
color_at_0: Rgb::new(0, 0, 255), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See comments above |
||||||
color_at_45: Rgb::new(0, 0, 255), | ||||||
color_at_90: Rgb::new(0, 0, 255), | ||||||
color_at_135: Rgb::new(0, 0, 255), | ||||||
color_at_180: Rgb::new(0, 0, 255), | ||||||
color_at_225: Rgb::new(0, 0, 255), | ||||||
color_at_270: Rgb::new(0, 0, 255), | ||||||
color_at_315: Rgb::new(0, 0, 255), | ||||||
} | ||||||
} | ||||||
|
||||||
pub fn keeper_replacement_eye() -> Eye { | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Eye { | ||||||
color_at_0: Rgb::new(0, 220, 255), | ||||||
color_at_45: Rgb::new(0, 220, 255), | ||||||
color_at_90: Rgb::new(0, 220, 255), | ||||||
color_at_135: Rgb::new(0, 220, 255), | ||||||
color_at_180: Rgb::new(0, 220, 255), | ||||||
color_at_225: Rgb::new(0, 220, 255), | ||||||
color_at_270: Rgb::new(0, 220, 255), | ||||||
color_at_315: Rgb::new(0, 220, 255), | ||||||
} | ||||||
} | ||||||
|
||||||
pub fn searcher_eye() -> Eye { | ||||||
Eye { | ||||||
color_at_0: Rgb::new(255, 255, 0), | ||||||
color_at_45: Rgb::new(0, 0, 255), | ||||||
color_at_90: Rgb::new(255, 255, 0), | ||||||
color_at_135: Rgb::new(0, 0, 255), | ||||||
color_at_180: Rgb::new(255, 255, 0), | ||||||
color_at_225: Rgb::new(0, 0, 255), | ||||||
color_at_270: Rgb::new(255, 255, 0), | ||||||
color_at_315: Rgb::new(0, 0, 255), | ||||||
} | ||||||
} | ||||||
} | ||||||
|
||||||
impl From<Rgb> for Eye { | ||||||
fn from(rgb: Rgb) -> Self { | ||||||
Self { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we maybe split this up, and split the colours in the eye based on the defender side? Might be useful!