import robot.compass as compass
import robot.motors as motors
import robot
import time

try:
    compass.wake()
    compass.setHighSpeedDataRate()
    compass.calibrate(10)
    print("Samlar data...")
    motors.left(100)
    with open("data.csv", "w") as f:
        while True:
            data = compass.readAxisData()
            print("{},{}".format(data[0], data[1]), file=f)
            time.sleep(1/220)
except:
    motors.stop()
    compass.sleep()
    robot.clean()
Exemple #2
0
def avsluta():
    print("Batteriet är s**t!")
    robot.clean()
    robot.halt()
Exemple #3
0
def avsluta():
    print("Batteriet är s**t!")
    robot.clean()
    robot.halt()
Exemple #4
0
            motors.forward()

        if time.time() - t >= 0.5:
            if abs(compass.angleDifference(compass.getHeading(),
                                           last)) >= math.radians(15):
                distance.stop_measuring()
                motors.stop()
                done = True
                logger.join()
                a = compass.getHeading()
                compass.calibrate(3)
                done = False
                logger = threading.Thread(target=supermagiskt)
                logger.start()
                robot.turn_to(a, math.radians(20))
                time.sleep(1)
                distance.start_measuring(count)
                motors.forward()
            t = time.time()
            last = compass.getHeading()
        time.sleep(0.1)
except KeyboardInterrupt:
    pass
finally:
    done = True
    distance.stop_measuring()
    motors.stop()
    logger.join()
    maplogger.close()
    robot.clean()