Send mavproxy commands through Python scripts

Hi there,

I am using sim_vehicle.py in my drone simulator combining AirSim and Unreal Engine.

I have a .kml file containing targets and non-fly zones I want to display on the map created by sim_vehicle.py. I am starting sim_vehicle.py with “–map” option, and then I manually enter the following commands in the terminal to display the info from the .kml file:

module load kmlread
kml load /path_to_my_file/my_file.kml

Is there a way to run these commands automatically from a Python script? Or add options to sim_vehicle.py launching commands to display this directly at startup?

Thank you for your help!

You can use --mavproxy-args to pass commands from SITL to mavproxy and --cmd to execute mavproxy commands after startup:
sim_vehicle.py --mavproxy-args='--cmd="module load kmlread; kml load /path_to_my_file/my_file.kml"'