Hi,
I’m working on a script to build some flights scenarios using Python. I’m using SITL+Mavproxy to tests this script before having too many “real” crashes
Here’s below a part of this script:
# Set up variables for wind and control
wind_speed = 5.0
wind_direction = 180.0
desired_pitch = 30.0
desired_roll = 25.0
# Main loop
while True:
# Retrieve wind information from the autopilot
msg = master.recv_match(type='WIND_COV', blocking=True)
wind_speed = msg.wind_speed
wind_direction = msg.wind_direction
The error message
^CTraceback (most recent call last):
File "/home/scripts/./Test3.py", line 126, in <module>
msg = master.recv_match(type='WIND_COV', blocking=True)
File "/home/.local/lib/python3.10/site-packages/pymavlink/mavutil.py", line 524, in recv_match
self.select(0.05)
File "/home/.local/lib/python3.10/site-packages/pymavlink/mavutil.py", line 338, in select
(rin, win, xin) = select.select([self.fd], [], [], timeout)
Due to this error message, I checked in mavutil.py, and I don’t understand what’s going wrong in my code:
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()
while True:
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.
if start_time + timeout < time.time():
return None
m = self.recv_msg()
if m is None:
if blocking:
for hook in self.idle_hooks:
hook(self)
if timeout is None:
self.select(0.05)
else:
self.select(timeout/2)
continue
return None
if type is not None and not m.get_type() in type:
continue
if not evaluate_condition(condition, self.messages):
continue
return m
def select(self, timeout):
'''wait for up to timeout seconds for more data'''
if self.fd is None:
time.sleep(min(timeout,0.5))
return True
try:
(rin, win, xin) = select.select([self.fd], [], [], timeout)
except select.error:
return False
return len(rin) == 1
If someone has an idea, many thanks
Nico