l5kit.geometry.transform module

l5kit.geometry.transform.compute_agent_pose(agent_centroid_m: numpy.ndarray, agent_yaw_rad: float) numpy.ndarray

Return the agent pose as a 3x3 matrix. This corresponds to world_from_agent matrix.

Parameters
  • agent_centroid_m (np.ndarry) – 2D coordinates of the agent

  • agent_yaw_rad (float) – yaw of the agent

Returns

3x3 world_from_agent matrix

Return type

(np.ndarray)

l5kit.geometry.transform.ecef_to_geodetic(point: Union[numpy.ndarray, Sequence[float]]) numpy.ndarray

Convert given ECEF coordinate into latitude, longitude, altitude.

Parameters

point (Union[np.ndarray, Sequence[float]]) – ECEF coordinate vector

Returns

latitude, altitude, longitude

Return type

np.ndarray

l5kit.geometry.transform.geodetic_to_ecef(lla_point: Union[numpy.ndarray, Sequence[float]]) numpy.ndarray

Convert given latitude, longitude, and optionally altitude into ECEF coordinates. If no altitude is given, altitude 0 is assumed.

Parameters

lla_point (Union[np.ndarray, Sequence[float]]) – Latitude, Longitude and optionally Altitude

Returns

3D ECEF coordinate

Return type

np.ndarray

l5kit.geometry.transform.rotation33_as_yaw(rotation: numpy.ndarray) float

Compute the yaw component of given 3x3 rotation matrix.

Parameters

rotation (np.ndarray) – 3x3 rotation matrix (np.float64 dtype recommended)

Returns

yaw rotation in radians

Return type

float

l5kit.geometry.transform.transform_point(point: numpy.ndarray, transf_matrix: numpy.ndarray) numpy.ndarray

Transform a single vector using transformation matrix. This function call transform_points internally

Parameters
  • point – vector of shape (N)

  • transf_matrix – transformation matrix of shape (N+1, N+1)

Returns

vector of same shape as input point

l5kit.geometry.transform.transform_points(points: numpy.ndarray, transf_matrix: numpy.ndarray) numpy.ndarray

Transform a set of 2D/3D points using the given transformation matrix. Assumes row major ordering of the input points. The transform function has 3 modes: - points (N, F), transf_matrix (F+1, F+1) all points are transformed using the matrix and the output points have shape (N, F). - points (B, N, F), transf_matrix (F+1, F+1) all sequences of points are transformed using the same matrix and the output points have shape (B, N, F). transf_matrix is broadcasted. - points (B, N, F), transf_matrix (B, F+1, F+1) each sequence of points is transformed using its own matrix and the output points have shape (B, N, F). Note this function assumes points.shape[-1] == matrix.shape[-1] - 1, which means that last rows in the matrices do not influence the final results. For 2D points only the first 2x3 parts of the matrices will be used.

Parameters
  • points – Input points of shape (N, F) or (B, N, F) with F = 2 or 3 depending on input points are 2D or 3D points.

  • transf_matrix – Transformation matrix of shape (F+1, F+1) or (B, F+1, F+1) with F = 2 or 3.

Returns

Transformed points of shape (N, F) or (B, N, F) depending on the dimensions of the input points.

l5kit.geometry.transform.vertical_flip(tm: numpy.ndarray, y_dim_size: int) numpy.ndarray

Return a new matrix that also performs a flip on the y axis.

Parameters
  • tm – the original 3x3 matrix

  • y_dim_size – this should match the resolution on y. It makes all coordinates positive

Returns: a new 3x3 matrix.

l5kit.geometry.transform.yaw_as_rotation33(yaw: float) numpy.ndarray

Create a 3x3 rotation matrix from given yaw. The rotation is counter-clockwise and it is equivalent to: [cos(yaw), -sin(yaw), 0.0], [sin(yaw), cos(yaw), 0.0], [0.0, 0.0, 1.0],

Parameters

yaw (float) – yaw rotation in radians

Returns

3x3 rotation matrix

Return type

np.ndarray