HITL & X-plane 11 & QGroundControl

Hello everyone,

I am using Cube Black, X-plane 11, QGC 4.1.2

I am trying to make quadrotor HITL on X-plane 11.

I made a software, which converts MAVLink packets to UDP datagrams for Xplane and vice versa. Now i am trying to use my HITL configuration w/ QGroundControl. Connection between QGroundControl and my CubeBlack is okay but i can’t command takeoff or any kind of mission.

First of all, which messages are enough to fly my vehicle ?
I am able to send HIL_SENSOR + HIL_GPS or HIL_STATE_QUATERNION messages with frequencies around 80-120 hz.

Secondly, I can control the system with joystick via qground or I can embed a flight route by hard coding to my system, but I cannot send a full mission via qgroundcontrol.

When I send a takeoff command, I can see in the mavlinkinspector of qground that I sent an invalid (NaN) position_target_local_ned message.

Can you help me about this issue?

Best regards.

1 Like

X-plane 11 is not a supported / maintained simulator setup with PX4.

Please check the list of supported simulators: Simulation | PX4 User Guide

Do you know why it is not supported? Cause in past posts i saw some people saying that they are using X-Plane and couldn’t figure out why Px4 stop supporting X-Plane now.

And do you have any idea how can i implement?

Thank you for your fast response.

Regards.

Do you know why it is not supported? Cause in past posts i saw some people saying that they are using X-Plane and couldn’t figure out why Px4 stop supporting X-Plane now.

@Fatih_Ozkan Yes it worked at somepoint, but AFAIK it is no longer maintained.

The main limitation I see with Xplane is that the simulation depends on the rendering rate, while SITL/HITL needs faster simulation update rates to simulate the sensors.

An alternative is the jsbsim implementation, which works with flightgear: GitHub - PX4/px4-jsbsim-bridge: JSBSim bridge for PX4 SITL/HITL simulations If you want to implement the bridge for Xplane, this would be a good reference for you.

2 Likes

Thank you for source.

And can you answer my first question.

Which specific messages i need to fly my vehicle. I determined as HIL_GPS, HIL_STATE_QUATERNION, HIL_SENSOR. Is that right? And i checked the code of JMavSim and few codes of JSBSim. Some sensor, gps values are sending with noise. Is it essential?

@Fatih_Ozkan You can read the documentation on how SITL/HITL works: Simulation | PX4 User Guide

Not sure if you would want to have a noise free simulation - your EKF will still be assuming that your sensor has noise unless you configure otherwise. This will probably end up being “not representative” of the vehicle behaviors you see in the real world

1 Like

I got stucked at even in basics. Now my issue is when i say arm to vehicle it’s not like arming but QGround is showing that vehicle “armed”.
I am trying to make simulation with quad mode with my Quadplane Vtol model.
And in takeoff mode (not just take off in all modes) i think QGroundcontrol can’t send mission command. But also there are no error sign in QGroundControl.

I think its about Position_Target_local_Ned MavLink message. Here is my Position_Target_local_Ned in takeoff mode:

image

@FairweatherIT Which simulator?

Like i said X-plane 11

Hi,

I have done the same thing (bridge mavlink<->xplane 11).
I started with the source of this github project mav2xplane

For your first question:
Only hil_sensor and hil_gps are needed.

2 important things:
this previous messages must always arrive to controller at exact same frequency (in my case 40 Hz). If not, the estimator doesn’t work.
If there no noise on hil_sensor, the estimator doesn’t work.

I had also problem with vibrations see here

To get more information, i used the logs extractor which very useful https://logs.px4.io/

1 Like

@big Would you be able to share the changes on top of mav2xplane?

It would be great if we can get a standard setup running

Thank you for your logical and realistic response. I will dive in.

Appreciate that

Best Regards.

Sorry, i can’t. It’s part of huge internal tool.
ASAP, i’ll try to publish a standalone version of the bridge.

@big
Sir how did you manage time sync.

In mav2xplane scripts i reached this line about time:

static quint64 groundTimeMilliseconds()
{
return static_cast<quint64>(QDateTime::currentMSecsSinceEpoch());
}

But couldn’t find QDateTime.

Can you help me about it?

Regards.

@Fatih_Ozkan
The source depends on framework named Qt.
If you don’t use it, you can use as alternative as QDateTime:
std::chrono:system_clock::now() (STL library)
Good luck!

PS: Every time you see a Qxxx, it’s QT framework

1 Like

@big
Hi, thank you for sharing your experience!

I am trying to build an HIL environment with X-plane 11 & modified QGCv4.0 & modified PX4 v1.11.2.
The ultimate goal is to use my original fluid dynamics simulator instead of X-plane, and mav2xplane project looks excellent to start with.

I have some experience with developing PX4 but not much with Qt, and looking to learn. Could you share the standalone version of the bridge, if available? If not, can you advise what to do or where to look to utilize the bridge?

Thanks.

@takhashi
Hi,
For a standalone version, i’m working (very slowly) on it.
But…
The original et essential part of bridge is : https://github.com/borune-k12/mav2xplane/blob/master/QGC/UAS.cpp
Good luck.

Hi,

Thank you for your advice! I’ll take a look on that part.
Let me know if you completed the standalone version project.

First of all, Thanks for Contributing,

Second,
Can you explain to me how are you make connection between XPlane 11 & QGC v4.1 in ubuntu?
I’ve already download this project: mav2xplan but i cant use it … may you explain to me how to use it , or tell me the steps to make connection between them?

thanks in advance

Hi,

I’m not sure I understand your question. But, I can give you more info:

General Process:

XPlane ⇄ UDP ⇄ Mav2Xplane ⇄ Serial ⇄ PX4.

In depth, the are 2 data flow:

  1. Xplane to PX4 (generate IMU data from Xplane for PX4 EKF)

XPlane → UDP → XPlaneLink.cpp(QGCXPlaneLink::readBytes) → Internal xplane model → Mavlink Msg( UAS.cpp) → Serial → PX4

2.PX4 to Xplane: (convert PX4 mixer output to xplane engine thrust)

PX4 → Serial → UAS.cpp(UAS::readData()) → Mavlink Msg (in our case:MAVLINK_MSG_ID_HIL_ACTUATOR_CONTROLS) → XPlaneLink.cpp(QGCXPlaneLink::updateActuatorControls()) → UDP → XPlane.

I have used source of mav2pxplane but not mav2pxplane itseft.

I hope it will be useful.