Skip to content

HITL/SITL X-Plane: Improvements#11253

Open
Scavanger wants to merge 2 commits into
iNavFlight:maintenance-9.xfrom
Scavanger:X-Plane-SITL/HITL-V3
Open

HITL/SITL X-Plane: Improvements#11253
Scavanger wants to merge 2 commits into
iNavFlight:maintenance-9.xfrom
Scavanger:X-Plane-SITL/HITL-V3

Conversation

@Scavanger
Copy link
Copy Markdown
Contributor

@Scavanger Scavanger commented Jan 16, 2026

User description

New features for X-Plane HITL/SITL, mainly for use with https://github.com/Scavanger/INAV-X-Plane-XITL

HITL

  • Option to use the simulator joystick as a receiver
  • RSSI and failsafe
  • Current sensor
  • Rangefinder

SITL
Improved communication, only set simulator values via X-Plane DataRefs, no a mix with MSP.

Should not break compatibility with HITL Plugin 1.X or with "raw" X-Plane.


PR Type

Enhancement, New Feature


Description

This description is generated by an AI tool. It may have inaccuracies

  • Add support for X-Plane INAV-XITL plugin with DataRef-based communication for SITL/HITL modes

  • Implement new simulator features: RC input from joystick, RSSI, failsafe, current sensor, rangefinder

  • Refactor simulator MSP protocol to support version 3 with extended sensor data and SITL-specific handling

  • Add connection state management and dynamic DREF registration for X-Plane plugin detection

  • Support battery voltage/current, magnetometer, and RC failsafe simulation via X-Plane DREFs


Diagram Walkthrough

flowchart LR
  XPlane["X-Plane Simulator"]
  Plugin["INAV-XITL Plugin"]
  DREFs["DataRef Communication"]
  MSP["MSP Protocol V3"]
  INAV["INAV FC"]
  
  XPlane -->|DREFs| Plugin
  Plugin -->|Sensor Data| DREFs
  DREFs -->|Read/Write| INAV
  INAV -->|MSP Commands| MSP
  MSP -->|Control Output| XPlane
  
  DREFs -->|RC Input| INAV
  DREFs -->|Battery/Current| INAV
  DREFs -->|Rangefinder| INAV
  DREFs -->|Failsafe| INAV
Loading

File Walkthrough

Relevant files
Enhancement
9 files
fc_msp.c
Refactor simulator MSP protocol to support V3                       
+217/-178
runtime_config.c
Add current and rangefinder to simulator data                       
+3/-1     
runtime_config.h
Define MSP V3 and new HITL feature flags                                 
+14/-2   
displayport_msp_osd.c
Enable OSD in SITL mode via HITL flag                                       
+2/-0     
sim.c
Add failsafe support to RC simulator                                         
+11/-1   
sim.h
Add failsafe setter function signature                                     
+2/-1     
battery.c
Integrate simulated current sensor data                                   
+6/-0     
xplane.c
Implement INAV-XITL plugin connection and DREFs                   
+499/-264
xplane.h
Add stdbool include for xplane header                                       
+1/-0     
Bug fix
1 files
navigation_pos_estimator.c
Fix GPS velocity handling for HITL mode                                   
+1/-1     
Configuration changes
2 files
target.h
Move RX_SIM and RANGEFINDER_FAKE to common                             
+0/-2     
common.h
Enable RX_SIM and RANGEFINDER_FAKE globally                           
+2/-0     
Documentation
3 files
SITL.md
Add reference to INAV-X-Plane-XITL plugin                               
+1/-1     
X-Plane.md
Document INAV-XITL plugin for advanced features                   
+3/-0     
Hardware In The Loop (HITL) plugin for X-Plane.md
Add INAV-XITL plugin documentation link                                   
+6/-0     

@github-actions
Copy link
Copy Markdown

Branch Targeting Suggestion

You've targeted the master branch with this PR. Please consider if a version branch might be more appropriate:

  • maintenance-9.x - If your change is backward-compatible and won't create compatibility issues between INAV firmware and Configurator 9.x versions. This will allow your PR to be included in the next 9.x release.

  • maintenance-10.x - If your change introduces compatibility requirements between firmware and configurator that would break 9.x compatibility. This is for PRs which will be included in INAV 10.x

If master is the correct target for this change, no action is needed.


This is an automated suggestion to help route contributions to the appropriate branch.

@qodo-code-review
Copy link
Copy Markdown
Contributor

qodo-code-review Bot commented Jan 16, 2026

PR Compliance Guide 🔍

All compliance sections have been disabled in the configurations.

@Scavanger Scavanger changed the title HILT/SITL X-Plane: Improvments HITL/SITL X-Plane: Improvements Jan 16, 2026
Comment thread src/main/target/SITL/sim/xplane.c
Comment thread src/main/target/SITL/sim/xplane.c
Comment thread src/main/fc/fc_msp.c
Comment thread src/main/target/SITL/sim/xplane.c
@Scavanger Scavanger changed the base branch from master to maintenance-9.x January 17, 2026 13:08
@xznhj8129
Copy link
Copy Markdown
Contributor

Oh man, i use HITL/SITL a lot, this would be great. I'll test this as soon as i can.
Does this fix the SITL issue where sometimes even when armed and with valid commands the plane wouldn't do anything, motor or controls?

@error414
Copy link
Copy Markdown
Contributor

@xznhj8129 have you tried? It does not work for me Scavanger/INAV-X-Plane-XITL#3

@sensei-hacker sensei-hacker added this to the 9.1 milestone May 16, 2026
sensei-hacker added a commit to sensei-hacker/inav_unofficial_targets that referenced this pull request May 17, 2026
- MSP_SIMULATOR v2/v3 protocol: refactor into readMspSimulatorValues()
  and mspProcessSimulatorCommand(); v3 uses 2-byte flags field
- New HITL flags: HITL_RANGEFINDER, HITL_CURRENT_SENSOR, HITL_SIM_RC_INPUT,
  HITL_FAILSAFE_TRIGGERED, HITL_SITL_MODE
- Fix GPS velocity: exclude HITL mode from validVelNE path (same as SITL)
- battery.c: inject simulated current when HITL_CURRENT_SENSOR active
- displayport_msp_osd.c: enable OSD vtxActive in SITL mode
- runtime_config: add SIMULATOR_MSP_VERSION_3 and new HITL flag bits
- common.h: promote RX_SIM and RANGEFINDER_FAKE out of SITL-only target.h
- xplane.h: add stdbool.h include and simXPlaneClose() declaration
- xplane.c: INAV-XITL plugin with DataRef state machine; add atomic
  thread safety and simXPlaneClose() from maintenance-9.x
sensei-hacker added a commit to sensei-hacker/inav_unofficial_targets that referenced this pull request May 17, 2026
- MSP_SIMULATOR v2/v3 protocol: refactor into readMspSimulatorValues()
  and mspProcessSimulatorCommand(); v3 uses 2-byte flags field
- New HITL flags: HITL_RANGEFINDER, HITL_CURRENT_SENSOR, HITL_SIM_RC_INPUT,
  HITL_FAILSAFE_TRIGGERED, HITL_SITL_MODE
- Fix GPS velocity: exclude HITL mode from validVelNE path (same as SITL)
- battery.c: inject simulated current when HITL_CURRENT_SENSOR active
- displayport_msp_osd.c: enable OSD vtxActive in SITL mode
- runtime_config: add SIMULATOR_MSP_VERSION_3 and new HITL flag bits
- common.h: promote RX_SIM and RANGEFINDER_FAKE out of SITL-only target.h
- xplane.h: add stdbool.h include and simXPlaneClose() declaration
- xplane.c: INAV-XITL plugin with DataRef state machine; add atomic
  thread safety and simXPlaneClose() from maintenance-9.x
sensei-hacker added a commit to sensei-hacker/inav_unofficial_targets that referenced this pull request May 17, 2026
- MSP_SIMULATOR v2/v3 protocol: refactor into readMspSimulatorValues()
  and mspProcessSimulatorCommand(); v3 uses 2-byte flags field
- New HITL flags: HITL_RANGEFINDER, HITL_CURRENT_SENSOR, HITL_SIM_RC_INPUT,
  HITL_FAILSAFE_TRIGGERED, HITL_SITL_MODE
- Fix GPS velocity: exclude HITL mode from validVelNE path (same as SITL)
- battery.c: inject simulated current when HITL_CURRENT_SENSOR active
- displayport_msp_osd.c: enable OSD vtxActive in SITL mode
- runtime_config: add SIMULATOR_MSP_VERSION_3 and new HITL flag bits
- common.h: promote RX_SIM and RANGEFINDER_FAKE out of SITL-only target.h
- xplane.h: add stdbool.h include and simXPlaneClose() declaration
- xplane.c: INAV-XITL plugin with DataRef state machine; add atomic
  thread safety and simXPlaneClose() from maintenance-9.x
sensei-hacker added a commit to sensei-hacker/inav_unofficial_targets that referenced this pull request May 17, 2026
- MSP_SIMULATOR v2/v3 protocol: refactor into readMspSimulatorValues()
  and mspProcessSimulatorCommand(); v3 uses 2-byte flags field
- New HITL flags: HITL_RANGEFINDER, HITL_CURRENT_SENSOR, HITL_SIM_RC_INPUT,
  HITL_FAILSAFE_TRIGGERED, HITL_SITL_MODE
- Fix GPS velocity: exclude HITL mode from validVelNE path (same as SITL)
- battery.c: inject simulated current when HITL_CURRENT_SENSOR active
- displayport_msp_osd.c: enable OSD vtxActive in SITL mode
- runtime_config: add SIMULATOR_MSP_VERSION_3 and new HITL flag bits
- common.h: promote RX_SIM and RANGEFINDER_FAKE out of SITL-only target.h
- xplane.h: add stdbool.h include and simXPlaneClose() declaration
- xplane.c: INAV-XITL plugin with DataRef state machine; add atomic
  thread safety and simXPlaneClose() from maintenance-9.x
@sensei-hacker
Copy link
Copy Markdown
Member

I ran a small set of regression tests and 14 of 14 passed.
I attempted to resolve the merge conflicts here:

#11566

@Scavanger may want to review the work in 5522945

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants