def ultra_tester(severity=0.5): #just controlling distance with the ultrasonic dist = checkdist(exact=True) if dist < (severity - 0.1): move.move_backward(60) elif dist > (severity + 0.1): move.move_forward(60) elif dist >= (severity - 0.1) and dist <= (severity + 0.1): move.motorStop()
def stuck(): """ This function is called when the rover has not moved 0.5 meters from its last position """ motor.move_backward(100) time.sleep(2) motor.stop() motor.stationary_turn(100, 1) time.sleep(2) motor.stop() return
def do_GET(self): if self.path == '/': self.path += 'index.html' if self.path.endswith(".html") or self.path.endswith( ".js") or self.path.endswith(".svg") or self.path.endswith( ".css"): self.send_response(200) self.end_headers() try: f = open(curdir + sep + self.path) self.wfile.write(bytes(f.read(), 'utf-8')) f.close() except IOError as e: self.send_error(404, str(e)) elif self.path == '/stream.mjpg': self.close_connection = False self.send_response(200) self.send_header('Age', 0) self.send_header('Cache-Control', 'no-cache, private') self.send_header('Pragma', 'no-cache') self.send_header('Content-Type', 'multipart/x-mixed-replace; boundary=--FRAME') self.end_headers() output.add_client(self) if 'cmd=' in self.path: self.send_response(200) self.end_headers() cmd = self.path.split('cmd=')[1][0] if cmd == 'a': global mode_auto mode_auto = not mode_auto database.write_mode(mode_auto) elif cmd == 'l': motor.rotate_camera(15) elif cmd == 'r': motor.rotate_camera(-15) elif cmd == 'w': motor.move_forward(1) elif cmd == 's': motor.move_backward(1) elif cmd == 'd': self.wfile.write(bytes(database.read_last(13), 'utf-8')) elif cmd == 'c': self.wfile.write(bytes(str(-motor.camera_angle), 'utf-8')) elif cmd == 'b': self.wfile.write( bytes("%.1fM" % sensors.altitude_baro(), 'utf-8'))