-
-
Notifications
You must be signed in to change notification settings - Fork 594
Closed
mavlink/MAVSDK-Python
#781Description
I've been having a strange issue: On windows I run a mission planner SITL simulation to which I connect with mavsdk_server and then talk to via python. If and only if stdout=subprocess.PIPE is set in the launch command and the mission planner simulation is started after mavsdk_server was started waiting for connection, the incoming packets freeze after exactly 13 seconds.
Reproduction steps
- Tested on Windows 10.0.19045 with pycharm 2024.2.4 community
- Download mavsdk_server_win32.exe https://github.com/mavlink/MAVSDK/releases/download/v3.6.0/mavsdk_server_win32.exe (version 3.6.0) into the folder of my example script
- Run my example script
- Open mission planner, start a plane SITL simulation with stable
- Press CTRL-F -> Mavlink -> Set up forwarding to UDP Outbound 14552 127.0.0.1 with write access on
- Observe that the script starts printing position packets for some seconds, often exactly 13, then stops permanently.
- Relaunch the script unchanged and observe it now continuously prints data as it was launched after a SITL connection was immediately available
This issue does not occur if the stdout line is not set. This however makes mavsdk print into the normal python console.
I have confirmed this issue exists with the following combinations of versions:
mavsdk-python / mavsdk_server
3.5 / 3.6
3.6 / 3.6
3.6 / 3.7.2
example script:
import asyncio
import subprocess
from dataclasses import dataclass
from typing import List
from mavsdk import System
@dataclass
class Settings:
mavlink_vehicle_address: str
mavsdk_server_file_name: str
mavsdk_server_port: int
async def telemetry_worker(drone: System, stream_name: str) -> None:
async for msg in getattr(drone.telemetry, stream_name)():
print(msg)
async def main(settings: Settings, selected_streams: List[str]) -> None:
with subprocess.Popen(
[settings.mavsdk_server_file_name,
f"-p {settings.mavsdk_server_port}",
settings.mavlink_vehicle_address],
stdout=subprocess.PIPE # if this is uncommented, mavsdk really likes to freeze up.
) as mavsdk_server_process:
await asyncio.sleep(2)
drone = System(mavsdk_server_address="localhost", port=50051)
await drone.connect()
print("connected")
tasks = [
asyncio.create_task(telemetry_worker(drone, s))
for s in selected_streams
]
await asyncio.gather(*tasks)
if __name__ == "__main__":
settings_ = Settings(
mavlink_vehicle_address="udp://:14552",
mavsdk_server_file_name="mavsdk_server_win32.exe",
mavsdk_server_port=50051
)
# possible streams can be found at https://mavsdk.mavlink.io/main/en/cpp/guide/telemetry.html
streams = [
"position",
# "fixedwing_metrics",
# "raw_imu",
# "battery",
# "armed",
# "attitude_euler",
# "flight_mode", # not compatible with ardupilot flight modes
# "health",
# "rc_status"
]
asyncio.run(main(settings_, streams))Metadata
Metadata
Assignees
Labels
No labels