@@ -134,6 +134,7 @@ def update(self, state : AllState):
134134 self .t_last = t
135135 dt = t - self .t_last
136136
137+ # Position in vehicle frame (Start (0,0) to (15,0))
137138 curr_x = vehicle .pose .x
138139 curr_y = vehicle .pose .y
139140 curr_v = vehicle .v
@@ -167,14 +168,26 @@ def update(self, state : AllState):
167168 - For distant crossing pedestrians, apply a gentle deceleration based on the
168169 perception-estimated pedestrian velocity.
169170 """
171+
170172 print ("#### YIELDING PLANNING ####" )
173+
174+ # Convert vehicle pose from vehicle to world coordinates
175+ # xyhead_demo: vehicle start at [4, 5], ped walks [15, 2]~[15, 10]
176+ # Is there relative pose of pedestrian or absolute pose of vehicle?
177+ abs_x = vehicle .pose .x + state .start_vehicle_pose .x
178+ abs_y = vehicle .pose .y + state .start_vehicle_pose .y
179+
180+ # TODO: Check if there are multiple pedestrians
171181 for n ,a in state .agents .items ():
172- print ("ped" , a .pose .x ,a .pose .y )
173- print ("ego" , curr_x ,curr_y )
182+ print ("ped" , a .pose .x , a .pose .y )
183+ print ("ego" , abs_x , abs_y )
184+
185+ # TODO: Make logic for smooth deceleration and re-acceleration
174186 # TEMPORARY: STOP WHEN WITHIN 10M OF PEDESTRIAN
175- if a .pose .x - curr_x < 10.0 and a .pose .x - curr_x > 0.0 :
187+ if a .pose .x - abs_x < 10.0 and a .pose .x - abs_x > 0.0 :
176188 print ("#### Yielding to" ,n )
177189 should_brake = True
190+
178191 break
179192
180193 # # UNCOMMENT TO BRAKE FOR ALL PEDESTRIANS
0 commit comments