Using PX4 models as actors

Greetings,
We are currently trying to use Gazebo combined with ROS to create a scenario where our “hunter” drone Typhoon H480 views and captures the image of another drone in the simulation environment. Initially we have spent some time using multi-vehicle launch options which were actually quite nice. However, we were advised not to use two controllable drones, but use one instead with a Gazebo actor.
A Gazebo actor is basically an animated model that can be given a path which it smoothly transitions between its points. This serves our purpose, since we only want to capture images and use these to create our data set which we further intend to use to train our model.
These being said, we want to use Iris as the target drone, the dummy model which moves around. I was able to modify typhoon_h480.world as follows to add the box example that was provided in the following link:


And the result is:

This is satisfying for us, except the fact that we want to replace the box with Iris model. This looked trivial, but I then realized when we use make commands which invokes sitl_run.sh script, it actually doesn’t add drone models to world as we guessed.
So my question is, could I add a PX4 model as an animated model (actor) in gazebo? If so, could you maybe show me some pointers? I am guessing it has something to do with plugins, but my searches and repeated read-through of the PX world and gazebo actor tutorials were a dead end.
Thanks in advance, Taha.

Is the question more how to “animate” the iris?

If so, I think the tutorial you have posted is more or less relevant. You can look at how the script is written for the actor in gazebo.

However, I am not sure what advantages you have by animating the iris vs just spawning another iris SITL model in the world. This would lead to much less work since you don’t need to “animate” the vehicle dynamics anymore.

Hi @Jaeyoung-Lim,
Before anything, I would like to say that I greatly appreciate your anticipation regarding anything related to PX4 both here and on GitHub, you are actually making me consider being part of the contributors even when our senior project finalizes.
That being said, the part I had issue with was to actually not about adding animation (which is indeed straightforward) but adding the model to world xml. With include, it just places a static object. For animation, script part was quite straightforward, but what I couldn’t manage (after trying to work with different combinations of uri/filename/skin within actor tag, XML is hard to me, especially when I can’t find a decent document :frowning: )
About your recommendation regarding just using multi-vehicle setup, I actually agree with you. However, during the meeting with the “supervisor company”, the dude apparently recommended against it since “it would be less intense in terms of hardware requirements”.
The more drones you add to the world with their own nodes and communication the more, the laggy it gets. Don’t get me wrong, I think ros nodes are probably not that HW intensive, especially MAVROS etc., but problematic thing is more relevant to the simulation I think.
Personally on my computer (Ryzen 5 3600, 6Core 12Thread @ 3.60 Ghz, Nvidia GTX 1660 TI, 16 GB Ram @ 3200 Mhz) I am fine, but other members of the team apparently have performance issues when they run Gazebo + ROS + QGroundControl. Adding some online conference with screen share (which we avoid unless we have to, basically only I can do all of these at the same time :smiley: ) it gets laggy. I don’t have the whole conversation since I couldn’t attend that meeting, but I suppose the advice of using actors raised when one of my friends told about lag.
Anyways, these were a bit irrelevant to PX4 context, since it doesn’t necessarily report a performance issue, I just wanted to provide background information regarding why it was possibly recommended.
About adding Iris or any other PX4 vehicles, I just need tips regarding how I could add the model to the world, within actor tags, so that I can place positions (such as making “pray” or “rabbit” drone follow a path that is like “8”) and capture images. I have inspected model directories within gazebo_sitl and some of them are .dae (parts of the drone, no mesh for the whole object since it is animated I think). There also seems to be config, jinja and .sdf files which I couldn’t directly made use of.
I can’t wait to generate our data set and share our model, accuracy results using this method.
If you think this is not viable and we should:

  • Launch using multi-vehicle setup as I intended to do so initially,
  • Use Typhoon H480 + (Iris or anot other UAV model) within QGroundControl
  • Using various missions, MAVROS control or manual control via joypad, capture images of the “prey” drone.

For me, this path is nicer, since we can just use two different MAVROS nodes to control both “cat” and “mice” drone. However, with the use of actors, we could just edit typhoon_h480_world, adding some scripted movement and fly around it with Typhoon 480 to capture images. I will look further into these .sdf files, seeing what kind of tags I can use.
I know these lengthy posts naturally reflect motivation and anticipation on my part which I can imagine you appreciate, but at the same time I may not be efficient enough expression my thoughts. In that regard I also apologize for taking your time. I hope these discussions will still prove to be useful for people that work with PX4Autopilot, MAVROS, Gazebo and other relevant components. :slight_smile:

The more drones you add to the world with their own nodes and communication the more, the laggy it gets. Don’t get me wrong, I think ros nodes are probably not that HW intensive, especially MAVROS etc., but problematic thing is more relevant to the simulation I think.
Personally on my computer (Ryzen 5 3600, 6Core 12Thread @ 3.60 Ghz, Nvidia GTX 1660 TI, 16 GB Ram @ 3200 Mhz) I am fine, but other members of the team apparently have performance issues when they run Gazebo + ROS + QGroundControl. Adding some online conference with screen share (which we avoid unless we have to, basically only I can do all of these at the same time :smiley: ) it gets laggy. I don’t have the whole conversation since I couldn’t attend that meeting, but I suppose the advice of using actors raised when one of my friends told about lag.

Can you confirm this lag is also observable when you are spawning multiple gazebo models? I am asking since I can spawn multiple drones without lag as long as the vehicle doesn’t have a camera attached. On my desktop, I am able to simulate 200 drones without any issues.

Usually what slows your computer down is the rendering of the camera and not the sim

Of course if you think it is worth investing on animating the drone, the decision is yours

We do have camera attached, but in our scenario only on one drone. Later on, indeed we may add more than multiple target drones. About spawning multiple gazebos, could you please elaborate a little? Since so far I have never been able to spawn multiple gazebos. A simple instruction to achieve so would be nice, since it doesn’t allow us to do it currently (not with a method we are aware of).

@bonellia Sorry, I meant multiple gazebo models. For example running the typhoon_h480 alongside an iris model

As a side note, there were two ways to spawn multiple drones. One with no ROS (as shown on the documents with the script) and one with launch file manipulation. I suppose both yields the same result in the end (I inspected the scripts a bit). When you spawn 200 drones, do you also have UDP/TCP sockets attached to them to be used with MAVROS?

I will need to ask my peers and see what they experience. I get the impression this whole discussion will lead to a conclusion where we will be using multi-vehicle setup. :slight_smile:

Without mavros - I ran it gazebo_sitl_multiple_run.sh You can also attach mavros onto this if you want

I have also shared the discussion with the said individual, if they can’t provide assist with “editing the XML”, I’ll move forward using multi-vehicle launch option.