Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
9e59630
path_cv in progress
SarangaR Mar 19, 2025
9a25b34
Complete pathCV implementation (path detection using pure cv and cont…
SarangaR Mar 22, 2025
d8cb1fd
fix: remove nix flakes
SarangaR Mar 22, 2025
68fc221
fix: update gitignore
SarangaR Mar 22, 2025
343b26f
feat: changes from March 29th, 2025 pool test
Cowboylaserkittenjetshark Mar 30, 2025
634edcc
feat: path adjustments from pooltest
Cowboylaserkittenjetshark Apr 5, 2025
0a74eaa
feat(WIP): add feature to publish RTSP stream annotated with cv detec…
Cowboylaserkittenjetshark Apr 10, 2025
0c3e237
fix(WIP): await bottom camera annotation
Cowboylaserkittenjetshark Apr 10, 2025
2279eea
feat: implement detection annotated streams for all detectors
Cowboylaserkittenjetshark Apr 10, 2025
bec0667
refactor: rename Get*CamMat to *CamIO to reflect addition of annotate…
Cowboylaserkittenjetshark Apr 10, 2025
eb7dab7
feat: use hardware encoding for annotated streams
Cowboylaserkittenjetshark Apr 10, 2025
df84e32
feat: changes from April 12th, 2025 pool test
Cowboylaserkittenjetshark Apr 15, 2025
a705f10
feat: procedural path align implementation
Cowboylaserkittenjetshark May 8, 2025
058e532
refactor: clean up path align
Cowboylaserkittenjetshark May 8, 2025
34407be
feat (path align): use results from sassist commands
Cowboylaserkittenjetshark May 8, 2025
5b1e48f
new path cv impl
SarangaR May 17, 2025
45b0e1a
feat: working path align
Cowboylaserkittenjetshark May 17, 2025
a1dd897
fix (path align): skip sending sassist when nothing is detected
Cowboylaserkittenjetshark May 17, 2025
7bab6f6
fix (WIP): yaw & roll pid tune
Cowboylaserkittenjetshark May 17, 2025
2d9c37a
fix: tune gate to not skip path (also changed depths)
Cowboylaserkittenjetshark May 17, 2025
a53b96d
05-17-2025 pool test; gate -> path tuning
SarangaR Jun 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ required-features = ["graphing"]
[features]
default = []
logging = []
annotated_streams = []
#unblocked_logging = ["logging"]
cuda = ["dep:cc"]
cuda_f16 = ["cuda"]
Expand Down
2 changes: 1 addition & 1 deletion jetson/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ async fn main() -> Result<()> {
"build".to_string(),
"--release".to_string(),
"--features".to_string(),
"logging".to_string(),
"logging,annotated_streams".to_string(),
];
}

