MCPcopy Create free account
hub / github.com/OpenDriveLab/DriveAdapter / interpolate_trajectory

Function interpolate_trajectory

dataset/tools/generate_random_routes.py:254–289  ·  view source on GitHub ↗

Given some raw keypoints interpolate a full dense trajectory to be used by the user. Args: world: an reference to the CARLA world so we can use the planner waypoints_trajectory: the current coarse trajectory hop_resolution: is the resolution, how dense is the provide

(world_map, waypoints_trajectory, hop_resolution=1.0)

Source from the content-addressed store, hash-verified

252
253
254def interpolate_trajectory(world_map, waypoints_trajectory, hop_resolution=1.0):
255 """
256 Given some raw keypoints interpolate a full dense trajectory to be used by the user.
257 Args:
258 world: an reference to the CARLA world so we can use the planner
259 waypoints_trajectory: the current coarse trajectory
260 hop_resolution: is the resolution, how dense is the provided trajectory going to be made
261 Return:
262 route: full interpolated route both in GPS coordinates and also in its original form.
263 """
264
265 dao = GlobalRoutePlannerDAO(world_map, hop_resolution)
266 grp = GlobalRoutePlanner(dao)
267 grp.setup()
268 # Obtain route plan
269 route = []
270 is_junction = False
271 distance = 0
272
273 try:
274 for i in range(len(waypoints_trajectory) - 1): # Goes until the one before the last.
275
276 waypoint = waypoints_trajectory[i]
277 waypoint_next = waypoints_trajectory[i + 1]
278 interpolated_trace = grp.trace_route(waypoint, waypoint_next)
279 for i, wp_tuple in enumerate(interpolated_trace):
280 route.append(wp_tuple[0].transform)
281 if i > 0:
282 distance += wp_tuple[0].transform.location.distance(interpolated_trace[i-1][0].transform.location)
283 if not is_junction:
284 is_junction = wp_tuple[0].is_junction
285 # print (wp_tuple[0].transform.location, wp_tuple[1])
286 except:
287 return None, distance, is_junction
288
289 return route, distance, is_junction
290
291import subprocess
292

Callers 1

mainFunction · 0.70

Calls 5

setupMethod · 0.95
trace_routeMethod · 0.95
GlobalRoutePlannerClass · 0.90
distanceMethod · 0.80

Tested by

no test coverage detected