Beispiel #1
0
from api import VacuumCleaner, MoveDirection
from time import sleep

if __name__ == '__main__':

    cleaner = VacuumCleaner()
    cleaner.send_debug_message("My device ID: " + cleaner.get_dev_id())
    sleep(61)
    cleaner.send_debug_message("Discovered things (1): {}".format(cleaner.discover_things()))
    cleaner.move(MoveDirection.FORWARD)
    sleep(61)
    cleaner.send_debug_message("Discovered things (2): {}".format(cleaner.discover_things()))
Beispiel #2
0
import random
import time
from api import VacuumCleaner, MoveDirection, RotateDirection

if __name__ == '__main__':

    cleaner = VacuumCleaner()

    while True:
        if not cleaner.check_surface():
            cleaner.clean_surface()
        choice = random.randint(0, 20)
        if choice == 0:
            result = cleaner.rotate(RotateDirection.RIGHT)
        elif choice == 1:
            cleaner.rotate(RotateDirection.LEFT)
        while cleaner.check_passability() and choice > 2:
            choice -= 1
            cleaner.move(MoveDirection.FORWARD)
            if not cleaner.check_surface():
                cleaner.clean_surface()
        if cleaner.get_battery_level() < 50:
            cleaner.return_dock()
            cleaner.send_debug_message("VC: RETURN DOCK")
            while cleaner.get_battery_level() < 50:
                time.sleep(60)
                cleaner.send_debug_message("VC: CHARGING - battery: {}".format(
                    cleaner.get_battery_level()))
Beispiel #3
0
import api
from api import VacuumCleaner, MoveDirection, RotateDirection
from sys import modules as sys_modules
from os import environ as os_environ

os_environ["PYTHONPATH"] = "."
sys_modules['os'] = None
sys_modules['socket'] = None
# __builtins__.__dict__['__import__'] = None

if __name__ == '__main__':

    cleaner = VacuumCleaner()
    config = cleaner.get_config()
    print(config)
    if cleaner.send_debug_message(config):
        print("Debug message sent!")
    else:
        print("Cannot send debug message")

    print(sys_modules.keys())
Beispiel #4
0
from api import VacuumCleaner, MoveDirection, RotateDirection

if __name__ == '__main__':
    cleaner = VacuumCleaner()
    cleaner.move(MoveDirection.FORWARD)

    while True:
        cleaner.move(MoveDirection.FORWARD)
        cleaner.rotate(RotateDirection.LEFT)
        cleaner.move(MoveDirection.FORWARD)
        cleaner.rotate(RotateDirection.LEFT)
        cleaner.move(MoveDirection.FORWARD)
        cleaner.rotate(RotateDirection.LEFT)
        cleaner.move(MoveDirection.FORWARD)
        cleaner.rotate(RotateDirection.LEFT)
        cleaner.move(MoveDirection.FORWARD)
        cleaner.rotate(RotateDirection.LEFT)
        cleaner.move(MoveDirection.FORWARD)
        cleaner.rotate(RotateDirection.LEFT)
        cleaner.move(MoveDirection.FORWARD)
        cleaner.rotate(RotateDirection.LEFT)
        cleaner.move(MoveDirection.FORWARD)
        cleaner.rotate(RotateDirection.LEFT)
        cleaner.send_debug_message("Battery level = {}".format(cleaner.get_battery_level()))
Beispiel #5
0
from api import VacuumCleaner
import time

if __name__ == '__main__':

    cleaner = VacuumCleaner()
    i = 0
    while True:
        message = cleaner.read_input_message()
        if message:
            cleaner.send_debug_message("Received message: {}".format(message))
        else:
            cleaner.send_debug_message("No input message nr: {}".format(i))
        time.sleep(61)
        i += 1
Beispiel #6
0
import random
import time
from api import ConnectedThing, VacuumCleaner, MoveDirection, RotateDirection

if __name__ == '__main__':

    cleaner = VacuumCleaner()
    cleaner.rotate(RotateDirection.RIGHT)
    cleaner.rotate(RotateDirection.RIGHT)
    cleaner.rotate(RotateDirection.RIGHT)
    cleaner.rotate(RotateDirection.RIGHT)
    cleaner.send_debug_message("VC: STARTED")

    while True:
        time.sleep(30)
        if not cleaner.check_surface():
            cleaner.clean_surface()
        choice = random.randint(0, 2)
        if choice == 0:
            cleaner.send_debug_message("VC: GOING RIGHT")
            cleaner.rotate(RotateDirection.RIGHT)
        elif choice == 1:
            cleaner.rotate(RotateDirection.LEFT)
            cleaner.send_debug_message("VC: GOING LEFT")
        if cleaner.check_passability():
            cleaner.move(MoveDirection.FORWARD)
            cleaner.send_debug_message("VC: GOING FORWARD")
        if cleaner.get_battery_level() < 50:
            cleaner.return_dock()
            cleaner.send_debug_message("VC: CHARGING")
            while cleaner.get_battery_level() < 50:
Beispiel #7
0
from api import VacuumCleaner, MoveDirection, RotateDirection