Expand Down
2 changes: 2 additions & 0 deletions playstreams.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
mpv rtsp://192.168.2.5:8554/front.mp4 --title=Front --no-cache --untimed --no-demuxer-thread --vd-lavc-threads=1 --profile=low-latency --no-correct-pts --osc=no &
mpv rtsp://192.168.2.5:8554/bottom.mp4 --title=Front --no-cache --untimed --no-demuxer-thread --vd-lavc-threads=1 --profile=low-latency --no-correct-pts --osc=no &
11 changes: 7 additions & 4 deletions src/comms/control_board/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ fn stab_2_drift() -> f32 {
loop {
{
let mut drift_val_inner = drift_val_clone.lock().unwrap();
*drift_val_inner += 0.015;
// *drift_val_inner += 0.015;
}
sleep(Duration::from_secs(1)).await
}
Expand Down Expand Up @@ -155,9 +155,9 @@ impl<T: 'static + AsyncWriteExt + Unpin + Send> ControlBoard<T> {
async fn stab_tune(&self) -> Result<()> {
self.stability_assist_pid_tune('X', 0.8, 0.0, 0.0, 0.6, false)
.await?;
self.stability_assist_pid_tune('Y', 0.15, 0.0, 0.0, 0.1, false)
self.stability_assist_pid_tune('Y', 2.0, 0.0, 0.0, 0.1, false)
.await?;
self.stability_assist_pid_tune('Z', 1.6, 1e-6, 0.0, 0.8, false)
self.stability_assist_pid_tune('Z', 10.0, 0.0, 0.0, 1.0, false)
.await?;
self.stability_assist_pid_tune('D', 1.5, 0.0, 0.0, 1.0, false)
.await
Expand Down Expand Up @@ -341,7 +341,10 @@ impl<T: AsyncWrite + Unpin> ControlBoard<T> {
y,
target_pitch,
target_roll,
(target_yaw + stab_2_drift()),
(
target_yaw
// + stab_2_drift()
),
target_depth,
]
.iter()
Expand Down
4 changes: 2 additions & 2 deletions src/comms/control_board/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ impl ResponseMap {
} else if message_body.get(0..7) == Some(&BNO055D) {
static mut PREV_YAW_PRINT: SystemTime = SystemTime::UNIX_EPOCH;
let new_status = message_body[7..].try_into().unwrap();
/*

let now = SystemTime::now();
unsafe {
if now.duration_since(PREV_YAW_PRINT).unwrap() > Duration::from_secs(1) {
Expand All @@ -140,7 +140,7 @@ impl ResponseMap {
PREV_YAW_PRINT = SystemTime::now();
}
}
*/


*bno055_status.write().await = Some(new_status);
} else if message_body.get(0..7) == Some(&MS5837D) {
Expand Down
19 changes: 15 additions & 4 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,13 @@ use sw8s_rust_lib::{
buoy_circle_sequence, buoy_circle_sequence_blind, buoy_circle_sequence_model,
},
coinflip::coinflip,
example::initial_descent,
example::{initial_descent, pid_test},
fancy_octagon::fancy_octagon,
fire_torpedo::{FireLeftTorpedo, FireRightTorpedo},
gate::{gate_run_coinflip, gate_run_complex, gate_run_naive, gate_run_testing},
meb::WaitArm,
octagon::octagon,
path_align::path_align,
path_align::path_align_procedural,
reset_torpedo::ResetTorpedo,
spin::spin,
vision::PIPELINE_KILL,
Expand Down Expand Up @@ -374,14 +374,13 @@ async fn run_mission(mission: &str) -> Result<()> {
Ok(())
}
"path_align" => {
let _ = path_align(&FullActionContext::new(
let _ = path_align_procedural(&FullActionContext::new(
control_board().await,
meb().await,
front_cam().await,
bottom_cam().await,
gate_target().await,
))
.execute()
.await;
Ok(())
}
Expand Down Expand Up @@ -411,6 +410,18 @@ async fn run_mission(mission: &str) -> Result<()> {
.await;
Ok(())
}
"pid_test" => {
let _ = pid_test(&FullActionContext::new(
control_board().await,
meb().await,
front_cam().await,
bottom_cam().await,
gate_target().await,
))
.execute()
.await;
Ok(())
}
"octagon" => {
let _ = octagon(static_context().await).execute().await;
Ok(())
Expand Down
33 changes: 27 additions & 6 deletions src/missions/action_context.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use core::fmt::Debug;
use opencv::core::Mat;
use opencv::mod_prelude::ToInputArray;
use tokio::io::{AsyncWriteExt, WriteHalf};
use tokio::sync::RwLock;
use tokio_serial::SerialStream;
Expand Down Expand Up @@ -28,8 +29,10 @@ pub trait GetMainElectronicsBoard: Send + Sync {
* Inherit this trait if you have a front camera
*/
#[allow(async_fn_in_trait)]
pub trait GetFrontCamMat {
pub trait FrontCamIO {
fn get_front_camera_mat(&self) -> impl std::future::Future<Output = Mat> + Send;
#[cfg(feature = "annotated_streams")]
async fn annotate_front_camera(&self, image: &impl ToInputArray);
async fn get_desired_buoy_gate(&self) -> Target;
async fn set_desired_buoy_gate(&mut self, value: Target) -> &Self;
}
Expand All @@ -38,8 +41,10 @@ pub trait GetFrontCamMat {
* Inherit this trait if you have a bottom camera
*/
#[allow(async_fn_in_trait)]
pub trait GetBottomCamMat {
pub trait BottomCamIO {
async fn get_bottom_camera_mat(&self) -> Mat;
#[cfg(feature = "annotated_streams")]
async fn annotate_bottom_camera(&self, image: &impl ToInputArray);
}

/*
Expand Down Expand Up @@ -93,10 +98,14 @@ impl GetMainElectronicsBoard for FullActionContext<'_, WriteHalf<SerialStream>>
}
}

impl<T: AsyncWriteExt + Unpin + Send> GetFrontCamMat for FullActionContext<'_, T> {
impl<T: AsyncWriteExt + Unpin + Send> FrontCamIO for FullActionContext<'_, T> {
async fn get_front_camera_mat(&self) -> Mat {
self.front_cam.get_mat().await
}
#[cfg(feature = "annotated_streams")]
async fn annotate_front_camera(&self, image: &impl ToInputArray) {
self.front_cam.push_annotated_frame(image);
}
async fn get_desired_buoy_gate(&self) -> Target {
let res = self.desired_buoy_target.read().await;
(*res).clone()
Expand All @@ -107,10 +116,14 @@ impl<T: AsyncWriteExt + Unpin + Send> GetFrontCamMat for FullActionContext<'_, T
}
}

impl<T: AsyncWriteExt + Unpin + Send> GetBottomCamMat for FullActionContext<'_, T> {
impl<T: AsyncWriteExt + Unpin + Send> BottomCamIO for FullActionContext<'_, T> {
async fn get_bottom_camera_mat(&self) -> Mat {
self.bottom_cam.get_mat().await
}
#[cfg(feature = "annotated_streams")]
async fn annotate_bottom_camera(&self, image: &impl ToInputArray) {
self.bottom_cam.push_annotated_frame(image);
}
}

impl GetControlBoard<WriteHalf<SerialStream>> for EmptyActionContext {
Expand All @@ -125,10 +138,14 @@ impl GetMainElectronicsBoard for EmptyActionContext {
}
}

impl GetFrontCamMat for EmptyActionContext {
impl FrontCamIO for EmptyActionContext {
async fn get_front_camera_mat(&self) -> Mat {
todo!()
}
#[cfg(feature = "annotated_streams")]
async fn annotate_front_camera(&self, image: &impl ToInputArray) {
todo!();
}
async fn get_desired_buoy_gate(&self) -> Target {
todo!()
}
Expand All @@ -137,8 +154,12 @@ impl GetFrontCamMat for EmptyActionContext {
}
}

impl GetBottomCamMat for EmptyActionContext {
impl BottomCamIO for EmptyActionContext {
async fn get_bottom_camera_mat(&self) -> Mat {
todo!()
}
#[cfg(feature = "annotated_streams")]
async fn annotate_bottom_camera(&self, image: &impl ToInputArray) {
todo!();
}
}
6 changes: 3 additions & 3 deletions src/missions/align_buoy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ use crate::{

use super::{
action::ActionExec,
action_context::{GetControlBoard, GetFrontCamMat, GetMainElectronicsBoard},
action_context::{GetControlBoard, FrontCamIO, GetMainElectronicsBoard},
};

pub fn buoy_align<
Con: Send
+ Sync
+ GetControlBoard<WriteHalf<SerialStream>>
+ GetMainElectronicsBoard
+ GetFrontCamMat
+ FrontCamIO
+ Unpin,
>(
context: &'static Con,
Expand Down Expand Up @@ -149,7 +149,7 @@ pub fn buoy_align_shot<
+ Sync
+ GetControlBoard<WriteHalf<SerialStream>>
+ GetMainElectronicsBoard
+ GetFrontCamMat
+ FrontCamIO
+ Unpin,
>(
context: &'static Con,
Expand Down
8 changes: 4 additions & 4 deletions src/missions/buoy_hit.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use super::{
action::{Action, ActionExec, ActionSequence, ActionWhile},
action_context::{GetControlBoard, GetFrontCamMat, GetMainElectronicsBoard},
action_context::{GetControlBoard, FrontCamIO, GetMainElectronicsBoard},
basic::DelayAction,
movement::{StraightMovement, ZeroMovement},
};
Expand Down Expand Up @@ -54,7 +54,7 @@ impl<T> Action for FindBuoy<'_, T> {}

impl<T> ActionExec<Result<()>> for FindBuoy<'_, T>
where
T: GetControlBoard<WriteHalf<SerialStream>> + GetFrontCamMat + Sync + Unpin,
T: GetControlBoard<WriteHalf<SerialStream>> + FrontCamIO + Sync + Unpin,
{
async fn execute(&mut self) -> Result<()> {
let camera_aquisition = self.context.get_front_camera_mat();
Expand All @@ -75,7 +75,7 @@ where
}
impl<T> ActionExec<Result<()>> for DriveToBuoyVision<'_, T>
where
T: GetControlBoard<WriteHalf<SerialStream>> + GetFrontCamMat + Sync + Unpin,
T: GetControlBoard<WriteHalf<SerialStream>> + FrontCamIO + Sync + Unpin,
{
async fn execute(&mut self) -> Result<()> {
let camera_aquisition = self.context.get_front_camera_mat();
Expand Down Expand Up @@ -121,7 +121,7 @@ pub fn buoy_collision_sequence<
+ Sync
+ GetControlBoard<WriteHalf<SerialStream>>
+ GetMainElectronicsBoard
+ GetFrontCamMat
+ FrontCamIO
+ Unpin,
T: Send + Sync,
>(
Expand Down
8 changes: 4 additions & 4 deletions src/missions/circle_buoy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ use crate::{

use super::{
action::{ActionExec, ActionSequence},
action_context::{GetControlBoard, GetFrontCamMat, GetMainElectronicsBoard},
action_context::{GetControlBoard, FrontCamIO, GetMainElectronicsBoard},
basic::DelayAction,
movement::ZeroMovement,
};
Expand All @@ -35,7 +35,7 @@ pub fn buoy_circle_sequence<
+ Sync
+ GetControlBoard<WriteHalf<SerialStream>>
+ GetMainElectronicsBoard
+ GetFrontCamMat
+ FrontCamIO
+ Unpin,
>(
context: &Con,
Expand Down Expand Up @@ -95,7 +95,7 @@ pub fn buoy_circle_sequence_model<
+ Sync
+ GetControlBoard<WriteHalf<SerialStream>>
+ GetMainElectronicsBoard
+ GetFrontCamMat
+ FrontCamIO
+ Unpin,
>(
context: &'static Con,
Expand Down Expand Up @@ -144,7 +144,7 @@ pub fn buoy_circle_sequence_blind<
+ Sync
+ GetControlBoard<WriteHalf<SerialStream>>
+ GetMainElectronicsBoard
+ GetFrontCamMat
+ FrontCamIO
+ Unpin,
>(
context: &'static Con,
Expand Down
12 changes: 4 additions & 8 deletions src/missions/coinflip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use super::{
wrap_action, ActionChain, ActionConcurrent, ActionExec, ActionSequence, ActionWhile,
FirstValid,
},
action_context::{GetControlBoard, GetFrontCamMat, GetMainElectronicsBoard},
action_context::{FrontCamIO, GetControlBoard, GetMainElectronicsBoard},
basic::DelayAction,
comms::StartBno055,
extra::{CountTrue, OutputType},
Expand All @@ -29,21 +29,17 @@ use super::{
};

pub fn coinflip<
Con: Send
+ Sync
+ GetControlBoard<WriteHalf<SerialStream>>
+ GetMainElectronicsBoard
+ GetFrontCamMat,
Con: Send + Sync + GetControlBoard<WriteHalf<SerialStream>> + GetMainElectronicsBoard + FrontCamIO,
>(
context: &Con,
) -> impl ActionExec<()> + '_ {
const TRUE_COUNT: u32 = 4;
const DELAY_TIME: f32 = 3.0;

const DEPTH: f32 = -1.15;
const DEPTH: f32 = -1.6;
const ALIGN_X_SPEED: f32 = 0.0;
const ALIGN_Y_SPEED: f32 = 0.0;
const ALIGN_YAW_SPEED: f32 = -6.0;
const ALIGN_YAW_SPEED: f32 = -3.0;
const ALIGN_YAW_CORRECTION_SPEED: f32 = 0.0;

act_nest!(
Expand Down
Loading
Loading