示例#1
0
 def setup(self, path_to_conf_file):
     """Setup phase. Invoked by the scenario runner."""
     flags.FLAGS([__file__, '--flagfile={}'.format(path_to_conf_file)])
     self._logger = erdos.utils.setup_logging('erdos_agent',
                                              FLAGS.log_file_name)
     enable_logging()
     self.track = get_track()
     self._camera_setups = create_camera_setups(self.track)
     # Set the lidar in the same position as the center camera.
     self._lidar_transform = pylot.utils.Transform(CENTER_CAMERA_LOCATION,
                                                   pylot.utils.Rotation())
     self._lidar_setup = LidarSetup('lidar', 'sensor.lidar.ray_cast',
                                    self._lidar_transform)
     # Stores the waypoints we get from the challenge planner.
     self._waypoints = None
     # Stores the open drive string we get when we run in track 3.
     self._open_drive_data = None
     (camera_streams, pose_stream, global_trajectory_stream,
      open_drive_stream, point_cloud_stream,
      control_stream) = create_data_flow()
     self._camera_streams = camera_streams
     self._pose_stream = pose_stream
     self._global_trajectory_stream = global_trajectory_stream
     self._open_drive_stream = open_drive_stream
     self._sent_open_drive = False
     self._point_cloud_stream = point_cloud_stream
     self._control_stream = control_stream
     # Execute the data-flow.
     erdos.run_async()
示例#2
0
 def setup(self, path_to_conf_file):
     """Setup phase. Invoked by the scenario runner."""
     # Disable Tensorflow logging.
     pylot.utils.set_tf_loglevel(logging.ERROR)
     # Parse the flag file.
     flags.FLAGS([__file__, '--flagfile={}'.format(path_to_conf_file)])
     self._logger = erdos.utils.setup_logging('erdos_agent',
                                              FLAGS.log_file_name)
     enable_logging()
     self.track = get_track()
     self._town_name = None
     self._camera_setups = create_camera_setups()
     # Set the lidar in the same position as the center camera.
     self._lidar_transform = pylot.utils.Transform(CENTER_CAMERA_LOCATION,
                                                   pylot.utils.Rotation())
     self._lidar_setup = LidarSetup('lidar',
                                    'sensor.lidar.ray_cast',
                                    self._lidar_transform,
                                    range=8500,
                                    legacy=False)
     self._last_point_cloud = None
     self._last_yaw = 0
     # Stores the waypoints we get from the challenge planner.
     self._waypoints = None
     # Stores the open drive string we get when we run in track 3.
     self._open_drive_data = None
     (camera_streams, pose_stream, route_stream, global_trajectory_stream,
      open_drive_stream, point_cloud_stream, imu_stream, gnss_stream,
      control_stream, control_display_stream, ground_obstacles_stream,
      ground_traffic_lights_stream, vehicle_id_stream,
      streams_to_send_top_on) = create_data_flow()
     self._camera_streams = camera_streams
     self._pose_stream = pose_stream
     self._route_stream = route_stream
     self._sent_initial_pose = False
     self._global_trajectory_stream = global_trajectory_stream
     self._open_drive_stream = open_drive_stream
     self._sent_open_drive = False
     self._point_cloud_stream = point_cloud_stream
     self._imu_stream = imu_stream
     self._gnss_stream = gnss_stream
     self._control_stream = control_stream
     self._control_display_stream = control_display_stream
     self._ground_obstacles_stream = ground_obstacles_stream
     self._ground_traffic_lights_stream = ground_traffic_lights_stream
     self._vehicle_id_stream = vehicle_id_stream
     self._ego_vehicle = None
     self._sent_vehicle_id = False
     # Execute the dataflow.
     self._node_handle = erdos.run_async()
     for stream in streams_to_send_top_on:
         stream.send(erdos.WatermarkMessage(erdos.Timestamp(is_top=True)))
     if using_perfect_component():
         # The agent is using a perfect component. It must directly connect
         # to the simulator to send perfect data to the data-flow.
         _, self._world = pylot.simulation.utils.get_world(
             FLAGS.carla_host, FLAGS.carla_port, FLAGS.carla_timeout)
示例#3
0
def create_lidar_setup():
    """Creates a setup for the LiDAR deployed on the car."""
    # Set the lidar in the same position as the center camera.
    # Pylot uses the LiDAR point clouds to compute the distance to
    # the obstacles detected using the camera frames.
    lidar_transform = pylot.utils.Transform(CENTER_CAMERA_LOCATION,
                                            pylot.utils.Rotation())
    lidar_setup = LidarSetup(
        'lidar',
        'sensor.lidar.ray_cast',
        lidar_transform,
        range=8500,  # Range is only used for visualization.
        legacy=False)
    return lidar_setup
示例#4
0
def test_point_cloud_get_pixel_location(lidar_points, pixel, expected):
    camera_setup = CameraSetup(
        'test_setup',
        'sensor.camera.depth',
        801,
        601,  # width, height
        Transform(location=Location(0, 0, 0), rotation=Rotation(0, 0, 0)),
        fov=90)
    lidar_setup = LidarSetup('lidar', 'sensor.lidar.ray_cast',
                             Transform(Location(), Rotation()))
    point_cloud = PointCloud(lidar_points, lidar_setup)
    location = point_cloud.get_pixel_location(pixel, camera_setup)
    assert np.isclose(location.x,
                      expected.x), 'Returned x value is not the same '
    'as expected'
    assert np.isclose(location.y,
                      expected.y), 'Returned y value is not the same '
    'as expected'
    assert np.isclose(location.z,
                      expected.z), 'Returned z value is not the same '
    'as expected'
示例#5
0
def on_lidar_msg(carla_pc):
    game_time = int(carla_pc.timestamp * 1000)
    print("Received lidar msg {}".format(game_time))
    lidar_transform = pylot.utils.Transform.from_carla_transform(
        carla_pc.transform)
    lidar_setup = LidarSetup('lidar',
                             lidar_type='sensor.lidar.ray_cast',
                             transform=lidar_transform)
    point_cloud = PointCloud.from_carla_point_cloud(carla_pc, lidar_setup)
    camera_setup = CameraSetup("lidar_camera",
                               "sensor.camera.depth",
                               800,
                               600,
                               lidar_transform,
                               fov=90.0)
    for (x, y) in pixels_to_check:
        pixel = pylot.utils.Vector2D(x, y)
        location = point_cloud.get_pixel_location(pixel, camera_setup)
        print("{} Computed using lidar {}".format((x, y), location))

    global lidar_pc
    lidar_pc = point_cloud
示例#6
0
def test_initialize_point_cloud(points, expected):
    lidar_setup = LidarSetup('lidar', 'sensor.lidar.ray_cast',
                             Transform(Location(), Rotation()))
    point_cloud = PointCloud(points, lidar_setup)
    for i in range(len(expected)):
        assert all(np.isclose(point_cloud.points[i], expected[i]))
示例#7
0
 def __init__(self, points, lidar_setup: LidarSetup):
     # Transform point cloud from lidar to camera coordinates.
     self._lidar_setup = lidar_setup
     self.global_points = copy.deepcopy(points)
     self.points = self._to_camera_coordinates(points)
     self.transform = lidar_setup.get_transform()