Fixed Wing HITL with Gazebo

I have a Fixed Wing model built in Gazebo to use with HITL in a Pixhawk 5x. If I select the HILStar (Xplane) while the Pixhawk has the original firmware PX4 Pro Stable Release v1.12.3 it works well, the motors move in the simulation. If I make a new firmware using
make px4_fmu-v5x_default
and I uploaded through QGC the motors don’t respond, even when I select the same HILStar.

Something I noticed is that when using the custom firmware sometimes I cannot see the topic /gazebo/command/motor_speed
in gazebo and I just see
/gazebo/command/.

Something else is that this folder:
PX4-Autopilot/build/px4_sitl_default/build_gazebo
does not exist in this folder:
PX4-Autopilot/build/px4_fmu-v5x_default
I wonder if I missing something when I make px4_fmu-v5x_default

Also before starting the HITL simulation I tried the following:
~/PX4-Autopilot$ DONT_RUN=1 make px4_fmu-v5x_default gazebo
but I get this error:

ninja: error: unknown target 'gazebo', did you mean 'geo'?
make: *** [Makefile:230: px4_fmu-v5x_default] Error 1

Since my model needs two independent ailerons, basically I could just modify the HILStar mixer or add a new airframe, but this needs a new firmware to be uploaded which is giving the problem.

I would greatly appreciate some suggestion or some workaround.

1 Like

Hi, did you enable HITL as discussed in Hardware in the Loop Simulation \(HITL\) | PX4 User Guide ?

Note, make px4_fmu-v5x_default should be all you need to do for building (or just take the default). Indeed even the enabling HITL probably shouldn’t be needed if you select the HIL target

Hi @hamishwillee, thanks for your reply.

Yes, I can go back and forward uploading to the Pixhawk the Stable_Release_v1.12.3 and px4_fmu-v5x_default.px4 and HITL only works with the Stable_Release.

Actually, to narrow it down further, the same situation happens with the default airframes. For example if I select standard_vtol_hitl gazebo model with the HIL Standard VTOL QuadPlane it works well with Stable Release but not when upload a new firmware to the Pixhawk.

It seems like when the new firmware is generated, something related with Gazebo is missing.

There shouldn’t be anything related to gazebo in the firmware “specifically” as I understand it.

@dagar Can you advise on this HITL query?

1 Like

I think so too @hamishwillee,if is nothing with the firmware running in the Pixhawk, maybe is something related with this part I mentioned above?

This folder:
PX4-Autopilot/build/px4_sitl_default/build_gazebo
does not exist in this folder:
PX4-Autopilot/build/px4_fmu-v5x_default

I hope @dagar can help us here.

@hamishwillee, @dagar I just noticed that stable version v1.12.3 does not contain some parameters like SYS_CTRL_ALLOC and all the Geometry parameters. So I was wondering if there are more things to be done before running HITL with another firmware.

Just in case it could helps to know what could be the problem, exploring this possibility I uploaded a firmware, selected the HILStar, which is the one I am using, enabled SYS_CTRL_ALLOC thinking that I may need to assign HIL Outputs, but in the Actuators Tab in QGC there is nothing:

Hi, so I think part of the issue has been solved.
When uploading the new firmware (Which has a lot of new parameters compared with the stable version) the parameter SYS_CTRL_ALLOC needs to be Enabled and the servos and motors need to be set in the Actuators Tab that shows after enabling the parameter.
After this, I was able to download new firmwares with new airframes but when I connected to a real airplane, the actuators did not respond, so additionally, in the file:
src/modules/commander/state_machine_helper.cpp
In this part, the line armed.lockdown = true needs to be commented

if (hil_enabled) {
			/* enforce lockdown in HIL */
			//armed.lockdown = true; //This need to be commented
			status_flags.system_sensors_initialized = true;

And finally once the simulation is running and connected, in QGC I had to go to Safety Tab and Disable HITL so the real actuators start to receive signals.

Now I have a Fixed Wing in Gazebo working along with a real aircraft, but there still is a problem. In the Actuator Tabs, I only see Main outputs and we need also to use Auxiliar ouputs. Does anybody knows how to Enable Auxiliar Outputs?

To update,
I was told in the slack channel that there was a new release with some HITL fix. I pulled that one, compile, upload and the Aux Tab was there visible but still with no signals going out through Auxiliar. I added a line in the file:
ROMFS/px4fmu_common/init.d/rc.interface
like in the image:
image
with this I have HITL simulation working simultaneously with the real aircraft but only in manual or stabilized mode. If I run a Mission, the real outputs don’t move and they keep reacting to the joystick.
I hope @hamishwillee could give me some ideas about what to try. I think also that this could be very beneficial for the community.

2 Likes

Hi, this helps to allow the actual motors to spin while in the HIL Airframe but my drone in the simulation stopped responding to my inputs instead. Seems like its either one way or the other.