Exemple #1
0
 def _to_camera_coordinates(self, points):
     # Converts points in lidar coordinates to points in camera coordinates.
     # See CameraSetup in pylot/drivers/sensor_setup.py for coordinate
     # axis orientations.
     #
     # The Velodyne coordinate space is defined as:
     # +x into the screen, +y to the left, and +z up.
     #
     # Note: We're using the ROS velodyne driver coordinate
     # system, not the one specified in the Velodyne manual.
     # Link to the ROS coordinate system:
     # https://www.ros.org/reps/rep-0103.html#axis-orientation
     if self._lidar_setup.lidar_type == 'sensor.lidar.ray_cast':
         if self._lidar_setup.legacy:
             # The legacy CARLA Lidar coordinate space is defined as:
             # +x to right, +y out of the screen, +z down.
             to_camera_transform = Transform(matrix=np.array(
                 [[1, 0, 0, 0], [0, 0, 1, 0], [0, -1, 0, 0], [0, 0, 0, 1]]))
         else:
             # The latest coordiante space is the unreal space.
             to_camera_transform = Transform(matrix=np.array(
                 [[0, 1, 0, 0], [0, 0, -1, 0], [1, 0, 0, 0], [0, 0, 0, 1]]))
     elif self._lidar_setup.lidar_type == 'velodyne':
         to_camera_transform = Transform(matrix=np.array(
             [[0, -1, 0, 0], [0, 0, -1, 0], [1, 0, 0, 0], [0, 0, 0, 1]]))
     else:
         raise ValueError('Unexpected lidar type {}'.format(
             self._lidar_setup.lidar_type))
     transformed_points = to_camera_transform.transform_points(points)
     return transformed_points
Exemple #2
0
 def _to_camera_coordinates(self, points):
     # Converts points in lidar coordinates to points in camera coordinates.
     # See CameraSetup in pylot/simulation/sensor_setup.py for coordinate
     # axis orientations.
     to_camera_transform = Transform(matrix=np.array(
         [[1, 0, 0, 0], [0, 0, 1, 0], [0, -1, 0, 0], [0, 0, 0, 1]]))
     transformed_points = to_camera_transform.transform_points(points)
     return np.asarray([[loc.x, loc.y, loc.z]
                        for loc in transformed_points])
Exemple #3
0
def _point_cloud_to_precog_coordinates(point_cloud):
    """Converts a LIDAR PointCloud, which is in camera coordinates,
       to the coordinates used in the PRECOG dataset, which is LIDAR
       coordinates but with the y- and z-coordinates negated (for
       a reference describing PRECOG coordinates, see e.g. https://github.com/nrhine1/deep_imitative_models/blob/0d52edfa54cb79da28bd7cf965ebccbe8514fc10/dim/env/preprocess/carla_preprocess.py#L584)  # noqa: E501
    """
    to_precog_transform = Transform(matrix=np.array(
        [[1, 0, 0, 0], [0, 0, 1, 0], [0, -1, 0, 0], [0, 0, 0, 1]]))
    transformed_point_cloud = to_precog_transform.transform_points(point_cloud)
    return transformed_point_cloud