How to run px4_sitl using gz garden with specific world?

hello guys
I’m new to PX4,My Ubuntu version is 22.04 and I’m using Ros Humble.
My project is to simulate a drone using Ros, PX4 and Gazebo that can land on it by detecting a marker.
So I need px4_sitl to simulate the drone and control it. For me, there are 2 choices, one is Gazebo Garden and one is Gazebo Classic, which according to the description of the official document of PX4, Gazebo Classic does not work on Ubuntu 22.04.


which is in the link below:
https://docs.px4.io/main/en/ros/ros2_comm.html
So I’m using Gazebo Garden, I want to know how can I spawn a model for example gz_x500 in a custom world?
According to the official PX4 document, we can run the custom world with the PX4_GZ_WORLD parameter.

PX4_GZ_WORLD=windy make px4_sitl gz_x500

I copy the sdf file related to the custom world in the :
PX4-Autopilot/Tools/simulation/gz/worlds directory
and when I execute the above command, firstly, some models in the custom world are not loaded, secondly, the drone is also gz_x500 does not spawn either
How can I solve this problem? Thank you in advance for your help
If anyone knows a project similar to mine, I would be grateful if you could share it with me

Can anyone answer my question?

Hi @Alireza_Falaki , could you share the output of

PX4_GZ_WORLD="your custom world" make px4_sitl gz_x500

Then, did you add all the required plugins in your world file?

Note also that the interaction between PX4 and Gazebo changed over the last weeks if you are using main. Please read the updated documentation Gazebo Simulation | PX4 User Guide (main)

Hello @Benja
thanks for your help.
Yes, you are right, recently a series of changes have been applied to the repository and document.
So I wanted to clone the newer version of PX4, but unfortunately I encountered new errors
When I execute the command make px4_sitl, I encounter the following errors

make px4_sitl
[  0%] Generating Flight Tasks
[  0%] Built target events_header
[  0%] Built target drivers_board
[  0%] Generating uORB topic headers
[  0%] Built target git_micro_xrce_dds_client
[  0%] Built target parameters_xml
[  0%] Built target ver_gen
Traceback (most recent call last):
  File "/home/alireza/PX4-Autopilot/src/modules/flight_mode_manager/generate_flight_tasks.py", line 23, in <module>
    interpreter = em.Interpreter(output=output_file, globals=em_globals)
AttributeError: module 'em' has no attribute 'Interpreter'
gmake[3]: *** [src/modules/flight_mode_manager/CMakeFiles/flighttasks_generated.dir/build.make:74: src/modules/flight_mode_manager/FlightTasks_generated.hpp] Error 1
gmake[3]: *** Deleting file 'src/modules/flight_mode_manager/FlightTasks_generated.hpp'
gmake[2]: *** [CMakeFiles/Makefile2:7419: src/modules/flight_mode_manager/CMakeFiles/flighttasks_generated.dir/all] Error 2
gmake[2]: *** Waiting for unfinished jobs....
Traceback (most recent call last):
  File "/home/alireza/PX4-Autopilot/Tools/msg/px_generate_uorb_topic_files.py", line 261, in <module>
    generate_output_from_file(generate_idx, f, args.outputdir, args.package, args.templatedir, INCL_DEFAULT, all_topics)
  File "/home/alireza/PX4-Autopilot/Tools/msg/px_generate_uorb_topic_files.py", line 171, in generate_output_from_file
    return generate_by_template(output_file, template_file, em_globals)
  File "/home/alireza/PX4-Autopilot/Tools/msg/px_generate_uorb_topic_files.py", line 186, in generate_by_template
    interpreter = em.Interpreter(output=ofile, globals=em_globals, options={
AttributeError: module 'em' has no attribute 'Interpreter'
[  0%] Generating actuators.json
gmake[3]: *** [msg/CMakeFiles/uorb_headers.dir/build.make:481: uORB/topics/action_request.h] Error 1
gmake[3]: *** Deleting file 'uORB/topics/action_request.h'
gmake[2]: *** [CMakeFiles/Makefile2:4128: msg/CMakeFiles/uorb_headers.dir/all] Error 2
[  0%] Generating output_functions.hpp
[  0%] Built target output_functions_header
[  0%] Built target actuators_json
gmake[1]: *** [Makefile:156: all] Error 2
make: *** [Makefile:232: px4_sitl] Error 2

I think the most important part of this error is the following part:

module 'em' has no attribute 'Interpreter'

So what should I do now?

My problem was incompatibility in the version of empy module, the problem was solved by executing the following commands

pip uninstall em
pip install empy==3.3.4

Now I will follow the official document to solve the problem of adding a new world to PX4ـSITL

1 Like

Same issue here, I tried more than one option, but didn’t work so far.

File “/home/ubuntu/Developer/PX4-Autopilot/Tools/msg/px_generate_uorb_topic_files.py”, line 261, in
generate_output_from_file(generate_idx, f, args.outputdir, args.package, args.templatedir, INCL_DEFAULT, all_topics)
File “/home/ubuntu/Developer/PX4-Autopilot/Tools/msg/px_generate_uorb_topic_files.py”, line 171, in generate_output_from_file
return generate_by_template(output_file, template_file, em_globals)
File “/home/ubuntu/Developer/PX4-Autopilot/Tools/msg/px_generate_uorb_topic_files.py”, line 186, in generate_by_template
interpreter = em.Interpreter(output=ofile, globals=em_globals, options={

AttributeError: module ‘em’ has no attribute ‘Interpreter’

ninja: build stopped: subcommand failed.
Makefile:232: recipe for target ‘px4_sitl’ failed
make: *** [px4_sitl] Error 1

Any suggestion please?

Thank you.