@@ -43,7 +43,7 @@ pub async fn slalom<
4343
4444 let mut vision = VisionNormAngle :: < Con , Slalom , f64 > :: new (
4545 context,
46- Slalom :: from_color_profile ( color_profile) ,
46+ Slalom :: from_color_profile ( color_profile, config . area_bounds . clone ( ) ) ,
4747 ) ;
4848
4949 let initial_yaw = loop {
@@ -55,6 +55,12 @@ pub async fn slalom<
5555 }
5656 } ;
5757
58+ let _ = cb
59+ . stability_2_speed_set ( 0.0 , 0.0 , 0.0 , 0.0 , initial_yaw, config. depth )
60+ . await ;
61+
62+ sleep ( Duration :: from_secs ( 3 ) ) . await ;
63+
5864 let mut yaw_target = 0.0 ;
5965 let mut true_count = 0 ;
6066 let mut false_count = 0 ;
@@ -78,20 +84,6 @@ pub async fn slalom<
7884 logln ! ( "Starting slalom detection" ) ;
7985
8086 // Default left, right if flipped
81- let _ = cb
82- . stability_1_speed_set (
83- 0.0 ,
84- 0.0 ,
85- if flip {
86- config. yaw_speed
87- } else {
88- -config. yaw_speed
89- } ,
90- 0.0 ,
91- 0.0 ,
92- config. depth ,
93- )
94- . await ;
9587 ' detections: loop {
9688 #[ allow( unused_variables) ]
9789 let detections = vision. execute ( ) . await . unwrap_or_else ( |e| {
@@ -132,12 +124,30 @@ pub async fn slalom<
132124 logln ! ( "true_count: {true_count}/4" ) ;
133125 }
134126 } else {
135- correction = dbg ! ( - 0.2 * x) ;
127+ correction = dbg ! ( config . correction_factor * x) ;
136128 let _ = cb
137129 . stability_1_speed_set ( 0.0 , 0.0 , correction, 0.0 , 0.0 , config. depth )
138130 . await ;
139131 }
140132 } else {
133+ #[ cfg( feature = "logging" ) ]
134+ logln ! ( "SEARCHING" ) ;
135+
136+ let _ = cb
137+ . stability_1_speed_set (
138+ 0.0 ,
139+ 0.0 ,
140+ if flip {
141+ config. yaw_speed
142+ } else {
143+ -config. yaw_speed
144+ } ,
145+ 0.0 ,
146+ 0.0 ,
147+ config. depth ,
148+ )
149+ . await ;
150+
141151 false_count += 1 ;
142152 #[ cfg( feature = "logging" ) ]
143153 logln ! ( "NO DETECTIONS" ) ;
@@ -153,12 +163,28 @@ pub async fn slalom<
153163 #[ cfg( feature = "logging" ) ]
154164 logln ! ( "APPROACH" ) ;
155165
166+ let strafe_direction = if let Left = config. side { -1.0 } else { 1.0 } ;
167+
168+ let _ = cb
169+ . stability_2_speed_set (
170+ config. speed * strafe_direction,
171+ 0.0 ,
172+ 0.0 ,
173+ 0.0 ,
174+ yaw_target,
175+ config. depth ,
176+ )
177+ . await ;
178+
179+ sleep ( Duration :: from_secs ( config. strafe_duration as u64 ) ) . await ;
180+
156181 yaw_target = ( yaw_target
157182 + ( if let Left = config. side {
158183 config. yaw_adjustment
159184 } else {
160185 -config. yaw_adjustment
161186 } ) ) ;
187+
162188 let _ = cb
163189 . stability_2_speed_set ( 0.0 , 0.0 , 0.0 , 0.0 , yaw_target, config. depth )
164190 . await ;
@@ -167,8 +193,13 @@ pub async fn slalom<
167193
168194 // init_timer.execute().await;
169195
196+ // let _ = cb
197+ // .stability_1_speed_set(0.0, config.speed, 0.0, 0.0, 0.0, config.depth)
198+ // .await;
199+
200+ //
170201 let _ = cb
171- . stability_1_speed_set ( 0.0 , config. speed , 0.0 , 0.0 , 0.0 , config. depth )
202+ . stability_2_speed_set ( 0.0 , config. speed , 0.0 , 0.0 , yaw_target , config. depth )
172203 . await ;
173204
174205 // traversal_timer.execute().await;
0 commit comments