@@ -4,6 +4,7 @@ use super::{
44 DifferentialGenerationTransformer , FeatureLockedTransformer , GenerationContext ,
55 SwerveGenerationTransformer ,
66} ;
7+ use trajoptlib:: Translation2d ;
78
89fn fix_scope ( idx : usize , removed_idxs : & [ usize ] ) -> usize {
910 let mut to_subtract: usize = 0 ;
@@ -108,8 +109,10 @@ impl SwerveGenerationTransformer for ConstraintSetter {
108109 tolerance,
109110 flip,
110111 } => match to_opt {
111- None => generator. wpt_point_at ( from, x, y, tolerance, flip) ,
112- Some ( to) => generator. sgmt_point_at ( from, to, x, y, tolerance, flip) ,
112+ None => generator. wpt_point_at ( from, Translation2d { x, y } , tolerance, flip) ,
113+ Some ( to) => {
114+ generator. sgmt_point_at ( from, to, Translation2d { x, y } , tolerance, flip)
115+ }
113116 } ,
114117 ConstraintData :: MaxVelocity { max } => match to_opt {
115118 None => generator. wpt_linear_velocity_max_magnitude ( from, max) ,
@@ -130,15 +133,19 @@ impl SwerveGenerationTransformer for ConstraintSetter {
130133 }
131134 }
132135 ConstraintData :: KeepInCircle { x, y, r } => match to_opt {
133- None => generator. wpt_keep_in_circle ( from, x, y, r) ,
134- Some ( to) => generator. sgmt_keep_in_circle ( from, to, x, y, r) ,
136+ None => generator. wpt_keep_in_circle ( from, Translation2d { x, y } , r) ,
137+ Some ( to) => generator. sgmt_keep_in_circle ( from, to, Translation2d { x, y } , r) ,
135138 } ,
136139 ConstraintData :: KeepInRectangle { x, y, w, h } => {
137- let xs = vec ! [ x, x + w, x + w, x] ;
138- let ys = vec ! [ y, y, y + h, y + h] ;
140+ let field_points = vec ! [
141+ Translation2d { x, y } ,
142+ Translation2d { x: x + w, y } ,
143+ Translation2d { x: x + w, y: y + h } ,
144+ Translation2d { x, y: y + h } ,
145+ ] ;
139146 match to_opt {
140- None => generator. wpt_keep_in_polygon ( from, xs , ys ) ,
141- Some ( to) => generator. sgmt_keep_in_polygon ( from, to, xs , ys ) ,
147+ None => generator. wpt_keep_in_polygon ( from, field_points ) ,
148+ Some ( to) => generator. sgmt_keep_in_polygon ( from, to, field_points ) ,
142149 }
143150 }
144151 ConstraintData :: KeepInLane { tolerance } => {
@@ -147,13 +154,23 @@ impl SwerveGenerationTransformer for ConstraintSetter {
147154 && let Some ( wpt_to) = self . waypoint_idx . get ( idx_to)
148155 {
149156 generator. sgmt_keep_in_lane (
150- from, idx_to, wpt_from. x , wpt_from. y , wpt_to. x , wpt_to. y , tolerance,
157+ from,
158+ idx_to,
159+ Translation2d {
160+ x : wpt_from. x ,
161+ y : wpt_from. y ,
162+ } ,
163+ Translation2d {
164+ x : wpt_to. x ,
165+ y : wpt_to. y ,
166+ } ,
167+ tolerance,
151168 ) ;
152169 }
153170 }
154171 ConstraintData :: KeepOutCircle { x, y, r } => match to_opt {
155- None => generator. wpt_keep_out_circle ( from, x, y, r) ,
156- Some ( to) => generator. sgmt_keep_out_circle ( from, to, x, y, r) ,
172+ None => generator. wpt_keep_out_circle ( from, Translation2d { x, y } , r) ,
173+ Some ( to) => generator. sgmt_keep_out_circle ( from, to, Translation2d { x, y } , r) ,
157174 } ,
158175 } ;
159176 }
@@ -177,7 +194,7 @@ impl DifferentialGenerationTransformer for ConstraintSetter {
177194 flip,
178195 } => {
179196 if to_opt. is_none ( ) {
180- generator. wpt_point_at ( from, x, y, tolerance, flip)
197+ generator. wpt_point_at ( from, Translation2d { x, y } , tolerance, flip)
181198 }
182199 }
183200 ConstraintData :: MaxVelocity { max } => match to_opt {
@@ -199,15 +216,19 @@ impl DifferentialGenerationTransformer for ConstraintSetter {
199216 }
200217 }
201218 ConstraintData :: KeepInCircle { x, y, r } => match to_opt {
202- None => generator. wpt_keep_in_circle ( from, x, y, r) ,
203- Some ( to) => generator. sgmt_keep_in_circle ( from, to, x, y, r) ,
219+ None => generator. wpt_keep_in_circle ( from, Translation2d { x, y } , r) ,
220+ Some ( to) => generator. sgmt_keep_in_circle ( from, to, Translation2d { x, y } , r) ,
204221 } ,
205222 ConstraintData :: KeepInRectangle { x, y, w, h } => {
206- let xs = vec ! [ x, x + w, x + w, x] ;
207- let ys = vec ! [ y, y, y + h, y + h] ;
223+ let field_points = vec ! [
224+ Translation2d { x, y } ,
225+ Translation2d { x: x + w, y } ,
226+ Translation2d { x: x + w, y: y + h } ,
227+ Translation2d { x, y: y + h } ,
228+ ] ;
208229 match to_opt {
209- None => generator. wpt_keep_in_polygon ( from, xs , ys ) ,
210- Some ( to) => generator. sgmt_keep_in_polygon ( from, to, xs , ys ) ,
230+ None => generator. wpt_keep_in_polygon ( from, field_points ) ,
231+ Some ( to) => generator. sgmt_keep_in_polygon ( from, to, field_points ) ,
211232 }
212233 }
213234 ConstraintData :: KeepInLane { tolerance } => {
@@ -216,13 +237,23 @@ impl DifferentialGenerationTransformer for ConstraintSetter {
216237 && let Some ( wpt_to) = self . waypoint_idx . get ( idx_to)
217238 {
218239 generator. sgmt_keep_in_lane (
219- from, idx_to, wpt_from. x , wpt_from. y , wpt_to. x , wpt_to. y , tolerance,
240+ from,
241+ idx_to,
242+ Translation2d {
243+ x : wpt_from. x ,
244+ y : wpt_from. y ,
245+ } ,
246+ Translation2d {
247+ x : wpt_to. x ,
248+ y : wpt_to. y ,
249+ } ,
250+ tolerance,
220251 ) ;
221252 }
222253 }
223254 ConstraintData :: KeepOutCircle { x, y, r } => match to_opt {
224- None => generator. wpt_keep_out_circle ( from, x, y, r) ,
225- Some ( to) => generator. sgmt_keep_out_circle ( from, to, x, y, r) ,
255+ None => generator. wpt_keep_out_circle ( from, Translation2d { x, y } , r) ,
256+ Some ( to) => generator. sgmt_keep_out_circle ( from, to, Translation2d { x, y } , r) ,
226257 } ,
227258 } ;
228259 }
0 commit comments