Trouble running custom scripts with SITL

Hey guys!

I’m currently creating custom scripts for a project and I want to use SITL to test them. I’m currently using DroneKit and SITL with QGroundControl. The goal was/is to run Python scripts utilizing DroneKit to interact with the SITL drone.

Issue Summary: When running sim_vehicle.py, MAVProxy starts with the default configuration:

  • --out 127.0.0.1:14550
  • --master tcp:127.0.0.1:5760
  • --sitl 127.0.0.1:5501
  • --out 127.0.0.1:14551

My DroneKit script is set to connect to 127.0.0.1:14551. However, upon execution, I’m getting a timeout error, specifically: dronekit.TimeoutError: wait_ready experienced a timeout after 30 seconds..

QGroundControl also disconnects from SITL whenever I initiate my dronekit script.

Steps Taken:

  1. Ensured sim_vehicle.py is running (QGroundControl visualizes the drone) before initiating the script.
  2. Confirmed no other applications/scripts are trying to connect to port 14551.
  3. Tried connecting the script to 127.0.0.1:14550 (after closing QGC) with the same issue persisting.
  4. Checked for any firewall or security software that might block the ports - none found.

Would anyone be able to provide guidance on how to resolve this issue? Are there any nuances that I should be aware of?

Thank you.

Try setting the timeout parameter in your connect method to something much higher than the default 30 seconds.

newdrone.connect(ip=‘tcp:127.0.0.1:5053’, timeout=240, wait_ready=True)

The issue seems to be caused by the calibration of the sitl drone taking too long and therefore the parameter list never actually gets sent before the timeout. You can show that this is the case by doing one of a couple of things. Change wait_ready=False. Your drone will function but will not be stable or be able to parse a GPS position because it took off before the information was received. Or, you can customise the data in the wait_ready parameter like wait_ready=[‘system_status’, ‘gps_0’, ‘armed’, ‘parameter’]. I found when I left out the ‘parameter’ option out, the drone would fly but was unstable as well, whilst all the other data would come through before a timeout.

1 Like