right_duty_cycle=64  # Valid duty cycle range is 0-255
        )

        # Delay to allow RVR to drive
        await asyncio.sleep(2)

    await rvr.stop_robot_to_robot_infrared_broadcasting()

    await rvr.close()


if __name__ == '__main__':
    try:
        loop.run_until_complete(
            main()
        )

    except KeyboardInterrupt:
        print('\nProgram terminated with keyboard interrupt.')

        loop.run_until_complete(
            asyncio.gather(
                rvr.stop_robot_to_robot_infrared_broadcasting(),
                rvr.close()
            )
        )

    finally:
        if loop.is_running():
            loop.close()
示例#2
0
    speed: Drive distance with given speed
    distance: Distance to drive [m]
    """
    await rvr.wake()
    await asyncio.sleep(1)
    battery = (await rvr.get_battery_percentage())["percentage"]
    battery_voltage = (await rvr.get_battery_voltage_state())
    await asyncio.sleep(1)

    print("------------------------------")
    print("RVR Informations")
    print("------------------------------")
    print("Battery [%%]: %d" % battery)
    print("------------------------------")

    await rvr.close()
    await asyncio.sleep(1)


if __name__ == '__main__':
    try:
        loop.run_until_complete(main())

    except KeyboardInterrupt:
        print('\nProgram terminated with keyboard interrupt.')
        loop.run_until_complete(asyncio.gather(rvr.close()))

    finally:
        if loop.is_running():
            loop.close()
示例#3
0
loop = asyncio.get_event_loop()

rvr = SpheroRvrAsync(dal=SerialAsyncDal(loop))


async def main():
    """ This program demonstrates how to get motor thermal protection status, in the event RVR's motors have already
        been stopped to prevent overheating.  This can be used to check if the motors are no longer in a thermal
        protection state. RVR does not need to be awake in order to run this operation.
    """

    response = await rvr.get_motor_thermal_protection_status()
    print('Thermal protection status response', response)

    # Delay to allow the callback to be invoked
    await asyncio.sleep(2)


if __name__ == '__main__':
    try:
        loop.run_until_complete(main())

    except KeyboardInterrupt:
        print('\nProgram terminated with keyboard interrupt.')

        loop.run_until_complete(rvr.close())

    finally:
        if loop.is_running():
            loop.close()
示例#4
0
        handler=ambient_light_handler)
    if debug: print("Starting encoder handler")
    await rvr.sensor_control.add_sensor_data_handler(
        service=RvrStreamingServices.encoders, handler=encoder_handler)
    if debug: print("Starting sensor control")

    #await rvr.sensor_control.start(interval=250)
    await rvr.sensor_control.start(interval=1000)

    if debug: print("Ros listener spinning up")
    #await spin_ros()
    if debug: print("spin complete")

    # The asyncio loop will run forever to allow infinite streaming.


if __name__ == '__main__':
    try:

        asyncio.ensure_future(main())
        loop.run_forever()

    except KeyboardInterrupt:
        print('\nProgram terminated with keyboard interrupt.')

        loop.run_until_complete(
            asyncio.gather(rvr.sensor_control.clear(), rvr.close()))

    finally:
        if loop.is_running():
            loop.close()