I am trying to run a multi vehicle simulation using gazebo garden (gz) without ROS. I want to run these vehicles on a host machine and connect remotely to a machine running a GCS via UDPclient. Currently, I am able to run multiple instances of PX4 with gazebo by starting a new terminal for each instance and running:
While this handles port deconfliction, it seems to be broadcasting the MAVlink messages aimlessly. I would like it to only broadcast once connected via UDPclient. I’d also like to be able to specify the ports used. Any help or documentation on this would be greatly appreciated and please let me know if I can clarify any further. Thanks!
Sorry for the confusion, I’m pretty new to PX4 in general. It’s important to be able to spawn the vehicles in a single command (or bash script if needed) as I will be spawning many vehicles. I’d then like to connect on a GCS from another computer, regardless of that computers IP address (on the same network of course). I’m not sure if mavlink commands within an already launched vehicle can accomplish this. Please let me know if you think I am missing something.
Remember to put a delay between the first spawn command and the second: you want gazebo to be full loaded before spawning the other vehicles otherwise you PX4 SITL startup script will fail to detect the starting gazebo instance and will attempt to start a second one.
Got it, understood about the bash script. I believe the need for this eliminates the possibility of sending individual mavlink commands like -t and -c once the vehicles have spawned though, considering the scale (there may be dozens or hundreds of vehicles).
In regard to the UDPclient requirement, yes it is critical to the application. For a bit more context, I can give an example use case. 100 SITL vehicles will be started from a single machine and then 4 separate machines running a GCS will connect to 25 vehicles each, having been given the udp port to connect to and the ip address of the host machine running the SITL vehicles. This is why the UDPclient requirement exists.
Now, after more experimentation, it does seem like I can connect to QGC (and the other GCS needed for this project) on a different computer. I think the issue was that I was testing with QGC, which automatically listens for MAVlink messages on remote port 14550, so my vehicles were auto connecting without me doing anything. The other GCS does not do this and I can manually connect to each via their UDP port and host IP address. If I do need to edit that remote port 14550, it seems I can do that in the startup script.