data.append([u.x, u.y]) if l <= 300 and l >= 15: data.append([v.x, v.y]) if r <= 300 and l >= 15: data.append([w.x, w.y]) if len(data) == 0: maplogger.log(position=[[n.x, n.y]], heading=compass.getHeading()) else: maplogger.log(position=[[n.x, n.y]], heading=compass.getHeading(), walls=data) time.sleep(0.2) try: maplogger.initialize("/var/www/map.txt") robot.on_battery_low(avsluta) compass.calibrate(5) input("Enter") logger = threading.Thread(target=supermagiskt) logger.start() distance.start_measuring(count) motors.forward() t = 0 last = compass.getHeading() while True: left = ultrasonic.get_left() middle = ultrasonic.get_middle() right = ultrasonic.get_right() if left <= 50 and right <= 50:
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()
if r <= 300 and l >= 15: data.append([w.x, w.y]) if len(data) == 0: maplogger.log(position=[[n.x, n.y]], heading=compass.getHeading()) else: maplogger.log(position=[[n.x, n.y]], heading=compass.getHeading(), walls=data) time.sleep(0.2) try: maplogger.initialize("/var/www/map.txt") robot.on_battery_low(avsluta) compass.calibrate(5) input("Enter") logger = threading.Thread(target=supermagiskt) logger.start() distance.start_measuring(count) motors.forward() t = 0 last = compass.getHeading() while True: left = ultrasonic.get_left() middle = ultrasonic.get_middle() right = ultrasonic.get_right() if left <= 50 and right <= 50: