def main(): hedge = MarvelmindHedge(tty="/dev/ttyACM0", adr=None, debug=False) # create MarvelmindHedge thread if (len(sys.argv) > 1): hedge.tty = sys.argv[1] hedge.start() # start thread while True: try: hedge.dataEvent.wait(1) hedge.dataEvent.clear() if (hedge.positionUpdated): hedge.print_position() if (hedge.distancesUpdated): hedge.print_distances() if (hedge.rawImuUpdated): hedge.print_raw_imu() if (hedge.fusionImuUpdated): hedge.print_imu_fusion() if (hedge.telemetryUpdated): hedge.print_telemetry() if (hedge.qualityUpdated): hedge.print_quality() if (hedge.waypointsUpdated): hedge.print_waypoint() except KeyboardInterrupt: hedge.stop() # stop and close serial port sys.exit()
# initialize the video stream and allow the camera sensor to warm up print("[INFO] starting video stream...") # vs = VideoStream(src=0).start() vs = VideoStream(usePiCamera=True).start() time.sleep(2.0) # open the output CSV file for writing and initialize the set of # barcodes found thus far csv = open(args["output"], "w") found = set() ### Position MarvelMind init hedge = MarvelmindHedge(tty = "/dev/ttyACM0", adr=None, debug=False) # create MarvelmindHedge thread if (len(sys.argv)>1): hedge.tty= sys.argv[1] hedge.start() # start thread ### Functions def read_position(): try: hedge.dataEvent.wait(1) hedge.dataEvent.clear() if (hedge.positionUpdated): position = hedge.position() except KeyboardInterrupt: hedge.stop() sys.exit()