Skip to content

Commit a28b1c0

Browse files
wip: post aug 12th
1 parent f26dd5b commit a28b1c0

4 files changed

Lines changed: 37 additions & 27 deletions

File tree

src/comms/control_board/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ impl<T: 'static + AsyncWriteExt + Unpin + Send> ControlBoard<T> {
129129
.await?;
130130
self.stability_assist_pid_tune('Y', 2.0, 0.0, 0.0, 0.1, false)
131131
.await?;
132-
self.stability_assist_pid_tune('Z', 10.0, 0.0, 0.0, 1.0, false)
132+
self.stability_assist_pid_tune('Z', 6.0, 0.0, 0.0, 1.0, false)
133133
.await?;
134134
self.stability_assist_pid_tune('D', 1.5, 0.0, 0.0, 1.0, false)
135135
.await

src/missions/coinflip.rs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
use itertools::Itertools;
22
use tokio::io::WriteHalf;
3+
use tokio::time::{sleep, Duration};
34
use tokio_serial::SerialStream;
45

56
use crate::{
@@ -56,7 +57,7 @@ pub async fn coinflip_procedural<
5657
let DEPTH = config.depth;
5758

5859
let _ = cb
59-
.stability_2_speed_set(0.0, 0.0, 0.0, 0.0, initial_yaw, DEPTH)
60+
.stability_1_speed_set(0.0, 0.0, config.angle_correction, 0.0, 0.0, DEPTH)
6061
.await;
6162

6263
let mut true_count = 0;
@@ -72,10 +73,10 @@ pub async fn coinflip_procedural<
7273
vec![]
7374
});
7475

75-
let gate = detections
76-
.iter()
77-
.filter(|d| matches!(d.class().identifier, Target::Gate))
78-
.collect_vec();
76+
// let gate = detections
77+
// .iter()
78+
// .filter(|d| matches!(d.class().identifier, Target::Gate))
79+
// .collect_vec();
7980
let shark = detections
8081
.iter()
8182
.filter(|d| matches!(d.class().identifier, Target::Shark))
@@ -85,19 +86,27 @@ pub async fn coinflip_procedural<
8586
.filter(|d| matches!(d.class().identifier, Target::Sawfish))
8687
.collect_vec();
8788

88-
if (gate.len() > 0 || shark.len() > 0 || sawfish.len() > 0) {
89+
let leftPole = detections
90+
.iter()
91+
.filter(|d| matches!(d.class().identifier, Target::LeftPole))
92+
.collect_vec();
93+
94+
let rightPole = detections
95+
.iter()
96+
.filter(|d| matches!(d.class().identifier, Target::RightPole))
97+
.collect_vec();
98+
99+
if (shark.len() > 0 || sawfish.len() > 0 || !leftPole.is_empty()) {
89100
if true_count > max_true_count {
90101
let _ = cb
91-
.stability_2_speed_set(0.0, 0.0, 0.0, 0.0, initial_yaw, DEPTH)
102+
.stability_1_speed_set(0.0, 0.0, 0.0, 0.0, 0.0, DEPTH)
92103
.await;
104+
break;
93105
} else {
94106
true_count += 1;
95107
}
96108
} else {
97-
target_yaw += angle_correction;
98-
let _ = cb
99-
.stability_2_speed_set(0.0, 0.0, 0.0, 0.0, target_yaw, DEPTH)
100-
.await;
109+
true_count = 0;
101110
}
102111
}
103112
}

src/missions/gate.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -77,24 +77,24 @@ pub async fn gate_run_procedural<
7777
vec![]
7878
});
7979

80-
/* let pole = detections
81-
.iter()
82-
.filter(|d| matches!(d.class().identifier, Target::Pole))
83-
.collect_vec(); */
80+
let rightPole = detections
81+
.iter()
82+
.filter(|d| matches!(d.class().identifier, Target::RightPole))
83+
.collect_vec();
8484

8585
/* let middle = detections
8686
.iter()
8787
.filter(|d| matches!(d.class().identifier, Target::Middle))
8888
.collect_vec(); */
8989

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

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

100100
let mut traversal_timer = DelayAction::new(9.5); // forward duration in second
@@ -149,7 +149,7 @@ pub async fn gate_run_procedural<
149149
logln!("LEFT: Missing Features, Fallback");
150150

151151
let correction = -0.2;
152-
let fwd = 0.0;
152+
let fwd = 0.05;
153153

154154
let _ = cb
155155
.stability_2_speed_set(correction, fwd, 0.0, 0.0, initial_yaw, config.depth)
@@ -161,18 +161,18 @@ pub async fn gate_run_procedural<
161161
Side::Right => {
162162
if !sawfish.is_empty() {
163163
// Center on average x of blue
164-
let avg_x = sawfish
164+
let avg_x = (sawfish
165165
.iter()
166166
.map(|d| *d.position().x() as f32)
167167
.sum::<f32>()
168-
/ sawfish.len() as f32;
168+
/ sawfish.len() as f32);
169169

170170
#[cfg(feature = "logging")]
171171
logln!("SAWFISH AVG X: {}", avg_x);
172172

173173
if avg_x.abs() > TOLERANCE {
174174
let correction = 0.4 * avg_x;
175-
let fwd = 0.0;
175+
let fwd = 0.05;
176176

177177
let _ = cb
178178
.stability_2_speed_set(
@@ -210,7 +210,7 @@ pub async fn gate_run_procedural<
210210
logln!("RIGHT: Missing Features, Fallback");
211211

212212
let correction = 0.2;
213-
let fwd = 0.0;
213+
let fwd = 0.05;
214214

215215
let _ = cb
216216
.stability_2_speed_set(correction, fwd, 0.0, 0.0, initial_yaw, config.depth)

src/video_source/appsink.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,11 @@ impl Camera {
4848
let rtsp_string = "h264. ! queue ! h264parse config_interval=-1 ! video/x-h264,stream-format=byte-stream,alignment=au ! rtspclientsink location=rtsp://127.0.0.1:8554/".to_string()
4949
+ camera_name + ".mp4 ";
5050

51+
// unsharp luma-radius-2.0 luma-amount=2.5 chroma-radius=2.0 chroma-amount=2.5 !
5152
let capture_string =
5253
pipeline_head(camera_path, camera_dimensions.0, camera_dimensions.1, 30)
5354
+ " ! jpegdec ! tee name=raw "
54-
+ "raw. ! queue ! videoconvert ! videobalance brightness=0.0 ! appsink "
55+
+ "raw. ! queue ! videoconvert ! videobalance brightness=-0.6 ! appsink "
5556
+ "raw. ! queue ! videoconvert ! "
5657
+ &h264_enc_pipeline(2048000)
5758
+ " ! tee name=h264 "
@@ -151,7 +152,7 @@ fn pipeline_head(device_name: &str, width: u32, height: u32, framerate: u32) ->
151152
return format!("mfvideosrc device-index={device_name} ! image/jpeg, width={width}, height={height}, framerate={framerate}/1");
152153

153154
#[cfg(not(target_os = "windows"))]
154-
return format!("v4l2src device={device_name} exposure=50 ! image/jpeg, width={width}, height={height}, framerate={framerate}/1");
155+
return format!("v4l2src device={device_name} exposure=25 ! image/jpeg, width={width}, height={height}, framerate={framerate}/1");
155156
}
156157

157158
fn h264_enc_pipeline(bitrate: u32) -> String {

0 commit comments

Comments
 (0)