Esempio n. 1
0
def compute_all_paths_for_actor(
        vehicle: carla.Actor,
        dist_between_waypoints: float,
        path_length: int = 10,
        lane_type: carla.LaneType = carla.LaneType.Driving,
        verbose: bool = False):
    world = vehicle.get_world()
    location = vehicle.get_location()
    paths = compute_all_paths_from_location(location, world,
                                            dist_between_waypoints,
                                            path_length, lane_type, verbose)

    return paths
    def __init__(self, ego_veh: carla.Actor, gt_config: dict, debug=False):
        """
        Constructor method. 

        Input:
            ego_veh: Carla.Actor obj of the ego vehicle. Carla.Actor provides a get_world() method to get the 
                     Carla.World it belongs to; thus, ego vehicle actor is sufficient to retrieve other info.
            gt_config (dict): Configurations.
            debug (bool): True to turn on debug features.
        """
        self.debug = debug
        # Retrieve carla.World object from ego vehicle carla.Actor object
        carla_world = ego_veh.get_world()

        # Dict as an buffer to store all ground truth data of interest
        # Using dict helps automate data selection during recording since data can be queried by keys
        # This buffer is automatically updated when the child ground truth extractors update their buffer
        self.all_gt = {'static': {}, 'seq': {}}

        # Traffic signs
        self.all_gt['static']['traffic_sign'] = self.get_traffic_signs(
            carla_world, self.debug)

        # Front bumper's transform in Carla's coordinate system
        # It's for the convenience of querying waypoints for lane using carla's APIs
        # TODO: Try put this frame's origin at the intersection of camera FOV and ground surface?
        self._fbumper_carla_tform = None

        # Pose ground truth extractor
        self.pose_gt = PoseGTExtractor(ego_veh, gt_config['pose'])
        # Lane ground truth extractor
        self.lane_gt = LaneGTExtractor(carla_world, gt_config['lane'],
                                       self.debug)

        # Set up buffer for sequential data
        # Refer to pose ground truth extractor's gt buffer
        self.all_gt['seq']['pose'] = self.pose_gt.gt
        # Refer to lane ground truth extractor's gt buffer
        self.all_gt['seq']['lane'] = self.lane_gt.gt