Gazebo HITL not working

I have tried using HITL gazebo without ROS on ubuntu but it seems there is no connection between my hardware and the simulation (or QGC). The are no errors printed at all, but after gazebo opens, there is not response from the pixhawk and there is no response after opening QGC. I am using px4_fmu-v3 and I have followed the HITL SImulation instructions.

I can use SITL gazebo though, so I really don’t know what could be the problem. Is there anything I should look at for possible errors?

Can you please link the docs that you followed and write the commands you tried?

And have you set the param SYS_HITL to 1?

1 Like

I followed these:
https://dev.px4.io/en/setup/dev_env_linux.html

source ubuntu_sim_nuttx.sh
source ubuntu_sim.sh

https://dev.px4.io/en/simulation/hitl.html

source Tools/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default
gazebo Tools/sitl_gazebo/worlds/iris.world

https://dev.px4.io/en/setup/dev_env_linux_ubuntu.html

# Gazebo simulator
sudo apt-get install protobuf-compiler libeigen3-dev libopencv-dev -y
sudo sh -c 'echo "deb http://packages.osrfoundation.org/gazebo/ubuntu-stable `lsb_release -cs` main" > /etc/apt/sources.list.d/gazebo-stable.list'
## Setup keys
wget http://packages.osrfoundation.org/gazebo.key -O - | sudo apt-key add -
## Update the debian database:
sudo apt-get update -y
## Install Gazebo9
sudo apt-get install gazebo9 -y
## For developers (who work on top of Gazebo) one extra package
sudo apt-get install libgazebo9-dev -y

I think that is all of them, but I could be missing some, Sorry.

I have set the SYS_HITL.

Ok, so far so good. And what output do you see when you start it?

There are no messages sent at all. (If i remove the first line I get a message that says it is unable to find the model) The gazebo sim automatically opens. If I open QGC, it just says waiting for connection. The pixhawk has no visible response either.

Ok got it, thanks. I’ll try to reproduce this in the next days when I find time.

Cool, thank you so much!

@isb did you follow what’s in here? https://dev.px4.io/en/simulation/hitl.html#gazebo

From what you have written above, doesn’t seem so.

Which section are you talking about? I followed these instructions the first time I tried.


I assumed that I was supposed to follow these steps the first time and then every other time I wanted to run the simulation I could just do step 6 and 7.

Hi,

I am having the same issue as @isb. I am using at Pixhawk 4 mini (px4fmu-v5) with Firmware 1.8.0. I have followed the same steps outlined in the HITL tutorial link, as well as many other attempts. Like @isb, jMAVSim and Gazebo both work fine in SITL, however when trying HITL QGroundControl can never find a vehicle connection. I am interested if there is a resolution here, as I am having a difficult time debugging this problem. Is there a way to read connection logs?

I also have the same issue as isb, QGroundControl does not connect to the Gazebo simulation. I have disabled all comm links except UDP as mentioned in the tutorial. The parameter “SYS_COMPANION” does not seem to be available in the latest Gazebo version so I ignored it.
Did you solve this?

@sritank which tutorial are you following? Make sure it is the latest (or fits your firmware version):
https://dev.px4.io/master/en/simulation/hitl.html#gazebo

Did anyone managed to get Gazebo HITL working? I have also tried the following tutorial but it’s not working
https://dev.px4.io/master/en/simulation/hitl.html#gazebo

@Andrew_Mangezi when you say “not working” that doesn’t tell me what the problem is. So please describe the steps you are doing and what “doesn’t work”.

@JulianOes I followed the tutorial that I mentioned about but when I ran the last 2 commands

(1) source Tools/setup_gazebo.bash $(pwd) $(pwd)/build/px4_sitl_default

(2) gazebo Tools/sitl_gazebo/worlds/iris.world,

Gazebo simulator started but it didn’t load the vehicle and the GCS kept waiting for the vehicle to connect.

2 Likes

Ok, and you did the steps where you have to edit the file to set the connection correctly? And you are sure the connection is possible and QGC is not running, so not blocking the connection?

Yes I changed SerialEnabled and HIL_MODE in iris.sdf to true and checked if the serial connection was correct using the command below:
dmesg | grep “tty”` and also QGC wasn’t running.

Ok, so what connection did you fill in? And did you make sure not to rebuild after the change? Otherwise this fails gets overwritten.

@JulianOes I am suffering from the same problem. I followed all the process mentioned in this link: HITL Simulation · PX4 Developer Guide and as soon as my HITL starts running, nothing shows up. There are no vehicle in Gazebo and no connection. Attached is the image of what I am getting.

1 Like

When following the docs make sure to look at the correct version. @mehdi786 you posted the link for v1.9. (I’m not sure if that’s the reason, but just saying.)

Is the airframe and SYS_HITL param set correctly?