I am attempting to read IMU data. So far I have done two different ways. One is with Dronekit useing the add message listener. See results below. The curve appears to have duplicated points and is jagged.
The second way is using recv_match as shown in this example:
looking at the middle plot the line is vary smooth with no repeated points!
I am trying to figure out how Dronekit gets Mavlink messages to figure out why my results are varying. I see that it is using this line here to add_message_listeners to get the messages.
My question is dose Dronekit use recv_match when add_message_listeners is called?
recv_match is in pymavlink/mavlink
usec = int(time.time() * 1.0e6) & ~3
self.logfile.write(str(struct.pack('>Q', usec) + msg.get_msgbuf()))
# if we failed to parse any messages _and_ no new bytes arrived, return immediately so the client has the option to
if numnew == 0:
def recv_match(self, condition=None, type=None, blocking=False, timeout=None):
'''recv the next MAVLink message that matches the given condition
type can be a string or a list of strings'''
if type is not None and not isinstance(type, list) and not isinstance(type, set):
type = [type]
start_time = time.time()
if timeout is not None:
now = time.time()
if now < start_time:
start_time = now # If an external process rolls back system time, we should not spin forever.