Adding cameras and sensors to a vehicle in CARLA

To add an RGB color camera in the CARLA environment, use the following code:

# Create a RGB Camera Objectcamera1 = Camera('CameraRGB')# Set the RGB camera image resolution in pixelscamera1.set_image_size(640, 480)# Set the camera/sensor position relative to the car in meterscamera1.set_positions(0.25, 0, 1.30)# Add the sensor to the Carla Settings objectsettings.add_sensor(camera1)

You can also add a depth measuring sensor or camera using the following code snippet:

# Create a depth camera object that can provide us the ground-truth depth of the driving scenecamera2 = Camera("CameraDepth",PostProcessing="Depth")# Set the depth camera image resolution in pixelscamera2.set_image_size(640, 480) ...

Get Hands-On Intelligent Agents with OpenAI Gym now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.