Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def test_camera(beamng):
scenario = Scenario('west_coast_usa', 'camera_test')
vehicle = Vehicle('test_car', model='etk800')
pos = (-0.3, 1, 1.0)
direction = (0, 1, 0)
fov = 120
resolution = (64, 64)
front_camera = Camera(pos, direction, fov, resolution,
colour=True, depth=True, annotation=True)
vehicle.attach_sensor('front_cam', front_camera)
scenario.add_vehicle(vehicle, pos=(-717.121, 101, 118.675), rot=(0, 0, 45))
scenario.make(beamng)
with beamng as bng:
bng.load_scenario(scenario)
bng.step(120)
sensors = bng.poll_sensors(vehicle)
assert_image_different(sensors['front_cam']['colour'])
assert_image_different(sensors['front_cam']['depth'])
assert_image_different(sensors['front_cam']['annotation'])
# Create a scenario in west_coast_usa
scenario = Scenario('west_coast_usa', 'research_test',
description='Random driving for research')
# Set up first vehicle, with two cameras, gforces sensor, lidar, electrical
# sensors, and damage sensors
vehicle = Vehicle('ego_vehicle', model='etk800',
licence='RED', color='Red')
# Set up sensors
pos = (-0.3, 1, 1.0)
direction = (0, 1, 0)
fov = 120
resolution = (512, 512)
front_camera = Camera(pos, direction, fov, resolution,
colour=True, depth=True, annotation=True)
pos = (0.0, 3, 1.0)
direction = (0, -1, 0)
fov = 90
resolution = (512, 512)
back_camera = Camera(pos, direction, fov, resolution,
colour=True, depth=True, annotation=True)
gforces = GForces()
electrics = Electrics()
damage = Damage()
lidar = Lidar(visualized=False)
timer = Timer()
# Attach them
vehicle.attach_sensor('front_cam', front_camera)
# sensors, and damage sensors
vehicle = Vehicle('ego_vehicle', model='etk800',
licence='RED', color='Red')
# Set up sensors
pos = (-0.3, 1, 1.0)
direction = (0, 1, 0)
fov = 120
resolution = (512, 512)
front_camera = Camera(pos, direction, fov, resolution,
colour=True, depth=True, annotation=True)
pos = (0.0, 3, 1.0)
direction = (0, -1, 0)
fov = 90
resolution = (512, 512)
back_camera = Camera(pos, direction, fov, resolution,
colour=True, depth=True, annotation=True)
gforces = GForces()
electrics = Electrics()
damage = Damage()
lidar = Lidar(visualized=False)
timer = Timer()
# Attach them
vehicle.attach_sensor('front_cam', front_camera)
vehicle.attach_sensor('back_cam', back_camera)
vehicle.attach_sensor('gforces', gforces)
vehicle.attach_sensor('electrics', electrics)
vehicle.attach_sensor('damage', damage)
vehicle.attach_sensor('timer', timer)