Sensor Editor

Sensor editing for scene manipulation.

The SensorEditor provides methods to edit individual sensors (cameras, LiDARs, radars) including their extrinsics, intrinsics, and world poses.

Example

>>> # Access sensors and modify properties
>>> scene.camera("FRONT").shift(up=0.05)
>>> scene.lidar(0).set_lidar_intrinsics(max_range=150)
>>> # Method chaining
>>> scene.camera("FRONT") \
...     .shift(up=0.05) \
...     .rotate(pitch=-1) \
...     .scale_camera_resolution(scale=2.0)
mimic_scene_edition.editors.sensor_editor.Frame

"vehicle" or "sensor".

Type:

Frame for extrinsic operations

alias of Literal[‘vehicle’, ‘sensor’]

mimic_scene_edition.editors.sensor_editor.Convention

"vehicle" (x-forward) or "opencv" (z-forward).

Type:

Coordinate convention

alias of Literal[‘vehicle’, ‘opencv’]

class mimic_scene_edition.editors.sensor_editor.SensorEditor(*, scene, sensor, limited_mode=False, value_limits=None, editions=None)[source]

Bases: object

Editor for manipulating individual sensors.

Provides methods to modify sensor extrinsics (mounting position/orientation), intrinsics (sensor-specific parameters), and world poses. Supports cameras, LiDARs, and radars.

Parameters:
  • scene (Scene) – The scene containing the sensor.

  • sensor (Camera | Lidar | Radar) – The sensor object to edit.

  • limited_mode (bool, optional) – If True, enable parameter value limit checking. Default is False.

  • value_limits (dict[str, tuple[float, float]] | None, optional) – Dictionary mapping parameter names to (min, max) bounds.

  • editions (list[EditionDict] | None, optional) – List to append edition records to.

Variables:
  • sensor (Camera | Lidar | Radar) – The underlying sensor object being edited.

  • extrinsics (NDArray[4,4]) – The sensor-to-vehicle transformation matrix.

  • intrinsics (varies) – Sensor-specific intrinsic parameters.

Notes

SensorEditor instances should be obtained through SceneEditor.camera(ref), SceneEditor.lidar(ref), or SceneEditor.radar(ref) rather than instantiated directly.

All transformation methods return self to enable method chaining.

Examples

Camera adjustments:

>>> scene.camera("FRONT").shift(up=0.05)  # Raise camera 5cm
>>> scene.camera("FRONT").rotate(pitch=-2)  # Tilt down 2°

LiDAR configuration:

>>> scene.lidar("LIDAR_TOP").set_lidar_intrinsics(
...     max_range=150.0,
...     min_range=1.0
... )

Method chaining:

>>> scene.camera("FRONT") \
...     .shift(up=0.05) \
...     .rotate(pitch=-1) \
...     .scale_camera_resolution(scale=2.0)
__init__(*, scene, sensor, limited_mode=False, value_limits=None, editions=None)[source]
property extrinsics

The sensor-to-vehicle transformation matrix.

Returns:

4x4 homogeneous transformation matrix from sensor frame to vehicle frame.

Return type:

NDArray[4, 4]

property intrinsics

The sensor’s intrinsic parameters.

Returns:

Sensor-specific intrinsic parameters object. Type depends on sensor type (CameraIntrinsics, LidarIntrinsics, or RadarIntrinsics).

Return type:

varies

scale_camera_resolution(scale)[source]

Scale the camera resolution and adjust intrinsics accordingly.

Scales the camera’s image dimensions and updates intrinsic parameters (focal length, principal point, skew) to match.

Parameters:

scale (float) –

Scale factor for resolution:

  • 0.5: Half resolution

  • 2.0: Double resolution

Returns:

Self for method chaining.

Return type:

SensorEditor

Raises:

TypeError – If the sensor is not a Camera.

Notes

The following intrinsic parameters are modified:

  • fx, fy, cx, cy, skew: Scaled by scale

  • width, height: Scaled and rounded to integers

Examples

>>> scene.camera("FRONT").scale_camera_resolution(scale=0.5)  # Half resolution
>>> scene.camera("FRONT").scale_camera_resolution(scale=2.0)  # Double resolution
set_extrinsics(*, translation_m=(0.0, 0.0, 0.0), rpy_deg=(0.0, 0.0, 0.0), convention='vehicle')[source]

Set the sensor extrinsics (sensor-to-vehicle transform) directly.

