I am writing a python script to simulate several flights of drones and send their telemetry to a mqtt broker.
I have already used the make command to create the environment and I am able to start the simulator in the origin of the default world in Gazebo. The problem is I am not able to establish the initial position of the vehicle when launching the simulator afterwards.
I launch the simulator like this:
px4_path = "/home/davmasero/PX4-Autopilot/build/px4_sitl_default/bin/px4"
env = os.environ.copy()
env["PX4_SYS_AUTOSTART"] = "4001" # Ajusta esto segĂșn tu configuraciĂłn
env["PX4_SIM_MODEL"] = "gz_x500" # Ajusta esto segĂșn tu modelo
x, y, z = latlon_to_cartesian(latitude, longitude, altitude)
env["PX4_GZ_MODEL_POSE"] = f"{x},{y},0,0,0,0"
env["PX4_SIMULATOR"] = "gz"
env["HEADLESS"] = "1"
subprocess.Popen([px4_path], env=env)
The âPX4_GZ_MODEL_POSEâ is supposed to reset the starting position of the vehicle with respect to the gazebo origin (which I have modified in the file, btw). Since the gazebo world coordinates have the x,y,z format, I am projecting the lat lon coordinates and setting them up with respect to the origin of the world. The problem is that, although the simulator starts correctly when launching it, for positions like:
[init] PX4_GZ_MODEL_POSE set, spawning at: 1985.7363611118635,-3075.866821288131,0,0,0,0
I find the following error:
pxh> WARN [health_and_arming_checks] Preflight Fail: ekf2 missing data
Or other arming errors which make the simulator crash.
I really donât know what the problem might be, since Iâm just setting a POSE wrt to the origin of the world and the format is correct. Is there any other way to set the home point correctly?