Starting Gazebo and PX4 separately

Dear all

I am following the instructions in:
https://dev.px4.io/simulation-gazebo.html => Section Starting gazebo and PX4 separately

When I run
make posix_sitl_default gazebo_none_ide

I get
ninja: error: unknown target ‘gazebo_none_ide’
make: *** [posix_sitl_default] Error 1

What is the correct target?

As an aside would be grateful for tips on how to find a list of valid targets for posix_sitl_default

Thanks
Eduardo

I’m not sure about that special target to run gazebo separately, but if you go into the build directory (build_posix_sitl_default) and run ninja -t targets you can get a list of all targets.

gazebo: phony
gazebo___callgrind: phony
gazebo___ddd: phony
gazebo___gdb: phony
gazebo___ide: phony
gazebo___lldb: phony
gazebo___valgrind: phony
gazebo_iris: phony
gazebo_iris_callgrind: phony
gazebo_iris_ddd: phony
gazebo_iris_gdb: phony
gazebo_iris_ide: phony
gazebo_iris_lldb: phony
gazebo_iris_opt_flow: phony
gazebo_iris_opt_flow_callgrind: phony
gazebo_iris_opt_flow_ddd: phony
gazebo_iris_opt_flow_gdb: phony
gazebo_iris_opt_flow_ide: phony
gazebo_iris_opt_flow_lldb: phony
gazebo_iris_opt_flow_valgrind: phony
gazebo_iris_valgrind: phony
gazebo_plane: phony
gazebo_plane_callgrind: phony
gazebo_plane_ddd: phony
gazebo_plane_gdb: phony
gazebo_plane_ide: phony
gazebo_plane_lldb: phony
gazebo_plane_valgrind: phony
gazebo_solo: phony
gazebo_solo_callgrind: phony
gazebo_solo_ddd: phony
gazebo_solo_gdb: phony
gazebo_solo_ide: phony
gazebo_solo_lldb: phony
gazebo_solo_valgrind: phony
gazebo_standard_vtol: phony
gazebo_standard_vtol_callgrind: phony
gazebo_standard_vtol_ddd: phony
gazebo_standard_vtol_gdb: phony
gazebo_standard_vtol_ide: phony
gazebo_standard_vtol_lldb: phony
gazebo_standard_vtol_valgrind: phony
gazebo_tailsitter: phony
gazebo_tailsitter_callgrind: phony
gazebo_tailsitter_ddd: phony
gazebo_tailsitter_gdb: phony
gazebo_tailsitter_ide: phony
gazebo_tailsitter_lldb: phony
gazebo_tailsitter_valgrind: phony
gazebo_typhoon_h480: phony
gazebo_typhoon_h480_callgrind: phony
gazebo_typhoon_h480_ddd: phony
gazebo_typhoon_h480_gdb: phony
gazebo_typhoon_h480_ide: phony
gazebo_typhoon_h480_lldb: phony
gazebo_typhoon_h480_valgrind: phony

Ideally I’d like to find a better way to find and run the different simulator and model combinations, but this works for now.

Very helpful, thanks Daniel.

How do you go about debugging when in SITL mode with Gazebo? What command/s do you use?

Thanks

Typical gdb usage. Set a breakpoint and step through as needed. Depending on what you’re doing or looking for it can be easier to insert a printf.

1 Like

I assume you launch gazebo and PX4 separately?
If so :
What binary and arguments do you use to launch PX4 and how do you launch gazebo separately?
Could you send me an example?

After digging up in the makefile and in the stil_run.sh I’ve come up with a pretty circuitous way to do it, and I suspect there’s simpler ways to do it (specially the gazebo part).

I set the following as the Debug Command in the IDE (Netbeans in my case)

Firmware/build_posix_sitl_default/src/firmware/posix/px4 posix-configs/SITL/init/lpe none gazebo Firmware Firmware/build_posix_sitl_default

and then start gazebo on a terminal like this:

$ source /Users/ealdaz/Documents/PX4/FirmwareFork/Tools/setup_gazebo.bash /Users/ealdaz/Documents/PX4/FirmwareFork /Users/ealdaz/Documents/PX4/FirmwareFork/build_posix_sitl_default

$ gazebo --verbose /Users/ealdaz/Documents/PX4/FirmwareFork/Tools/sitl_gazebo/worlds/plane.world &

Thanks
Eduardo

You can run it altogether by adding _gdb to the target.

make posix_sitl_default gazebo_iris_gdb

We should go through and add better self explanatory helper targets (or scripts) to make it trivial to run (and debug) these things independently.

Ah, I see, you’re running gdb on the command line… I was thinking of running it inside my IDE.

How do you switch between the nsh shell and the gdb shell ? Do you simply interrupt the process with CTRL+C ?

Oh, I see now… if I run
make posix_sitl_default gazebo_iris_ide

It starts gazebo with the right configuration ( so avoids having to enter all the commands directly like I had) and then also provides executable and parameters to enter in the IDE in the line that starts with:
SITL COMMAND:

There are 2 solutions

1- First solution

-open your terminal in the Firmware folder , type
export GAZEBO_PLUGIN_PATH=${GAZEBO_PLUGIN_PATH}:build/posix_sitl_default/build_gazebo
gazebo Tools/sitl_gazebo/worlds/iris.world --verbose

-it is suggests to open new terminal , type
make posix_sitl_default gazebo no_sim=1

Second solution

-set the environment varliabe
GAZEBO_MODEL_PATH=Tools/sitl_gazebo/models

-run gazebo with the desired world
export GAZEBO_MODEL_PATH=Tools/sitl_gazebo/models
gazebo Tools/sitl_gazebo/worlds/iris.world

make posix_sitl_default gazebo no_sim=1