Replaces the current extrinsics with a new transformation specified by translation and rotation.

Parameters:
  • translation_m (Iterable[float], optional) – Translation as (x, y, z) in meters. Default is (0, 0, 0).

  • rpy_deg (Iterable[float], optional) – Rotation as (roll, pitch, yaw) in degrees. Default is (0, 0, 0).

  • convention ({"vehicle", "opencv"}, optional) –

    Coordinate convention for the input:

    • "vehicle": x-forward, y-left, z-up (default)

    • "opencv": x-right, y-down, z-forward

Returns:

Self for method chaining.

Return type:

SensorEditor

Examples

>>> scene.camera("FRONT").set_extrinsics(
...     translation_m=(1.5, 0.0, 1.8),
...     rpy_deg=(0, -5, 0)
... )
offset_extrinsics(*, dtranslation_m=(0.0, 0.0, 0.0), drpy_deg=(0.0, 0.0, 0.0), frame='vehicle', convention='vehicle', recompute=True)[source]

Apply an incremental offset to the sensor extrinsics.

Modifies the existing extrinsics by applying an additional transformation, either in the vehicle frame or sensor frame.

Parameters:
  • dtranslation_m (Iterable[float], optional) – Incremental translation as (x, y, z) in meters. Default is (0, 0, 0).

  • drpy_deg (Iterable[float], optional) – Incremental rotation as (roll, pitch, yaw) in degrees. Default is (0, 0, 0).

  • frame ({"vehicle", "sensor"}, optional) –

    Frame in which to apply the offset:

    • "vehicle": Apply in vehicle coordinates (default)

    • "sensor": Apply in sensor coordinates

  • convention ({"vehicle", "opencv"}, optional) – Coordinate convention for the input. Default is "vehicle".

  • recompute (bool, optional) – If True (default), recompute world poses after modification.

Returns:

Self for method chaining.

Return type:

SensorEditor

Examples

>>> scene.camera("FRONT").offset_extrinsics(
...     dtranslation_m=(0.1, 0.0, 0.0),
...     drpy_deg=(0, -2, 0)
... )
shift(*, recompute=True, **kw)[source]

Shift the sensor mounting position in vehicle coordinates.

Translates the sensor in the vehicle frame using intuitive direction names. This modifies the extrinsics.

Parameters:
  • forward (float, optional) – Distance forward (positive X) in meters.

  • backward (float, optional) – Distance backward (negative X) in meters.

  • left (float, optional) – Distance left (positive Y) in meters.

  • right (float, optional) – Distance right (negative Y) in meters.

  • up (float, optional) – Distance up (positive Z) in meters.

  • down (float, optional) – Distance down (negative Z) in meters.

  • recompute (bool, optional) – If True (default), recompute world poses after modification.

Returns:

Self for method chaining.

Return type:

SensorEditor

Examples

>>> scene.camera("FRONT").shift(up=0.05)  # Raise camera 5cm
>>> scene.camera("FRONT").shift(forward=0.1)  # Move forward 10cm
>>> scene.lidar("LIDAR_TOP").shift(up=0.1)  # Raise LiDAR

See also

rotate

Rotate the sensor.

transform

Combined translation and rotation.

rotate(*, roll=0.0, pitch=0.0, yaw=0.0, recompute=True)[source]

Rotate the sensor in its local frame.

Applies a rotation to the sensor mounting orientation. For cameras, rotation is in the sensor’s native convention (typically OpenCV).

Parameters:
  • roll (float, optional) – Rotation around the X axis in degrees. Default is 0.

  • pitch (float, optional) – Rotation around the Y axis in degrees. Default is 0.

  • yaw (float, optional) – Rotation around the Z axis in degrees. Default is 0.

  • recompute (bool, optional) – If True (default), recompute world poses after modification.

Returns:

Self for method chaining.

Return type:

SensorEditor

Examples

>>> scene.camera("FRONT").rotate(pitch=-2)  # Tilt down 2°
>>> scene.camera("FRONT").rotate(yaw=5)  # Pan right 5°
>>> scene.lidar("LIDAR_TOP").rotate(roll=1)  # Slight roll correction

See also

shift

Translate the sensor.

transform

Combined translation and rotation.

transform(*, left=0.0, right=0.0, up=0.0, down=0.0, forward=0.0, backward=0.0, roll=0.0, pitch=0.0, yaw=0.0, referential='vehicle', convention='vehicle', recompute=True)[source]

