Example #1
0
# limitations under the License.
"""vehicle_driver_altino controller."""

from vehicle import Driver

sensorMax = 1000

driver = Driver()

basicTimeStep = int(driver.getBasicTimeStep())
sensorTimeStep = 4 * basicTimeStep
front_left_sensor = driver.getDistanceSensor('front_left_sensor')
front_center_sensor = driver.getDistanceSensor('front_center_sensor')
front_right_sensor = driver.getDistanceSensor('front_right_sensor')

headlights = driver.getLED("headlights")
backlights = driver.getLED("backlights")

keyboard = driver.getKeyboard()
keyboard.enable(sensorTimeStep)

front_left_sensor.enable(sensorTimeStep)
front_center_sensor.enable(sensorTimeStep)
front_right_sensor.enable(sensorTimeStep)

side_left_sensor = driver.getDistanceSensor('side_left_sensor')
side_right_sensor = driver.getDistanceSensor('side_right_sensor')
back_sensor = driver.getDistanceSensor('back_sensor')

side_left_sensor.enable(sensorTimeStep)
side_right_sensor.enable(sensorTimeStep)
            emergency_message = struct.pack("?", mode)
            emitter.send(emergency_message)

        if not red.get():
            red.set(1)
            blue.set(0)
        else:
            red.set(0)
            blue.set(1)


if __name__ == '__main__':
    # get driver instance
    driver = Driver()
    # set speed of the vehicle
    driver.setCruisingSpeed(100)
    speaker = driver.getSpeaker("Siren")

    # led sensor
    red = driver.getLED("red")
    red.set(0)
    blue = driver.getLED("blue")
    blue.set(0)

    # Emitter sensor to provide communication
    emitter = driver.getEmitter("emitter")
    path = "sounds/AmbulanceSiren.wav"
    path = os.path.abspath(path)
    file = os.path.isfile(path)
    main()