Ejemplo n.º 1
0
def _main():
    print("Caesar")
    motor.set_motor(2, 100)
    time.sleep(3)
    print("Caesar1")

    #lift_front_part()
    time.sleep(3)
    stop()
    exit()
Ejemplo n.º 2
0
 def do_GET(self):
     path = self.path
     print('path = {}'.format(self.path))
     body = "ok"
     if path == "/":
         html_f = open("motor-client.html", encoding='utf-8')
         body = html_f.read()
         html_f.close()
     if path == "/forward":
         motor.set_motor2(2)  # import motor.py
     elif path == "/back":
         motor.set_motor2(1)
     elif path == "/left":
         motor.set_motor(0, 1)
         motor.set_motor(1, 0)
     elif path == "/right":
         motor.set_motor(0, 0)
         motor.set_motor(1, 1)
     elif path == "/stop":
         motor.set_motor2(0)
     else:
         print("Unoknown command....")
     self.send_response(200)
     self.send_header('Content-Type', 'text/html;charset=utf-8')
     self.end_headers()
     self.wfile.write(body.encode('utf-8'))
Ejemplo n.º 3
0
def forward() -> None:
    """Move Spencer forwards."""
    motor.set_motor(DRIVE_LEFT, DRIVE_SIDE_FWD)
    motor.set_motor(DRIVE_RIGHT, DRIVE_SIDE_BCK)
    motor.set_motor(DRIVE_BACK, DRIVE_SIDE_FWD)
    motor.set_motor(DRIVE_FWD, DRIVE_SIDE_FWD)
Ejemplo n.º 4
0
def lift_back() -> None:
    """Moves the back stepper upwards, to the base position"""
    motor.set_motor(STEP_BACK, -SPEED)
Ejemplo n.º 5
0
def lower_back() -> None:
    """Moves the back stepper down, from the base position"""
    motor.set_motor(STEP_BACK, SPEED)
Ejemplo n.º 6
0
def lift_front() -> None:
    """Moves the front stepper upwards, from the base position"""
    motor.set_motor(STEP_FRONT, -SPEED)
Ejemplo n.º 7
0
def lower_front() -> None:
    """Moves the front stepper down, to the base position"""
    motor.set_motor(STEP_FRONT, SPEED)
Ejemplo n.º 8
0
def turn_right(speed: float = 1.0) -> None:
    """Attempt to turn Spencer right. It's not very effective."""
    motor.set_motor(DRIVE_LEFT, int(DRIVE_SIDE_BCK * speed))
    motor.set_motor(DRIVE_RIGHT, int(DRIVE_SIDE_BCK * speed))
Ejemplo n.º 9
0
def turn_left(speed: float = 1.0) -> None:
    """Attempt to turn Spencer left. It's a sight for sore eyes."""
    motor.set_motor(DRIVE_LEFT, int(
        DRIVE_SIDE_FWD *
        speed))  # TODO: Fix this so it's actually bloody correct.
    motor.set_motor(DRIVE_RIGHT, int(DRIVE_SIDE_FWD * speed))
Ejemplo n.º 10
0
def forward():
    """Move motors forwards."""
    motor.set_motor(4, 50)
    motor.set_motor(5, 50)
Ejemplo n.º 11
0
def lift_front_part():
    """Lift the front part"""
    motor.set_motor(3, 100)
Ejemplo n.º 12
0
    print("Caesar1")

    #lift_front_part()
    time.sleep(3)
    stop()
    exit()


if __name__ == "__main__":
    _main()

try:
    while True:
        #motor.set_motor(4, -100)
        #motor.set_motor(5, 100)
        motor.set_motor(1, 100)
        #time.sleep(3)
        #motor.stop_motors()
        #time.sleep(0.5)

        #motor.set_motor(4, 100)
        #motor.set_motor(5, -100)

        #time.sleep(3)
        #motor.stop_motors()
        #time.sleep(0.5)

    # motor.set_motor(1, 100)
    # motor.set_motor(3, -100)
finally:
    motor.stop_motors()