Apply both translation and rotation to the sensor.

Combines translation and rotation in a single SE(3) transformation applied to the sensor extrinsics.

Parameters:
  • left (float, optional) – Distance left in meters. Default is 0.

  • right (float, optional) – Distance right in meters. Default is 0.

  • up (float, optional) – Distance up in meters. Default is 0.

  • down (float, optional) – Distance down in meters. Default is 0.

  • forward (float, optional) – Distance forward in meters. Default is 0.

  • backward (float, optional) – Distance backward in meters. Default is 0.

  • roll (float, optional) – Rotation around X axis in degrees. Default is 0.

  • pitch (float, optional) – Rotation around Y axis in degrees. Default is 0.

  • yaw (float, optional) – Rotation around Z axis in degrees. Default is 0.

  • referential ({"vehicle", "sensor"}, optional) –

    Frame for the transformation:

    • "vehicle": Transform in vehicle coordinates (default)

    • "sensor": Transform in sensor coordinates

  • convention ({"vehicle", "opencv"}, optional) –

    Axis convention for the transformation:

    • "vehicle": x-forward, y-left, z-up (default)

    • "opencv": x-right, y-down, z-forward

  • recompute (bool, optional) – If True (default), recompute world poses after modification.

Returns:

Self for method chaining.

Return type:

SensorEditor

Examples

>>> scene.camera("FRONT").transform(up=0.05, pitch=-2)

See also

shift

Translation only.

rotate

Rotation only.

static get_rotation_from_euler(roll=0, pitch=0, yaw=0)[source]

Convert Euler angles to a rotation matrix.

Parameters:
  • roll (float, optional) – Rotation around X axis in degrees. Default is 0.

  • pitch (float, optional) – Rotation around Y axis in degrees. Default is 0.

  • yaw (float, optional) – Rotation around Z axis in degrees. Default is 0.

Returns:

3x3 rotation matrix.

Return type:

np.ndarray

set_camera_intrinsics(*, fx=None, fy=None, cx=None, cy=None, width=None, height=None, distortion=None, model=None, rolling_shutter=None)[source]

Modify camera intrinsic parameters.

Updates camera intrinsics. Only provided parameters are modified; others retain their current values.

Parameters:
  • fx (float | None, optional) – Focal length in X (pixels).

  • fy (float | None, optional) – Focal length in Y (pixels).

  • cx (float | None, optional) – Principal point X coordinate (pixels).

  • cy (float | None, optional) – Principal point Y coordinate (pixels).

  • width (int | None, optional) – Image width in pixels.

  • height (int | None, optional) – Image height in pixels.

  • distortion (DistortionParameters | None, optional) – Lens distortion parameters.

  • model (CameraModels | None, optional) – Camera model type.

  • rolling_shutter (RollingShutterParameters | None, optional) – Rolling shutter parameters.

Returns:

Self for method chaining.

Return type:

SensorEditor

Raises:

TypeError – If the sensor is not a Camera.

Examples

>>> scene.camera("FRONT").set_camera_intrinsics(
...     fx=1200, fy=1200,
...     cx=640, cy=360,
...     width=1280, height=720
... )
set_lidar_intrinsics(*, vertical_fov=None, horizontal_fov=None, horizontal_resolution=None, vertical_resolution_rad=None, vertical_resolution_deg=None, keep_vfov=True, max_range=None, min_range=None, horizontal_beam_divergence=None, vertical_beam_divergence=None)[source]

Modify LiDAR intrinsic parameters.

Updates LiDAR intrinsics. Only provided parameters are modified.

Parameters:
  • vertical_fov (float | None, optional) – Vertical field of view in radians.

  • horizontal_fov (float | None, optional) – Horizontal field of view in radians.

  • horizontal_resolution (float | None, optional) – Points per radian (horizontal).

  • vertical_resolution_rad (VerticalResolution | dict | float | None, optional) –

    Vertical resolution specification in radians. Can be provided as:

    • float: Angular spacing between beams. Behavior depends on keep_vfov.

    • dict[int, float]: Channel-to-angle mapping (replaces existing)

    • VerticalResolution: Full specification object (replaces existing)

  • vertical_resolution_deg (float | None, optional) – Convenience argument. Uniform vertical resolution in degrees. Converted to radians internally.

  • keep_vfov (bool, optional) –

    Only used when vertical_resolution_rad or vertical_resolution_deg is a float and the lidar currently has elevation_channel_mapping.

    • True (default): Preserve existing min/max elevation bounds. Generates new channel mapping from max to min elevation with the specified resolution as step size.

    • False: Generate symmetric FOV centered at 0, using the current vertical_fov value and the specified resolution.

  • max_range (float | None, optional) – Maximum detection range in meters.

  • min_range (float | None, optional) – Minimum detection range in meters.

  • horizontal_beam_divergence (float | None, optional) – Horizontal beam divergence in radians.

  • vertical_beam_divergence (float | None, optional) – Vertical beam divergence in radians.