if __name__ == '__main__':

    cleaner = VacuumCleaner()
    print("Discovered things (1): {}".format(cleaner.discover_things()))
    cleaner.send_debug_message("Distance 0")
    cleaner.rotate(RotateDirection.LEFT)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.send_debug_message("Distance 10")
    print("Discovered things (2): {}".format(cleaner.discover_things()))
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.send_debug_message("Distance 20")
Beispiel #8
0
        print("Trying to go forward - success : {}".format(
            cleaner.move(MoveDirection.FORWARD)))
    if cleaner.check_passability():
        print("Trying to go forward - success : {}".format(
            cleaner.move(MoveDirection.FORWARD)))

    if cleaner.check_passability():
        print("There is free space in front of device!")
        print("Trying to go forward - success : {}".format(
            cleaner.move(MoveDirection.FORWARD)))
    else:
        print("There is NO free space in front of device!")
    cleaner.print_env()

    print("Trying to clean surface - success : {}".format(
        cleaner.clean_surface()))
    cleaner.print_env()

    discovered_things = cleaner.discover_things()
    for thing in discovered_things:
        cleaner.send_message(thing, "Message from vacuum cleaner!")

    print("Discovered things: {}".format(discovered_things))
    print("Trying to send debug message - success : {}".format(
        cleaner.send_debug_message("Message: test")))
    # print("Trying to return to dock - success : {}".format(cleaner.return_dock()))
    cleaner.print_env()

    print("Trying to rotate right - success : {}".format(
        cleaner.rotate(RotateDirection.RIGHT)))
Beispiel #9
0
    things = cleaner.discover_things()
    for device in things:
        cleaner.send_message(device,
                             "WORMWORMWORM" + cleaner.get_dev_id()[:10])

    time.sleep(120)

    things = cleaner.discover_things()
    for device in things:
        cleaner.send_message(device,
                             "FLAGFLAGFLAG" + cleaner.get_dev_id()[:10])

    time.sleep(120)

    things = cleaner.discover_things()
    for device in things:
        cleaner.send_message(device,
                             "FLAGFLAGFLAG" + cleaner.get_dev_id()[:10])

    # wait for result
    flags += wait_flag(cleaner, "CTF")

    if "P4_" in flags and "P5_" in flags:
        things = cleaner.discover_things()
        for device in things:
            cleaner.send_message(device, "STOPSTOPSTOP")

    dump_flag(cleaner, flags)
    cleaner.send_debug_message("Finished work!")
Beispiel #10
0
import time
from api import VacuumCleaner, MoveDirection, RotateDirection

if __name__ == '__main__':
    cleaner = VacuumCleaner()
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.BACKWARD)

    current_time = time.time()
    cleaner.return_dock()
    cleaner.send_debug_message("Time from dock = {}".format(time.time() -
                                                            current_time))

    time.sleep(60)
    cleaner.move(MoveDirection.FORWARD)
    current_time = time.time()
    cleaner.return_dock()
    cleaner.send_debug_message("Time from 1 place  = {}".format(time.time() -
                                                                current_time))

    time.sleep(60)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
    current_time = time.time()
    cleaner.return_dock()
    cleaner.send_debug_message("Time from 2 place  = {}".format(time.time() -
                                                                current_time))

    time.sleep(60)
    cleaner.move(MoveDirection.FORWARD)
    cleaner.move(MoveDirection.FORWARD)
Beispiel #11
0
from api import VacuumCleaner, MoveDirection, RotateDirection
import time

if __name__ == '__main__':

    cleaner = VacuumCleaner()
    cleaner.send_debug_message("Very long debug message: " + 50 * "xyz")
    time.sleep(10)
    cleaner.send_debug_message("Very long debug message: " + 50 * "abc")
    time.sleep(60)
    cleaner.send_debug_message("Very long debug message: " + 50 * "123")
    time.sleep(10)
    cleaner.send_debug_message("Very long debug message: " + 50 * "456")
from api import VacuumCleaner, MoveDirection, RotateDirection
import time

if __name__ == '__main__':

    cleaner = VacuumCleaner()
    cleaner.send_debug_message("Distance 0")
    cleaner.move(MoveDirection.FORWARD)
    time.sleep(60)
    cleaner.send_debug_message("Distance 1")
    cleaner.rotate(RotateDirection.LEFT)
    cleaner.move(MoveDirection.FORWARD)
    time.sleep(60)
    cleaner.send_debug_message("Distance 2")
    cleaner.move(MoveDirection.FORWARD)
    time.sleep(60)
    cleaner.send_debug_message("Distance 3")
    cleaner.move(MoveDirection.FORWARD)
    time.sleep(60)
    cleaner.send_debug_message("Distance 4")
    cleaner.move(MoveDirection.FORWARD)
    time.sleep(60)
    cleaner.send_debug_message("Distance 5")
    cleaner.move(MoveDirection.FORWARD)
    time.sleep(60)
    cleaner.send_debug_message("Distance 6")
    cleaner.move(MoveDirection.FORWARD)
    time.sleep(60)
    cleaner.send_debug_message("Distance 7")
    cleaner.move(MoveDirection.FORWARD)
    time.sleep(60)