MCPcopy Create free account
hub / github.com/OpenDriveLab/TCP / _find_obstacle_3dbb

Method _find_obstacle_3dbb

leaderboard/team_code/base_agent.py:524–569  ·  view source on GitHub ↗

Returns a list of 3d bounding boxes of type obstacle_type. If the object does have a bounding box, this is returned. Otherwise a bb of size 0.5,0.5,2 is returned at the origin of the object. Args: obstacle_type (String): Regular expression max_distanc

(self, obstacle_type, max_distance=50)

Source from the content-addressed store, hash-verified

522 seg_img[(_region == 1)] = 4
523
524 def _find_obstacle_3dbb(self, obstacle_type, max_distance=50):
525 """Returns a list of 3d bounding boxes of type obstacle_type.
526 If the object does have a bounding box, this is returned. Otherwise a bb
527 of size 0.5,0.5,2 is returned at the origin of the object.
528
529 Args:
530 obstacle_type (String): Regular expression
531 max_distance (int, optional): max search distance. Returns all bbs in this radius. Defaults to 50.
532
533 Returns:
534 List: List of Boundingboxes
535 """
536 obst = list()
537
538 _actors = self._world.get_actors()
539 _obstacles = _actors.filter(obstacle_type)
540
541 for _obstacle in _obstacles:
542 distance_to_car = _obstacle.get_transform().location.distance(self._vehicle.get_location())
543
544 if 0 < distance_to_car <= max_distance:
545
546 if hasattr(_obstacle, 'bounding_box'):
547 loc = _obstacle.bounding_box.location
548 _obstacle.get_transform().transform(loc)
549
550 extent = _obstacle.bounding_box.extent
551 _rotation_matrix = self.get_matrix(carla.Transform(carla.Location(0,0,0), _obstacle.get_transform().rotation))
552
553 rotated_extent = np.squeeze(np.array((np.array([[extent.x, extent.y, extent.z, 1]]) @ _rotation_matrix)[:3]))
554
555 bb = np.array([
556 [loc.x, loc.y, loc.z],
557 [rotated_extent[0], rotated_extent[1], rotated_extent[2]]
558 ])
559
560 else:
561 loc = _obstacle.get_transform().location
562 bb = np.array([
563 [loc.x, loc.y, loc.z],
564 [0.5, 0.5, 2]
565 ])
566
567 obst.append(bb)
568
569 return obst
570
571 def _get_2d_bb_baseline(self, obstacle, distance=2, cam='seg_front'):
572 """Returns 2 coordinates for the baseline for 2d bbs in world coordinates

Callers 1

_get_3d_bbsMethod · 0.95

Calls 5

get_matrixMethod · 0.95
get_actorsMethod · 0.80
distanceMethod · 0.80
get_transformMethod · 0.80
get_locationMethod · 0.80

Tested by

no test coverage detected