Skip to content

Commit 66231d2

Browse files
post semi run 1
1 parent 32b2cad commit 66231d2

5 files changed

Lines changed: 69 additions & 4 deletions

File tree

src/config/path_align.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ pub struct Config {
55
pub depth: f32,
66
pub speed: f32,
77
pub forward_speed: f32,
8+
pub strafe_speed: f32,
89
pub detections: u8,
10+
pub yaw_angle: f32,
11+
pub forward_duration: u64,
12+
pub yaw_wait: u64,
913
}
1014

1115
impl Default for Config {
@@ -14,7 +18,11 @@ impl Default for Config {
1418
depth: -1.25,
1519
speed: 0.3,
1620
forward_speed: 0.3,
21+
strafe_speed: 0.3,
1722
detections: 10,
23+
yaw_angle: 15.0,
24+
forward_duration: 3,
25+
yaw_wait: 3,
1826
}
1927
}
2028
}

src/main.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ use sw8s_rust_lib::{
2626
gate::{gate_run_complex, gate_run_naive, gate_run_procedural, gate_run_testing},
2727
meb::WaitArm,
2828
octagon::octagon,
29-
path_align::path_align_procedural,
29+
path_align::{path_align_procedural, static_align_procedural},
3030
reset_torpedo::ResetTorpedo,
3131
slalom::slalom,
3232
sonar::sonar,
@@ -422,6 +422,16 @@ async fn run_mission(mission: &str, cancel: CancellationToken) -> Result<()> {
422422
&config.missions.path_align,
423423
&config.get_color_profile().unwrap(),
424424
)),
425+
"static_align" => ctwrap!(static_align_procedural(
426+
&FullActionContext::new(
427+
control_board().await,
428+
meb().await,
429+
front_cam().await,
430+
bottom_cam().await,
431+
gate_target().await,
432+
),
433+
&config.missions.path_align,
434+
)),
425435
"example" => ctwrap!(initial_descent(&FullActionContext::new(
426436
control_board().await,
427437
meb().await,

src/missions/gate.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ pub async fn gate_run_procedural<
8989

9090
let shark = detections
9191
.iter()
92-
.filter(|d| matches!(d.class().identifier, Target::Shark))
92+
.filter(|d| matches!(d.class().identifier, Target::Sawfish))
9393
.collect_vec();
9494

9595
let sawfish = detections
9696
.iter()
97-
.filter(|d| matches!(d.class().identifier, Target::Sawfish))
97+
.filter(|d| matches!(d.class().identifier, Target::Shark))
9898
.collect_vec();
9999

100100
let mut traversal_timer = DelayAction::new(8.0); // forward duration in second

src/missions/path_align.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,3 +125,50 @@ pub async fn path_align_procedural<
125125
.await;
126126
sleep(Duration::from_secs(1)).await;
127127
}
128+
129+
pub async fn static_align_procedural<
130+
Con: Send + Sync + GetControlBoard<WriteHalf<SerialStream>> + GetMainElectronicsBoard + BottomCamIO,
131+
>(
132+
context: &Con,
133+
config: &Config,
134+
) {
135+
#[cfg(feature = "logging")]
136+
logln!("Starting static align");
137+
138+
let cb = context.get_control_board();
139+
let _ = cb.bno055_periodic_read(true).await;
140+
141+
let initial_yaw = loop {
142+
if let Some(initial_angle) = cb.responses().get_angles().await {
143+
break *initial_angle.yaw();
144+
} else {
145+
#[cfg(feature = "logging")]
146+
logln!("Failed to get initial angle");
147+
}
148+
};
149+
150+
let target_yaw = initial_yaw + config.yaw_angle;
151+
152+
let _ = cb
153+
.stability_2_speed_set(0.0, 0.0, 0.0, 0.0, initial_yaw, config.depth)
154+
.await;
155+
156+
sleep(Duration::from_secs(config.yaw_wait)).await;
157+
158+
let _ = cb
159+
.stability_2_speed_set(
160+
config.strafe_speed,
161+
config.forward_speed,
162+
0.0,
163+
0.0,
164+
target_yaw,
165+
config.depth,
166+
)
167+
.await;
168+
169+
sleep(Duration::from_secs(config.forward_duration)).await;
170+
171+
let _ = cb
172+
.stability_2_speed_set(0.0, 0.0, 0.0, 0.0, target_yaw, config.depth)
173+
.await;
174+
}

src/missions/spin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub fn spin<
3939
),
4040
OutputType::<()>::new(),
4141
),
42-
DelayAction::new(1.0),
42+
DelayAction::new(6.0),
4343
ActionWhile::new(TupleSecond::new(ActionConcurrent::new(
4444
act_nest!(
4545
ActionSequence::new,

0 commit comments

Comments
 (0)