How to connect to the Mission Planner's simulator from dronekit?

I’m writing dronekit scripts for the ArduPilot Copter and using Mission Planner to observe the behavior of my scripts. To test the scripts, I’ve been trying to use SITL simulator, but it has way longer initialization time and is generally more cumbersome to work with than the one in Mission Planner’s simulation tab, which takes 5-10 seconds to initialize with a couple of clicks. The only thing left to figure out is how can I connect to the simulator that the Mission Planner starts? I tried the host 127.0.0.1 with ports 14550, 5760, 5762, 5763 - none of which has worked. Perhaps I need to use mavproxy? I would appreciate any suggestions that could help resolve this issue.

TCP/5760
BUT you have to start with the correct parameters and if you start it from Mission Planner, you have to disconnect first.

ArduCopter.exe" -M+ -O0,0,0,0 -s1 --uartA tcp:0 --defaults “C:\Users<username>\Documents\Mission Planner\sitl\default_params/copter.parm”

1 Like

Turns out the issue was the fact that I wasn’t explicitly specifying the tcp protocol. Using connection string as “tcp:127.0.0.1:5762” solved my problem. Also by using port 5762 in the dronekit code and I was able to monitor the mission progress in the Mission Planner without disconnecting.