connection_state reports OK but drone is not connected
Closed this issue · 5 comments
Hello all,
I have been developing on top of olympe and found that when connected through the SkyController to the drone, when i do Drone.connection_state() it returns me OK when in fact only the SkyController is connected, but the drone is not on.
This is misleading and I would like to handle this situation, where the SkyController is indeed connected to my program but the drone is not.
I see how that can be misleading. Drone.connection_state
returns the status of the SDK connection to the device and it doesn't really matter if the the device is a drone or a SkyController.
When you're connected to a drone through a SkyController the drone_manager.connection_state event message is probably what you're looking for.
The least I can do is to update the documentation of Drone.connection_state
. I will also see what I can do to improve this API.
Please improve the docs. This would be enough :)
@ndessart It happens that if the drone is already connected i will not receive any connection state change. How do i query the connection state, without it changing? When i do drone_manager connect nothing happens, meaning no state change message is received.
drone.get_state(drone_manager.connection_state)["state"]
is probably what you're looking for.
Alternatively :
if drone(drone_manager.connection_state(state="connected", _policy="check")):
print("connected")
Hmm that seems a familiar construct but while i can import drone_manager the code fails
print(self.drone.getDrone().get_state(drone_manager.connection_state)["state"])
File "./parrot-service.py", line 389, in _reconnectDrone
print(self.getDrone()._get_message(137).state()["state"])
File "/parrot/code/parrot-groundsdk/packages/olympe/src/olympe/arsdkng/drone.py", line 1155, in _get_message
return self.messages[id_]
KeyError: 137