def __init__(self, deviceName, baudrate=115200): if deviceName is None: print("Device name is required") return try: print("Opening %s at %d bps" % (deviceName, baudrate)) ## Serial object for device communication self.iodev = serial.Serial(deviceName, baudrate) self.iodev.timeout = 1 except Exception as e: print("Failed to open the given serial port") print("\t", e) exit(1) ## A helper class to take care of decoding the input stream self.parser = PingMessage.PingParser() ## device id of this Ping1D object, used for dst_device_id in outgoing messages self.my_id = 255
type=str, default="0.0.0.0:9000", help="Mavlink udp address and port. ex \"0.0.0.0:9000\"") parser.add_argument( '--min-confidence', action="store", type=int, default=50, help="Minimum acceptable confidence percentage for depth measurements.\"") args = parser.parse_args() ## The time that this script was started tboot = time.time() ## Parser to decode incoming PingMessage ping_parser = PingMessage.PingParser() ## Messages that have the current distance measurement in the payload distance_messages = [ PingMessage.PING1D_DISTANCE, PingMessage.PING1D_DISTANCE_SIMPLE, PingMessage.PING1D_PROFILE ] ## The minimum interval time for distance updates to the autopilot ping_interval_ms = 0.1 ## The last time a distance measurement was received last_distance_measurement_time = 0 ## The last time a distance measurement was requested last_ping_request_time = 0
def __init__(self): ## Queued messages received from client self.rxMsgs = deque([]) ## Parser to verify client comms self.parser = PingMessage.PingParser()