@@ -216,7 +216,7 @@ def run(self, is_displayed=False):
216216 plt .ioff ()
217217 plt .show (block = True )
218218
219- print ("Collision distance:" , collision_distance )
219+ # print("Collision distance:", collision_distance)
220220
221221 return collision_distance
222222
@@ -1086,7 +1086,7 @@ def longitudinal_brake(path : Path, deceleration : float, current_speed : float)
10861086# the desired speed.
10871087# """
10881088
1089- # def __init__(self):
1089+ # def __init__(self, mode : str = 'real', planner : str = 'milestone' ):
10901090# self.route_progress = None
10911091# self.t_last = None
10921092# self.acceleration = 0.5
@@ -1096,6 +1096,9 @@ def longitudinal_brake(path : Path, deceleration : float, current_speed : float)
10961096# self.min_deceleration = 1.0
10971097# self.max_deceleration = 8.0
10981098
1099+ # self.mode = mode
1100+ # self.planner = planner
1101+
10991102# def state_inputs(self):
11001103# return ['all']
11011104
@@ -1124,6 +1127,22 @@ def longitudinal_brake(path : Path, deceleration : float, current_speed : float)
11241127# abs_x = curr_x + state.start_vehicle_pose.x
11251128# abs_y = curr_y + state.start_vehicle_pose.y
11261129
1130+ # ###############################################
1131+ # print("@@@@@ VEHICLE STATE @@@@@")
1132+ # print(vehicle)
1133+ # print("@@@@@@@@@@@@@@@@@@@@@@@@@")
1134+
1135+ # if self.mode == 'real':
1136+ # # Position in vehicle frame (Start (0,0) to (15,0))
1137+ # curr_x = vehicle.pose.x * 20
1138+ # curr_y = vehicle.pose.y * 20
1139+ # curr_v = vehicle.v
1140+ # # print("@@@@@ PLAN", curr_x, curr_y, curr_v)
1141+ # abs_x = curr_x
1142+ # abs_y = curr_y
1143+ # # print("@@@@@ PLAN", abs_x, abs_y)
1144+ # ###############################################
1145+
11271146# #figure out where we are on the route
11281147# if self.route_progress is None:
11291148# self.route_progress = 0.0
@@ -1146,6 +1165,10 @@ def longitudinal_brake(path : Path, deceleration : float, current_speed : float)
11461165# #get the object we are yielding to
11471166# obj = state.agents[r.obj2]
11481167
1168+ # if self.mode == 'real':
1169+ # obj.pose.x = obj.pose.x + curr_x
1170+ # obj.pose.y = obj.pose.y + curr_y
1171+
11491172# detected, deceleration = detect_collision(abs_x, abs_y, curr_v, obj, self.min_deceleration, self.max_deceleration, self.acceleration, self.desired_speed)
11501173# if isinstance(deceleration, list):
11511174# print("@@@@@ INPUT", deceleration)
@@ -1232,6 +1255,11 @@ def update(self, state : AllState):
12321255
12331256 ###############################################
12341257 # # TODO: Fix the coordinate conversion of other files
1258+
1259+ print ("@@@@@ VEHICLE STATE @@@@@" )
1260+ print (vehicle )
1261+ print ("@@@@@@@@@@@@@@@@@@@@@@@@@" )
1262+
12351263 if self .mode == 'real' :
12361264 # Position in vehicle frame (Start (0,0) to (15,0))
12371265 curr_x = vehicle .pose .x * 20
@@ -1284,24 +1312,30 @@ def update(self, state : AllState):
12841312 print ("#### YIELDING PLANNING ####" )
12851313
12861314 # Vehicle parameters.
1287-
1288-
1289- """
1290- TODO: Change the pose of vehicle and pedestrian according to the frames.
1291- Simulation => World frame?
1292- Vehicle => Relative frame?
1293- """
1294-
1295-
12961315 x1 , y1 = abs_x , abs_y
12971316 v1 = [curr_v , 0 ] # Vehicle speed vector
12981317
12991318 for n ,a in state .agents .items ():
13001319
1320+ """
1321+ class ObjectFrameEnum(Enum):
1322+ START = 0 #position / yaw in m / radians relative to starting pose of vehicle
1323+ CURRENT = 1 #position / yaw in m / radians relative to current pose of vehicle
1324+ GLOBAL = 2 #position in longitude / latitude, yaw=heading in radians with respect to true north (used in GNSS)
1325+ ABSOLUTE_CARTESIAN = 3 #position / yaw in m / radians relative to a global cartesian reference frame (used in simulation)
1326+ """
1327+ print ("@@@@@ AGENT STATE @@@@@" )
1328+ print (a )
1329+ print ("@@@@@@@@@@@@@@@@@@@@@@@" )
1330+
13011331 # Pedestrian parameters.
13021332 x2 , y2 = a .pose .x , a .pose .y
13031333 v2 = [a .velocity [0 ], a .velocity [1 ]] # Pedestrian speed vector
13041334
1335+ if self .mode == 'real' :
1336+ x2 = a .pose .x + curr_x
1337+ y2 = a .pose .y + curr_y
1338+
13051339 # Total simulation time
13061340 if v1 [0 ] > 0.1 :
13071341 total_time = min (10 , lookahead_distance / v1 [0 ])
@@ -1394,8 +1428,6 @@ def update(self, state : AllState):
13941428 # traj = longitudinal_plan(route_to_end, self.acceleration, self.deceleration, self.desired_speed, curr_v, "milestone")
13951429 #choose whether to accelerate, brake, or keep at current velocity
13961430 if should_accelerate :
1397- print (route_with_lookahead )
1398- print (accel , decel , desired_speed , curr_v )
13991431 traj = longitudinal_plan (route_with_lookahead , accel , decel , desired_speed , curr_v , self .planner )
14001432 elif should_brake :
14011433 traj = longitudinal_brake (route_with_lookahead , decel , curr_v )
0 commit comments