mavsdk.info.InfoError: INFORMATION_NOT_RECEIVED_YET
See original GitHub issueHi I’m using MVSDK-Python for quite some while and its helpful in many ways.
Recently I tried using MAVSDK-Python to work on raspberry pi which is a companion computer with Pixhawk 4.
The serial connection between Pi and Pixhawk4 is on /dev/ttyAMA0 port and the MAVLINK data is routed to udp port 13000 using mavlink-router.
While the code_A.py
works on the Pi, I get an error when I try to run code_B.py
.
Also until yesterday code_B.py
ran without errors on Pi, but today I’m getting this error mavsdk.info.InfoError: INFORMATION_NOT_RECEIVED_YET
(full error below)
code_A.py (this works as expected)
!/usr/bin/env python3
import asyncio
from mavsdk import System
async def run():
# Init the drone
drone = System()
await drone.connect(system_address="udp://:13000")
# Start the tasks
asyncio.ensure_future(print_battery(drone))
asyncio.ensure_future(print_gps_info(drone))
asyncio.ensure_future(print_in_air(drone))
asyncio.ensure_future(print_position(drone))
async def print_battery(drone):
async for battery in drone.telemetry.battery():
print(f"Battery: {battery.remaining_percent}")
async def print_gps_info(drone):
async for gps_info in drone.telemetry.gps_info():
print(f"GPS info: {gps_info}")
async def print_in_air(drone):
async for in_air in drone.telemetry.in_air():
print(f"In air: {in_air}")
async def print_position(drone):
async for position in drone.telemetry.position():
print(position)
if __name__ == "__main__":
# Start the main function
asyncio.ensure_future(run())
# Runs the event loop until the program is canceled with e.g. CTRL-C
asyncio.get_event_loop().run_forever()
code_B.py
#!/usr/bin/env python
import asyncio
from mavsdk import System
async def run():
# Init the drone
vehicle = System()
await vehicle.connect(system_address="udp://:13000")
# vehicle = System(mavsdk_server_address="localhost", port=50040)
# await vehicle.connect()
async for state in vehicle.core.connection_state():
if state.is_connected:
print(f"Vehicle discovered with UUID: {state.uuid}")
break
id_info = await vehicle.info.get_identification()
print(id_info)
if __name__ == '__main__':
# Start the main function
asyncio.ensure_future(run())
# Runs the event loop until the program is canceled with e.g. CTRL-C
asyncio.get_event_loop().run_forever()
code_B.py output
Waiting for mavsdk_server to be ready...
Connected to mavsdk_server!
Vehicle discovered with UUID: 0
Task exception was never retrieved
future: <Task finished coro=<run() done, defined at drone_id.py:6> exception=InfoError(<mavsdk.info.InfoResult object at 0x7528a2f0>, 'get_identification()')>
Traceback (most recent call last):
File "drone_id.py", line 20, in run
id_info = await vehicle.info.get_identification()
File "/home/pi/.local/lib/python3.7/site-packages/mavsdk/info.py", line 666, in get_identification
raise InfoError(result, "get_identification()")
mavsdk.info.InfoError: INFORMATION_NOT_RECEIVED_YET: 'Information Not Received Yet'; origin: get_identification(); params: ()
I’m not able to understand why this line (id_info = await vehicle.info.get_identification()
) is throwing error.
Both the codes work on Ubuntu PC, only the code_B.py
doesn’t work on Pi. Also, to add to the weirdness code_B.py
was working yesterday on the same Pi.
I’m using the latest Raspian Buster OS.
Thanks.
Issue Analytics
- State:
- Created 3 years ago
- Comments:7
MAVSDK needs to receive the data from PX4. Until it does, if you call
get_identification()
, it will raise an error (that you should catch and act accordingly). My feeling is that for some reason, sometimes you callget_identification()
before the information has reached MAVSDK from PX4 (either the message gets lost, or takes time to be sent, whatever).So you may need to try multiple times, or just to wait a bit longer before you call
get_identification()
.Ok thanks will implement error handling henceforth on every await calls. Thanks for the explanation.