Skip to content

feat(simulation): add sensor_adsb_sim for simulated ADS-B traffic#27409

Draft
anilkir wants to merge 3 commits into
PX4:mainfrom
anilkir:feat/sensor-adsb-sim
Draft

feat(simulation): add sensor_adsb_sim for simulated ADS-B traffic#27409
anilkir wants to merge 3 commits into
PX4:mainfrom
anilkir:feat/sensor-adsb-sim

Conversation

@anilkir
Copy link
Copy Markdown
Contributor

@anilkir anilkir commented May 20, 2026

Description

This adds an ADS-B simulator with a very rudimentary multi-aircraft simulation model, similar to the implementation in ArduPilot. The module runs at 1 Hz (matching real ADS-B squitter rate) and integrates aircraft positions using a flat-earth approximation. Each aircraft is spawned at a random bearing and distance within the configured radius, flies a constant random heading and speed, and is re-spawned when it exits the radius, descends below ground, or climbs more than 1000 m above the configured altitude.

This works in POSIX SITL and SIH on real hardware.

New parameters:

  • SIM_ADSB_COUNT: Number of simulated aircraft (max 10)
  • SIM_ADSB_RADIUS: Spawn/despawn radius around ownship
  • SIM_ADSB_ALT: Target cruise altitude (AMSL) for simulated traffic

Known limitation: MAVLink heartbeat not simulated

A real ADS-B receiver is a MAVLink component that sends ADSB_VEHICLE messages and a HEARTBEAT message. The MAVLink module tracks that heartbeat in telemetry_status.heartbeat_type_adsb, and Commander uses it to set traffic_avoidance_system_present.

The proposed sensor_adsb_sim publishes transponder_report directly over uORB, bypassing the MAVLink receive path. As a result, traffic_avoidance_system_present is never set during simulation, even though traffic reports are flowing.

The simulation of an ADS-B receiver with a full MAVLink interface to simulate the HEARTBEAT messages as well is deferred to a follow-up.

Changelog Entry

For release notes:

Feature: ADS-B simulator
New parameters: SIM_ADSB_COUNT, SIM_ADSB_RADIUS, SIM_ADSB_ALT

Test coverage

This was tested in SITL and the ADS-B emitter positions were verified on GCS.

@github-actions github-actions Bot added kind:feature Request or change that adds new functionality. scope:simulation SITL, Gazebo, jmavsim, lockstep, or simulated sensors. labels May 20, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 20, 2026

🔎 FLASH Analysis

