Hello,
I want to access asynchronously the GPS position of my MAV with pymavlink but strangely I stop receiving it after takeoff.
Setup:
- MACOSX latest
- SITL latest
To request the GLOBAL_POSITION_INT message I use:
self.connection.mav.command_long_send(self.connection.target_system, self.connection.target_component,
mavutil.mavlink.MAV_CMD_SET_MESSAGE_INTERVAL, 0, 33, 1e6/frequency, 0, 0, 0, 0, 0)
Then:
# ARM command
drone.get_landed_state()
# LOG :
#[INFO] Last landed state0.9970817565917969
#[INFO] MAV 192.168.0.11 landed state is: 2
# TAKEOFF command
# Checking if the drone has finished it's takeoff:
while drone.get_landed_state() != 2:
sleep(0.5)
def get_landed_state(self):
#Try to check the age of the last message received
self.logger(1, f"Last landed state{self.connection.time_since("EXTENDED_SYS_STATE")}")
while self.connection.time_since("EXTENDED_SYS_STATE") > 2: # If older than 2s I wait for another one...
self.logger(1, f"Last landed state {self.connection.time_since("EXTENDED_SYS_STATE")}")
sleep(0.1)
answer = self.connection.messages["EXTENDED_SYS_STATE"]
if(answer != -1 and answer != -2):
state = answer.landed_state
self.state = state
self.logger(1, f"MAV {self.drone_ip} landed state is: {state}")
return state
else:
self.logger(2, f"could not get GPS lastposition")
return -2
But It seems that I receive no EXTENDED_SYS_STATE after the takeoff:
[INFO] Last landed state 3.000504732131958
[INFO] Last landed state 3.000566005706787
[INFO] Last landed state 3.103688955307007
[INFO] Last landed state 3.2051267623901367
[INFO] Last landed state 3.3052690029144287
[INFO] Last landed state 3.409393787384033
[INFO] Last landed state 3.5099267959594727
[INFO] Last landed state 3.612421751022339
[INFO] Last landed state 3.717477798461914
[INFO] Last landed state 3.8184657096862793
[INFO] Last landed state 3.923513889312744
[INFO] Last landed state 4.024768829345703
[INFO] Last landed state 4.12600302696228
[INFO] Last landed state 4.229667901992798
[INFO] Last landed state 4.332736015319824
[INFO] Last landed state 4.436912775039673
[INFO] Last landed state 4.542001962661743
[INFO] Last landed state 4.644875764846802
[INFO] Last landed state 4.7497718334198
[INFO] Last landed state 4.850944757461548
[INFO] Last landed state 4.955895662307739
[INFO] Last landed state 5.060929775238037
[INFO] Last landed state 5.1615376472473145
[INFO] Last landed state 5.2618348598480225
[INFO] Last landed state 5.366897821426392
[INFO] Last landed state 5.470556974411011
What did I miss ?
Thanks a lot,
Alex