Ejemplo n.º 1
0
#car = Overdrive("F5:64:F7:27:C4:70")
car = Overdrive("E4:E7:75:16:93:AC")
print("LTE-B DEMO:", str(dir(car)))
car.setDelocalizedCallback(delocalizedCallback)
car.setOffsetFromRoadCenterCallback(offsetFromRoadCenter)

#car.setPongCallback(pongCallback)
#car.setTransitionCallback(transitionCallback)
car.setLocationChangeCallback(
    locationChangeCallback)  # Set location change callback to function above
car.changeSpeed(200,
                1000)  # Set car speed with speed = 500, acceleration = 1000
#car.changeLaneRight(1000, 1000) # Switch to next right lane with speed = 1000, acceleration = 1000
#input() # Hold the program so it won't end abruptly
car.ping()
car.changeLane(800, 1000, 0)

car2 = Overdrive("F5:64:F7:27:C4:70")
car2.setDelocalizedCallback(delocalizedCallback)
car2.setLocationChangeCallback(locationChangeCallback)
car2.changeSpeed(200, 1000)
car2.changeLane(800, 1000, 0)

while True:
    #print("Notification:",car.getNotificationsReceived())
    time.sleep(5)
    car.changeSpeed(200, 1000)
    car.changeLane(800, 1000, -44.6)
    #car.changeLaneLeft(500,1000)
    time.sleep(5)
Ejemplo n.º 2
0
        except Exception:
            _LOG.exception('Exception while handling received MQTT message:')

    client.on_connect = on_conn
    client.on_message = on_msg

    for vehicle in config['anki']['vehicles']:
        veh = Overdrive(vehicle['mac'])
        client.publish('%s/%s/connected' % (topic_prefix, vehicle['name']),
                       True,
                       qos=2)
        veh.setLocationChangeCallback(loc_change_callback)
        veh.setTransitionCallback(transition_callback)
        veh.setPongCallback(pong_callback)
        vehicles[vehicle['name']] = veh
        veh.ping()

    try:
        client.connect(config["mqtt"]["host"], config["mqtt"]["port"], 60)
    except socket.error as err:
        _LOG.fatal("Unable to connect to MQTT server: %s" % err)
        sys.exit(1)

    client.loop_start()

    try:
        while True:
            sleep(1)
    except KeyboardInterrupt:
        print("")
        msg_infos = []