px4_fmu-v5x [Total VM Diff: 2180 byte (0.11 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.1% +2.12Ki  +0.1% +2.12Ki    .text
    [NEW]    +716  [NEW]    +716    SensorAdsbSim::Run()
    [NEW]    +276  [NEW]    +276    SensorAdsbSim::SensorAdsbSim()
    [NEW]    +260  [NEW]    +260    SensorAdsbSim::spawn_vehicle()
    [NEW]    +140  [NEW]    +140    SensorAdsbSim::~SensorAdsbSim()
    +0.1%    +140  +0.1%    +140    g_cromfs_image
    +0.1%    +112  +0.1%    +112    [section .text]
    [NEW]    +104  [NEW]    +104    SensorAdsbSim::task_spawn()
    [NEW]     +84  [NEW]     +84    SensorAdsbSim
    [NEW]     +80  [NEW]     +80    SensorAdsbSim::print_usage()
    [NEW]     +52  [NEW]     +52    SensorAdsbSim::random_float()
    [NEW]     +52  [NEW]     +52    SensorAdsbSim::updateParamsImpl()
    [NEW]     +44  [NEW]     +44    _GLOBAL__sub_I__ZN13SensorAdsbSim4descE
    +0.2%     +32  +0.2%     +32    px4::parameters
    [NEW]     +20  [NEW]     +20    SensorAdsbSim::init()
    +0.7%     +16  +0.7%     +16    g_builtins
    [NEW]     +16  [NEW]     +16    sensor_adsb_sim_main
    [NEW]     +12  [NEW]     +12    SensorAdsbSim::EMITTER_TYPES
    [NEW]     +12  [NEW]     +12    SensorAdsbSim::custom_command()
    +5.6%      +8  +5.6%      +8    px4::wq_configurations::hp_default
    +4.8%      +4  +4.8%      +4    FlightTask
   -100.2%      -4 -100.2%      -4    [3 Others]
  +1.0%      +4  +1.0%      +4    .init_section
  +0.2% +3.06Ki  [ = ]       0    .debug_abbrev
  +0.1%    +224  [ = ]       0    .debug_aranges
  +0.2%    +772  [ = ]       0    .debug_frame
  +0.2% +48.1Ki  [ = ]       0    .debug_info
  +0.1% +4.62Ki  [ = ]       0    .debug_line
   -85.7%      -6  [ = ]       0    [Unmapped]
    +0.1% +4.62Ki  [ = ]       0    [section .debug_line]
  +0.1% +2.97Ki  [ = ]       0    .debug_loclists
  +0.1%    +543  [ = ]       0    .debug_rnglists
    +100%      +1  [ = ]       0    [Unmapped]
    +0.1%    +542  [ = ]       0    [section .debug_rnglists]
  +0.1% +3.90Ki  [ = ]       0    .debug_str
  +0.8%      +2  [ = ]       0    .shstrtab
  +0.1%    +714  [ = ]       0    .strtab
    [NEW]     +20  [ = ]       0    SensorAdsbSim
    [NEW]     +35  [ = ]       0    SensorAdsbSim::EMITTER_TYPES
    [NEW]     +56  [ = ]       0    SensorAdsbSim::Run()
    [NEW]     +46  [ = ]       0    SensorAdsbSim::SensorAdsbSim()
    [NEW]     +40  [ = ]       0    SensorAdsbSim::custom_command()
    [NEW]     +26  [ = ]       0    SensorAdsbSim::init()
    [NEW]     +36  [ = ]       0    SensorAdsbSim::print_usage()
    [NEW]     +36  [ = ]       0    SensorAdsbSim::random_float()
    [NEW]     +38  [ = ]       0    SensorAdsbSim::spawn_vehicle()
    [NEW]     +36  [ = ]       0    SensorAdsbSim::task_spawn()
    [NEW]     +83  [ = ]       0    SensorAdsbSim::updateParamsImpl()
    [NEW]    +183  [ = ]       0    SensorAdsbSim::~SensorAdsbSim()
    +0.1%     +18  [ = ]       0    [section .strtab]
    [NEW]     +40  [ = ]       0    _GLOBAL__sub_I__ZN13SensorAdsbSim4descE
   -32.7%     -16  [ = ]       0    __param_get_default_value_veneer
     +64%     +16  [ = ]       0    __up_unblock_task_veneer
    [NEW]     +21  [ = ]       0    sensor_adsb_sim_main
  +0.2%    +960  [ = ]       0    .symtab
    [NEW]     +32  [ = ]       0    SensorAdsbSim
    [NEW]     +32  [ = ]       0    SensorAdsbSim::EMITTER_TYPES
    [NEW]     +80  [ = ]       0    SensorAdsbSim::Run()
    [NEW]     +64  [ = ]       0    SensorAdsbSim::SensorAdsbSim()
    [NEW]     +64  [ = ]       0    SensorAdsbSim::custom_command()
    [NEW]     +32  [ = ]       0    SensorAdsbSim::desc
    [NEW]     +48  [ = ]       0    SensorAdsbSim::init()
    [NEW]     +48  [ = ]       0    SensorAdsbSim::print_usage()
    [NEW]     +48  [ = ]       0    SensorAdsbSim::random_float()
    [NEW]     +48  [ = ]       0    SensorAdsbSim::spawn_vehicle()
    [NEW]     +48  [ = ]       0    SensorAdsbSim::task_spawn()
    [NEW]     +32  [ = ]       0    SensorAdsbSim::updateParamsImpl()
    [NEW]    +224  [ = ]       0    SensorAdsbSim::~SensorAdsbSim()
     +50%     +16  [ = ]       0    SensorGpsSim::generate_wgn()
   -33.3%     -16  [ = ]       0    SensorGpsSim::generate_wgn()::S
    [NEW]     +64  [ = ]       0    _GLOBAL__sub_I__ZN13SensorAdsbSim4descE
   -40.0%     -32  [ = ]       0    __param_get_default_value_veneer
     +67%     +32  [ = ]       0    __up_unblock_task_veneer
    +6.5%     +48  [ = ]       0    px4::wq_configurations::hp_default
    [NEW]     +48  [ = ]       0    sensor_adsb_sim_main
 -18.4% -2.13Ki  [ = ]       0    [Unmapped]
  +0.1% +65.8Ki  +0.1% +2.13Ki    TOTAL

px4_fmu-v6x [Total VM Diff: 0 byte (0 %)]
    FILE SIZE        VM SIZE    
 --------------  -------------- 
  +0.0%     +55  [ = ]       0    .debug_abbrev
  +0.0%    +168  [ = ]       0    .debug_info
  -0.0%      -7  [ = ]       0    .debug_line
  +0.0%     +36  [ = ]       0    .debug_loclists
  +0.0%      +2  [ = ]       0    .debug_rnglists
  +0.0%    +178  [ = ]       0    .debug_str
  +0.0%    +432  [ = ]       0    TOTAL

Updated: 2026-05-21T09:41:36

@github-actions github-actions Bot added the scope:uorb uORB messages, generated interfaces, or message translation. label May 21, 2026
Copy link
Copy Markdown
Member

@Claudio-Chies Claudio-Chies left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks alot for takling this, this will be a huge improvement over the current implementation! added a few comments, and i would make sure to also add it to the docs, and remove the run_fake_traffic

max: 100000.0
SIM_ADSB_ALT:
description:
short: Altitude of simulated ADSB aircraft (MSL)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thats just the start altitude of the simulated airfracts, right, i would write this more clearly

parameters:
- group: Sensors
definitions:
SENS_EN_ADSBSIM:
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this param is not mentioned in the PR

report.icao_address = v.icao_address;
report.lat = v.lat;
report.lon = v.lon;
report.altitude_type = 0;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i think we are simulating GPS altitude, and not Pressure adjusted altitude

report.altitude_type = 1;

@Claudio-Chies Claudio-Chies force-pushed the feat/sensor-adsb-sim branch from aa850de to 6619bf6 Compare May 21, 2026 09:36
@MaEtUgR MaEtUgR self-requested a review May 21, 2026 11:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind:feature Request or change that adds new functionality. scope:simulation SITL, Gazebo, jmavsim, lockstep, or simulated sensors. scope:uorb uORB messages, generated interfaces, or message translation.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants