Пример #1
0
def control_move(path):
    print(path)

    seekrate_ = 6000
    feedrate_ = 2000
    intensity_ = 100.0
    driveboard.absolute()
    for polyline in path:
        if len(polyline) > 0:
            driveboard.feedrate(seekrate_)
            driveboard.intensity(0.0)
            driveboard.move(polyline[0][0], polyline[0][1])
            if len(polyline) > 1:
                driveboard.feedrate(feedrate_)
                driveboard.intensity(intensity_)
                for i in range(1, len(polyline)):
                    driveboard.move(polyline[i][0], polyline[i][1])
                    time.sleep(0.08)

    driveboard.air_off()
    driveboard.feedrate(seekrate_)
    driveboard.intensity(0.0)
    time.sleep(0.1)
    driveboard.move(0, 0, 0)
    time.sleep(0.1)
Пример #2
0
def start(browser=False, debug=False):
    """ Start a bottle web server.
        Derived from WSGIRefServer.run()
        to have control over the main loop.
    """
    global DEBUG
    DEBUG = debug

    class FixedHandler(wsgiref.simple_server.WSGIRequestHandler):
        def address_string(self):  # Prevent reverse DNS lookups please.
            return self.client_address[0]

        def log_request(*args, **kw):
            if debug:
                return wsgiref.simple_server.WSGIRequestHandler.log_request(
                    *args, **kw)

    S.server = wsgiref.simple_server.make_server(
        conf['network_host'], conf['network_port'], bottle.default_app(),
        wsgiref.simple_server.WSGIServer, FixedHandler)
    S.server.timeout = 0.01
    S.server.quiet = not debug
    if debug:
        bottle.debug(True)
    print("Library Directory: " + conf['rootdir'])
    print("Config Directory: " + conf['confdir'])
    print(
        "-----------------------------------------------------------------------------"
    )
    print("Starting server at http://%s:%d/" %
          ('127.0.0.1', conf['network_port']))
    print(
        "-----------------------------------------------------------------------------"
    )
    driveboard.connect_withfind()
    # open web-browser
    if browser:
        try:
            webbrowser.open_new_tab('http://127.0.0.1:' +
                                    str(conf['network_port']))
        except webbrowser.Error:
            print("Cannot open Webbrowser, please do so manually.")
    sys.stdout.flush()  # make sure everything gets flushed
    # start server
    # print "INFO: Starting web server thread."
    S.start()
    driveboard.air_off()
    if conf['home_on_startup']:
        try:
            # will fail if board not flashed
            driveboard.homing()
        except:
            pass
Пример #3
0
def control(decision):
    seekrate_ = 6000
    driveboard.feedrate(seekrate_)
    driveboard.intensity(0.0)
    if decision == "left":
        driveboard.move(-10.0, 0)
        time.sleep(0.1)
    elif decision == "right":
        driveboard.move(10.0, 0)
        time.sleep(0.1)
    elif decision == "top":
        driveboard.move(0, -10.0)
        time.sleep(0.1)
    elif decision == "bot":
        driveboard.move(0, 10.0)
        time.sleep(0.1)
    elif decision == "quit":
        driveboard.absolute()
        driveboard.air_off()
        driveboard.feedrate(seekrate_)
        driveboard.intensity(0.0)
        time.sleep(0.1)
        driveboard.move(0, 0, 0)
        time.sleep(0.1)
    elif decision == "run":
        driveboard.absolute()
        path = [[[0, 0], [0, 0]],
                [[30.0, 30.0], [30.0, 60.0], [60.0, 60.0], [60.0, 30.0],
                 [30.0, 30.0]]]

        driveboard.intensity(0.0)
        driveboard.air_on()
        seekrate_ = 6000
        feedrate_ = 2000
        intensity_ = 100.0
        for polyline in path:
            if len(polyline) > 0:
                driveboard.feedrate(seekrate_)
                driveboard.intensity(0.0)
                driveboard.move(polyline[0][0], polyline[0][1])
                if len(polyline) > 1:
                    driveboard.feedrate(feedrate_)
                    driveboard.intensity(intensity_)
                    for i in range(1, len(polyline)):
                        driveboard.move(polyline[i][0], polyline[i][1])
                        time.sleep(0.08)

        driveboard.air_off()
        driveboard.feedrate(seekrate_)
        driveboard.intensity(0.0)
        time.sleep(0.1)
        driveboard.move(0, 0, 0)
        time.sleep(0.1)
Пример #4
0
def air_off():
    driveboard.air_off()
    return '{}'
Пример #5
0
def air_off():
    driveboard.air_off()
    return '{}'
Пример #6
0
count = 0
# if driveboard.status()['ready']:
driveboard.intensity(0.0)
driveboard.air_on()
seekrate_ = 6000
feedrate_ = 2000
intensity_ = 100.0
driveboard.absolute()
for polyline in path:
    if len(polyline) > 0:
        driveboard.feedrate(seekrate_)
        driveboard.intensity(0.0)
        driveboard.move(polyline[0][0], polyline[0][1])
        if len(polyline) > 1:
            driveboard.feedrate(feedrate_)
            driveboard.intensity(intensity_)
            for i in range(1, len(polyline)):
                driveboard.move(polyline[i][0], polyline[i][1])
                count += 1
                time.sleep(0.08)

driveboard.air_off()
driveboard.feedrate(seekrate_)
driveboard.intensity(0.0)
time.sleep(0.1)
driveboard.move(0, 0, 0)
time.sleep(0.1)
print("Count: {}".format(count))

driveboard.close()