Use custom world with ROS2 and Gazebo11

Hello, I would like to use my custom world in a simulation.
With ROS1 and mavros is straightforward and I can do it, but how can I do it with

make px4_sitl_default gazebo-classic

I have try with the standard PX4 worlds and I can use them like

make px4_sitl_default gazebo-classic__wharehouse

But if I try with another one like simple_obstacle.world from the PX4-Avoidance package I get the following error:

ninja: error: unknown target 'gazebo-classic_iris__simple_obstacle'
make: *** [Makefile:227: px4_sitl_default] Error 1

I have use this command:

make px4_sitl_default gazebo-classic_iris__simple_obstacle

and I have add (after PX4 model generation) the files in the worlds and models PX4-Avoidance folders inside the PX4 respective ones.

What is the correct procedure to use custom worlds?

Have you added your custom world to the list of targets?

Thanks I was missing that part!

Hey I am having a similar issue, except I am not using gazebo-classic, Iā€™m using gz. I put my custom world to the worlds directory, but I cannot find the list of targets cmake file for gz. Do you have any idea where this file exists? Or if there is a different step that i am missing?

According to the documentation on adding new worlds and models, all you should need is to add the sdf to the gz worlds directory. No need to modify a cmake file like with gazebo-classic.
You may need to specify the world using the environment variable PX4_GZ_WORLD in your make command. For example: PX4_GZ_WORLD=custom make px4_sitl gz_x500
Though it seems make px4_sitl gz_x500_custom should also work.

1 Like