Pxh shell doesn't launch when I run with gazebo

Hello everyone!

I am new to Ros/Gazebo/PX4 stack, and am facing some issues. I have installed PX4/Ros/Gazebo on a fresh Ubuntu 18.04 and I am trying to run the simulation examples, using make px4_sitl on it.

When I run the gazebo simulation on it, by typing in make px4_sitl gazebo, Gazebo launches but the pxh shell doesn’t come up. I tried the same with jmavsim using make px4_sitl jmavsim, but in that case the pxh shell came and it performed a takeoff well.

I have installed/reinstalled PX4/Ros/Gazebo multiple times now, and am still wondering what could be the issue now.

My environment variables are set as below:

source ~/PX4-Autopilot/Tools/setup_gazebo.bash ~/PX4-Autopilot ~/PX4-Autopilot/build/px4_sitl_default
export ROS_PACKAGE_PATH=$ROS_PACKAGE_PATH:~/PX4-Autopilot/Tools/sitl_gazebo
export GAZEBO_PLUGIN_PATH=$GAZEBO_PLUGIN_PATH:/usr/lib/x86_64-linux-gnu/gazebo-9/plugins
export GAZEBO_MODEL_PATH=$GAZEBO_MODEL_PATH:/home/major/catkin_ws/src/px4_fast_planner/models

The logs for the gazebo simulation are below. I have to interrupt the execution, because nothing happens, even after 10-20 minutes:

major@mewmew:~/PX4-Autopilot$ make px4_sitl_default gazebo
[0/4] Performing build step for 'sitl_gazebo'
ninja: no work to do.
[3/4] cd /home/major/PX4-Autopilot/bui...r/PX4-Autopilot/build/px4_sitl_default
sitl_bin: /home/major/PX4-Autopilot/build/px4_sitl_default/bin/px4
debugger: none
program: gazebo
model: none
world: none
src_path: /home/major/PX4-Autopilot
build_path: /home/major/PX4-Autopilot/build/px4_sitl_default
empty model, setting iris as default
GAZEBO_PLUGIN_PATH :/home/major/PX4-Autopilot/build/px4_sitl_default/build_gazebo:/usr/lib/x86_64-linux-gnu/gazebo-9/plugins:./build/px4_sitl_default//build_gazebo:/home/major/PX4-Autopilot/build/px4_sitl_default/build_gazebo
GAZEBO_MODEL_PATH /home/major/gazebo_ws/gazebo_models::/opt/ros/melodic/share/jderobot_assets/models:/home/major/PX4-Autopilot/Tools/sitl_gazebo/models:/home/major/catkin_ws/src/px4_fast_planner/models:./Tools/sitl_gazebo/models:/home/major/PX4-Autopilot/Tools/sitl_gazebo/models
LD_LIBRARY_PATH /home/major/catkin_ws/devel/lib:/opt/ros/melodic/lib:/home/major/PX4-Autopilot/build/px4_sitl_default/build_gazebo:./build/px4_sitl_default//build_gazebo:/home/major/PX4-Autopilot/build/px4_sitl_default/build_gazebo
empty world, setting empty.world as default
Using: /home/major/PX4-Autopilot/Tools/sitl_gazebo/models/iris/iris.sdf
SITL COMMAND: "/home/major/PX4-Autopilot/build/px4_sitl_default/bin/px4" "/home/major/PX4-Autopilot/build/px4_sitl_default"/etc -s etc/init.d-posix/rcS -t "/home/major/PX4-Autopilot"/test_data
INFO  [px4] Creating symlink /home/major/PX4-Autopilot/build/px4_sitl_default/etc -> /home/major/PX4-Autopilot/build/px4_sitl_default/tmp/rootfs/etc

______  __   __    ___ 
| ___ \ \ \ / /   /   |
| |_/ /  \ V /   / /| |
|  __/   /   \  / /_| |
| |     / /^\ \ \___  |
\_|     \/   \/     |_/

px4 starting.

INFO  [px4] Calling startup script: /bin/sh etc/init.d-posix/rcS 0
Info: found model autostart file as SYS_AUTOSTART=10016
INFO  [param] selected parameter default file eeprom/parameters_10016
[param] Loaded: eeprom/parameters_10016
INFO  [dataman] Unknown restart, data manager file './dataman' size is 11798680 bytes
INFO  [simulator] Waiting for simulator to accept connection on TCP port 4560
Gazebo multi-robot simulator, version 9.16.0
Copyright (C) 2012 Open Source Robotics Foundation.
Released under the Apache 2 License.

[Msg] Waiting for master.
[Msg] Connected to gazebo master @
[Msg] Publicized address:

(gzclient:5976): Gtk-WARNING **: 01:34:11.226: Theme parsing error: gtk.css:6329:10: 'height' is not a valid property name
^CERROR [px4] Startup script returned with return value: 2
/home/major/PX4-Autopilot/Tools/sitl_run.sh: line 238: kill: (5937) - No such process
ninja: build stopped: interrupted by user.
Makefile:217: recipe for target 'px4_sitl_default' failed
make: *** [px4_sitl_default] Interrupt

I had the same issue where launching PX4 SITL gave me the info message that is also present in your log:

INFO [simulator] Waiting for simulator to accept connection on TCP port 4560

I changed this so that the simulator would connect by changing it to connect on UDP port 14560.

This works on the latest master branch (commit Dec 14 13:04:01). I tried testing the latest stable release for some reason did not work.

in /build/px4_sitl_default/etc/init.d-posix/rcS after line 107 add the following:
simulator_udp_port = $((14560+px4_instance))

and change line 213 to:
simulator start -u $simulator_udp_port

in /Tools/sitl_gazebo/models/iris/iris.sdf (or whichever PX4 model you are working with )change line 506 to

The simulator now connects and I am able to do commands such as commander takeoff and use mavros in OFFBOARD mode.

I am using an Nvidia Jetson AGX Xavier. Good luck!