Returns:

Self for method chaining.

Return type:

SensorEditor

Raises:
  • TypeError – If the sensor is not a Lidar.

  • ValueError – If both vertical_resolution_rad and vertical_resolution_deg are specified.

Examples

>>> scene.lidar("LIDAR_TOP").set_lidar_intrinsics(
...     max_range=150.0,
...     min_range=1.0,
... )

Change vertical resolution while preserving existing FOV bounds:

>>> scene.lidar("LIDAR_TOP").set_lidar_intrinsics(vertical_resolution_deg=0.5)

Change vertical resolution with symmetric FOV:

>>> scene.lidar("LIDAR_TOP").set_lidar_intrinsics(
...     vertical_resolution_deg=0.5,
...     keep_vfov=False
... )
set_radar_intrinsics(*, range=None, azimuth_fov=None, elevation_fov=None, azimuth_resolution=None, elevation_resolution=None, min_speed_resolution=None, max_speed_resolution=None)[source]

Modify radar intrinsic parameters.

Updates radar intrinsics. Only provided parameters are modified.

Parameters:
  • range (float | None, optional) – Maximum detection range in meters.

  • azimuth_fov (float | None, optional) – Azimuth field of view in radians.

  • elevation_fov (float | None, optional) – Elevation field of view in radians.

  • azimuth_resolution (list[tuple[float, float]] | None, optional) – Azimuth resolution specification.

  • elevation_resolution (list[tuple[float, float]] | None, optional) – Elevation resolution specification.

  • min_speed_resolution (float | None, optional) – Minimum speed resolution.

  • max_speed_resolution (float | None, optional) – Maximum speed resolution.

Returns:

Self for method chaining.

Return type:

SensorEditor

Raises:

TypeError – If the sensor is not a Radar.

Examples

>>> scene.radar("RADAR_FRONT").set_radar_intrinsics(
...     range=200.0,
...     azimuth_fov=2.0,  # radians
...     elevation_fov=0.3
... )
recompute_world_poses(ego_traj=None)[source]

Rebuild the sensor’s world poses from ego trajectory and extrinsics.

Recomputes the sensor-to-world transformation sequence using the current extrinsics and ego vehicle trajectory.

The computation follows:

\[S2W(t) = E2W(t) \cdot S2E\]

Where:

  • S2W: Sensor-to-world transform

  • E2W: Ego-to-world transform (interpolated to sensor timestamps)

  • S2E: Sensor-to-ego (extrinsics)

Parameters:

ego_traj (WorldTrajectory | None, optional) – Ego trajectory to use. If None, uses the scene’s ego trajectory.

Returns:

Self for method chaining.

Return type:

SensorEditor

Notes

Call this after modifying extrinsics to update the sensor’s world trajectory.

Examples

>>> scene.camera("FRONT").shift(up=0.05).recompute_world_poses()
convert_convention(*, from_convention, to_convention='vehicle', recompute=True)[source]

Convert the sensor extrinsics between coordinate conventions.

Transforms the extrinsics from one coordinate convention to another. This is primarily used for cameras to convert between vehicle and OpenCV conventions.

Parameters:
  • from_convention ({"vehicle", "opencv"}) – Current coordinate convention.

  • to_convention ({"vehicle", "opencv"}, optional) – Target coordinate convention. Default is "vehicle".

  • recompute (bool, optional) – If True (default), recompute world poses after conversion.

Returns:

Self for method chaining.

Return type:

SensorEditor

Notes

Coordinate conventions:

  • Vehicle: X-forward, Y-left, Z-up

  • OpenCV: X-right, Y-down, Z-forward

Examples

>>> scene.camera("FRONT").convert_convention(
...     from_convention="opencv",
...     to_convention="vehicle"
... )