.. _sensors: ****************** Sensors Reference ****************** Scenic sensors provide observations from the selected simulator during a simulation. Use these abstract classes in :specifier:`with sensors { ... }` blocks; the selected simulator (CARLA, MetaDrive, etc.) supplies the concrete implementation. .. note:: The sensors API is a prototype and may undergo changes. .. versionadded:: 3.1 .. contents:: :local: Built-in Sensors ---------------- .. autoclass:: scenic.core.sensors.RGBSensor :noindex: :no-show-inheritance: :no-members: .. autoclass:: scenic.core.sensors.SSSensor :noindex: :no-show-inheritance: :no-members: Usage ----- .. code-block:: scenic param map = localPath('../../assets/maps/CARLA/Town05.xodr') param carla_map = 'Town05' model scenic.domains.driving.model # Sample a lane at random lane = Uniform(*network.lanes) spot = new OrientedPoint on lane.centerline attrs = {"convert": "CityScapesPalette"} # Used by CARLA # Spawn car on that spot with follow lane behavior and # - an RGB Camera pointing forward # - a semantic segmentation sensor ego = new Car at spot, with behavior FollowLaneBehavior(), with sensors {"front_ss": SSSensor(offset=(1.6, 0, 1.7), width=1056, height=704, attributes=attrs), "front_rgb": RGBSensor(offset=(1.6, 0, 1.7), width=1056, height=704, attributes=attrs) } other = new Car offset by 0 @ Range(10, 30), with behavior FollowLaneBehavior() param recordFolder = "out/{simulation}" record ego.observations["front_ss"] every 0.5 seconds after 5 seconds to "frontss_{time}.jpg" record ego.observations["front_rgb"] after 5 seconds to "frontrgb.mp4" terminate after 15 seconds