@@ -195,7 +195,7 @@ def waypoint_generate_relaxed(vehicle_state, cones, cone_idx):
195195 target_heading = car_heading
196196
197197 # ===== Parameters =====
198- u_turn_radius = 7 # Radius for U-turn
198+ u_turn_radius = 8 # Radius for U-turn
199199 offset = 2.0 # Offset for left/right pass
200200 lookahead_distance = 10.0 # Distance ahead for fixed point
201201 # ======================
@@ -221,6 +221,7 @@ def waypoint_generate_relaxed(vehicle_state, cones, cone_idx):
221221
222222 # Generate waypoints in a smooth semi-circular pattern on the RIGHT side
223223 flex_wps_list = []
224+ fixed_wp_list = []
224225
225226 # Create a semi-circular arc from 0 to π
226227 # But negate perpendicular_vector to go to the right side
@@ -239,6 +240,7 @@ def waypoint_generate_relaxed(vehicle_state, cones, cone_idx):
239240
240241 # Fixed waypoint: behind the cone after U-turn (also on right side)
241242 fixed_wp = cone + u_turn_radius * perpendicular_vector
243+ fixed_wp_list = [fixed_wp ]
242244
243245 target_heading = target_heading + np .pi
244246
@@ -252,6 +254,7 @@ def waypoint_generate_relaxed(vehicle_state, cones, cone_idx):
252254 # Fixed waypoint: forward after passing the cone
253255 # fixed_wp = flex_wp + heading_vector * lookahead_distance - offset * perpendicular_vector * 2
254256 fixed_wp = flex_wp1 + heading_vector * lookahead_distance - offset * perpendicular_vector
257+ fixed_wp_list = [fixed_wp ]
255258
256259 elif scenario == 'right' :
257260 cone = np .array (cone_position )
@@ -263,7 +266,7 @@ def waypoint_generate_relaxed(vehicle_state, cones, cone_idx):
263266 # Fixed waypoint: forward after passing the cone
264267 # fixed_wp = flex_wp + heading_vector * lookahead_distance + offset * perpendicular_vector * 2
265268 fixed_wp = flex_wp1 + heading_vector * lookahead_distance + offset * perpendicular_vector
266-
269+ fixed_wp_list = [ fixed_wp ]
267270 # TODO: move to a different setting instead of as a scenario
268271 elif scenario == '90turn' :
269272 turn_vector = np .array ([- np .sin (car_heading + np .pi / 6 ), np .cos (car_heading + np .pi / 6 )])
@@ -277,6 +280,7 @@ def waypoint_generate_relaxed(vehicle_state, cones, cone_idx):
277280
278281 final_flex_wp = cone + 1.0 * perpendicular_vector + heading_vector * 1.0
279282 fixed_wp = cone - turn_vector * 2.5 + heading_vector * 0.0
283+ fixed_wp_list = [fixed_wp ]
280284
281285 cone_direction = (final_flex_wp - car_position ) / np .linalg .norm (final_flex_wp - car_position )
282286 for i in range (steps - 2 ):
@@ -288,10 +292,11 @@ def waypoint_generate_relaxed(vehicle_state, cones, cone_idx):
288292 flex_wp = cone + 1.0 * perpendicular_vector + heading_vector * 1.0
289293 fixed_wp = cone - turn_vector * 2.5 + heading_vector * 0.0
290294 flex_wps_list = [flex_wp ]
291-
295+ fixed_wp_list = [ fixed_wp ]
292296 else :
293297 flex_wps_list = None
294298 fixed_wp = None
299+ fixed_wp_list .append = None
295300
296301 target_heading = (target_heading + np .pi ) % (2 * np .pi ) - np .pi
297302 current_heading = (current_heading + np .pi ) % (2 * np .pi ) - np .pi
@@ -314,7 +319,7 @@ def waypoint_generate_relaxed(vehicle_state, cones, cone_idx):
314319 # plt.grid(True)
315320 # plt.show()
316321
317- return scenario , flex_wps_list , fixed_wp , target_heading
322+ return scenario , flex_wps_list , fixed_wp , target_heading , fixed_wp_list
318323
319324def velocity_profiling (path , acceleration , deceleration , max_speed , current_speed , lateral_acc_limit ):
320325 """
@@ -577,7 +582,7 @@ def trajectory_generation_dynamics(init_state, final_state, N=30, Lr=1.5,
577582 eps_min = - 0.2 , eps_max = 0.2 ,
578583 v_min = 2.0 , v_max = 11.0 ,
579584 T_min = 0.5 , T_max = 1000.0 ,
580- waypoints = None , waypoint_penalty_weight = 1 , waypoint_headings = None ):
585+ waypoints = None , waypoint_penalty_weight = 10 , waypoint_headings = None ):
581586 """
582587 Generate a dynamically feasible trajectory between init_state and final_state
583588 using curvature-based vehicle dynamics and nonlinear optimization.
@@ -708,7 +713,7 @@ def waypoint_penalty(p):
708713
709714 a_vals = np .zeros (N - 1 )
710715 eps_vals = np .zeros (N - 1 )
711- T_guess = 10 .0
716+ T_guess = 60 .0
712717
713718 p0 = np .concatenate ([x_vals [1 :], y_vals [1 :], psi_vals [1 :], c_vals [1 :], v_vals [1 :],
714719 a_vals , eps_vals , [T_guess ]])
@@ -942,7 +947,7 @@ def waypoint_search_optimization(vehicle_state, cones, search_attempts=3):
942947 print (f"Checking waypoint: { flex_wp } , Fixed: { fixed_wp } , Feasible: { feasible } , Collisions: { collisions } " )
943948 if feasible :
944949 valid_flex_wps .append (flex_wp )
945- valid_fixed_wps . append ( fixed_wp )
950+ valid_fixed_wps = [ fixed_wp ]
946951 current_state ['position' ] = list (fixed_wp )
947952 break
948953 except :
@@ -1121,14 +1126,18 @@ def plan_full_slalom_trajectory(vehicle_state, cones):
11211126 current_pos = np .array (vehicle_state ['position' ])
11221127 current_heading = vehicle_state ['heading' ]
11231128 waypoint_all = []
1129+ fixed_wp_all = []
11241130
11251131 for cone_idx , cone in enumerate (cones ):
11261132 # scenario, flex_wps, fixed_wp, target_heading = waypoint_generate(vehicle_state, cones, cone_idx)
1127- scenario , flex_wps , fixed_wp , target_heading = waypoint_generate_relaxed (vehicle_state , cones , cone_idx )
1133+ scenario , flex_wps , fixed_wp , target_heading , fixed_wp_list = waypoint_generate_relaxed (vehicle_state , cones , cone_idx )
11281134 if not flex_wps or fixed_wp is None :
11291135 continue
11301136 # flex_wp = flex_wps[0]
11311137 waypoint_all .extend (flex_wps )
1138+ fixed_wp_all .extend (fixed_wp_list )
1139+ print ("flex: " + str (waypoint_all ))
1140+ print ("flex: " + str (fixed_wp_all ))
11321141 current_heading = (current_heading + np .pi ) % (2 * np .pi ) - np .pi
11331142
11341143 init_state = {
@@ -1171,6 +1180,11 @@ def plan_full_slalom_trajectory(vehicle_state, cones):
11711180 plt .plot (wp [0 ], wp [1 ], 'ro' ) # Plot all waypoints in red
11721181 plt .text (wp [0 ], wp [1 ], f'wp{ i } ' , fontsize = 9 )
11731182
1183+ # plot fixed waypoints
1184+ for i , wp in enumerate (fixed_wp_all ):
1185+ plt .plot (wp [0 ], wp [1 ], 'ks' ) # Plot all waypoints in red
1186+ plt .text (wp [0 ], wp [1 ], f'fx_wp{ i } ' , fontsize = 9 )
1187+
11741188 plt .title ('4-Cone Full Course Trajectory' )
11751189 plt .xlabel ('X' )
11761190 plt .ylabel ('Y' )
0 commit comments