Custom SDF Model and World with PX4 SITL

I have created custom SDF files for my model and world. Then, I took the necessary steps to add them into PX4-Autopilot:

  • I added an airframe config file for my custom model in /PX4-Autopilot/ROMFS/px4fmu_common/init.d-posix/airframes
  • I added that airframe name to the CMakeLists.txt in the same location
  • I added my custom sdf model file in /PX4-Autopilot/Tools/simulation/gz/models
  • I added my custom sdf world file in /PX4-Autopilot/Tools/simulation/gz/worlds

When I launch px4 I use this command per the documentation:

PX4_SYS_AUTOSTART=4050 ./build/px4_sitl_default/bin/px4

Currently, this works to launch the world and model together. Topics from my model sdf file plugins in gazebo publish but then there are topics that are created from px4 that do not publish anything. When PX4 launches the preflight checks fail and do not detect the sensors. Does anyone know why this keeps happening?

Information:

  • Gazebo Harmonic
  • PX4-Autopilot v1.16.0

Please let me know if you need more information or to see anything specific - topics, sdf file snippets, airframe config, launch preflight errors, etc. Thank you in advance! I am new to this so I really appreciate any advice here.

PX4 SITL terminal output? Can you arm and takeoff or no? These messages are unfortunately ā€œnormalā€ and I haven’t figured out the best way to fix it

WARN [health_and_arming_checks] Preflight Fail: ekf2 missing data
WARN [health_and_arming_checks] Preflight Fail: system power unavailable
WARN [health_and_arming_checks] Preflight Fail: No connection to the GCS

This is also relevant if you are doing anything with multi-vehicle

This is the output when i launch px4 and arming does not work unfortunately:

Thank you for taking the time here.

PX4 is not receiving sensor data but it was able to connect to Gazebo and lock to its clock.

does make px4 sitl gz_500 work?

Given that you added the aiframe name to CMakeLists.txt and world and model to the gz submodule, can you run make px4 sitl x500_research_indoor_env0? Does it fail like PX4_SYS_AUTOSTART=4050 ./build/px4_sitl_default/bin/px4?

I’m thinking about:

  • IMU sensor placed in the wrong link
  • gz world plugins not loaded correctly (but you said you see the IMU topics in gz)
  • PX4 not fully connected to GZ

From your image, PX4 reports to be using world: indoor_env0 is that indeed the name of your world?

Please share the full log (not as screenshot) of the PX4 process. thanks!

To answer your questions:

make px4_sitl gz_x500 returns:


| __ \ \ \ / / / |
| |/ / \ V / / /| |
| __/ / \ / /
| |
| | / /^\ \ __ |
_| / / |_/

px4 starting.

INFO [px4] startup script: /bin/sh etc/init.d-posix/rcS 0
INFO [init] found model autostart file as SYS_AUTOSTART=4001
INFO [param] selected parameter default file parameters.bson
INFO [param] importing from ā€˜parameters.bson’
INFO [parameters] BSON document size 343 bytes, decoded 343 bytes (INT32:12, FLOAT:5)
INFO [param] selected parameter backup file parameters_backup.bson
SYS_AUTOCONFIG: curr: 0 → new: 1

  • SYS_AUTOSTART: curr: 4050 → new: 4001
    SENS_BOARD_X_OFF: curr: 0.0000 → new: 0.0000
    SENS_DPRES_OFF: curr: 0.0000 → new: 0.0010
    INFO [dataman] data manager file ā€˜./dataman’ size is 1208528 bytes
    INFO [init] Gazebo simulator
    INFO [init] Starting gazebo with world: /home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/worlds/default.sdf
    INFO [init] Starting gz gui
    [Err] [SystemLoader.cc:92] Failed to load system plugin [libGstCameraSystem.so] : Could not find shared library.
    INFO [init] Gazebo world is ready
    INFO [init] Spawning model
    INFO [gz_bridge] world: default, model: x500_0
    INFO [lockstep_scheduler] setting initial absolute time to 3268000 us
    INFO [commander] LED: open /dev/led0 failed (22)
    WARN [health_and_arming_checks] Preflight Fail: ekf2 missing data
    WARN [health_and_arming_checks] Preflight Fail: No connection to the ground control station
    INFO [tone_alarm] home set
    INFO [uxrce_dds_client] init UDP agent IP:127.0.0.1, port:8888
    INFO [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 18570 remote port 14550
    INFO [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14580 remote port 14540
    INFO [mavlink] mode: Onboard, data rate: 4000 B/s on udp port 14280 remote port 14030
    INFO [mavlink] mode: Gimbal, data rate: 400000 B/s on udp port 13030 remote port 13280
    INFO [logger] logger started (mode=all)
    INFO [logger] removing log directory ./log/2025-08-20 to get more space (left=761289 MiB)
    INFO [logger] Start file log (type: full)
    INFO [logger] [logger] ./log/2025-11-08/04_26_26.ulg
    INFO [logger] Opened full log file: ./log/2025-11-08/04_26_26.ulg
    INFO [mavlink] MAVLink only on localhost (set param MAV_{i}BROADCAST = 1 to enable network)
    INFO [mavlink] MAVLink only on localhost (set param MAV
    {i}_BROADCAST = 1 to enable network)
    INFO [px4] Startup script returned successfully
    pxh> WARN [health_and_arming_checks] Preflight Fail: No connection to the ground control station
    WARN [health_and_arming_checks] Preflight Fail: No connection to the ground control station

make px4_sitl gz_x500_research_indoor_env0 returns:


| __ \ \ \ / / / |
| |/ / \ V / / /| |
| __/ / \ / /
| |
| | / /^\ \ __ |
_| / / |_/

px4 starting.

INFO [px4] startup script: /bin/sh etc/init.d-posix/rcS 0
INFO [init] found model autostart file as SYS_AUTOSTART=4050
INFO [param] selected parameter default file parameters.bson
INFO [param] importing from ā€˜parameters.bson’
INFO [parameters] BSON document size 404 bytes, decoded 404 bytes (INT32:14, FLOAT:6)
INFO [param] selected parameter backup file parameters_backup.bson
SYS_AUTOCONFIG: curr: 0 → new: 1

  • SYS_AUTOSTART: curr: 4001 → new: 4050
    SENS_BOARD_X_OFF: curr: 0.0000 → new: 0.0000
    SENS_DPRES_OFF: curr: 0.0000 → new: 0.0010
    INFO [dataman] data manager file ā€˜./dataman’ size is 1208528 bytes
    INFO [init] Gazebo simulator
    INFO [init] Starting gazebo with world: /home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/worlds/indoor_env0.sdf
    INFO [init] Starting gz gui
    INFO [init] Gazebo world is ready
    INFO [init] Spawning model
    Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œbase_linkā€]/sensor[@name=ā€œair_pressure_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L173]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
    Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œbase_linkā€]/sensor[@name=ā€œmagnetometer_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L191]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
    Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œbase_linkā€]/sensor[@name=ā€œimu_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L221]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
    Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œlidar_linkā€]/sensor[@name=ā€œlidar_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L739]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
    Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œoptical_flow_linkā€]/sensor[@name=ā€œoptical_flow_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L968]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
    Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œrangefinder_linkā€]/sensor[@name=ā€œrangefinder_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L1035]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copyi
    ng[gz_frame_id] as children of [sensor].
    Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œultrasonic_front_linkā€]/sensor[@name=ā€œultrasonic_front_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L1146]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
    Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œultrasonic_left_linkā€]/sensor[@name=ā€œultrasonic_left_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L1255]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
    Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œultrasonic_right_linkā€]/sensor[@name=ā€œultrasonic_right_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L1364]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
    libEGL warning: egl: failed to create dri2 screen
    INFO [gz_bridge] world: indoor_env0, model: x500_research_0
    INFO [lockstep_scheduler] setting initial absolute time to 2294000 us
    INFO [commander] LED: open /dev/led0 failed (22)
    WARN [health_and_arming_checks] Too many arming check events (1, 14 > 14). Not reporting all
    WARN [health_and_arming_checks] Preflight Fail: Accel Sensor 0 missing
    WARN [health_and_arming_checks] Preflight Fail: barometer 0 missing
    WARN [health_and_arming_checks] Preflight Fail: ekf2 missing data
    WARN [health_and_arming_checks] Preflight Fail: Gyro Sensor 0 missing
    WARN [health_and_arming_checks] Preflight Fail: Found 0 compass (required: 1)
    WARN [health_and_arming_checks] Preflight Fail: system power unavailable
    INFO [uxrce_dds_client] init UDP agent IP:127.0.0.1, port:8888
    INFO [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 18570 remote port 14550
    INFO [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14580 remote port 14540
    INFO [mavlink] mode: Onboard, data rate: 4000 B/s on udp port 14280 remote port 14030
    INFO [mavlink] mode: Gimbal, data rate: 400000 B/s on udp port 13030 remote port 13280
    INFO [logger] logger started (mode=all)
    INFO [logger] Start file log (type: full)
    INFO [logger] [logger] ./log/2025-11-08/04_28_35.ulg
    INFO [logger] Opened full log file: ./log/2025-11-08/04_28_35.ulg
    INFO [mavlink] MAVLink only on localhost (set param MAV_{i}BROADCAST = 1 to enable network)
    INFO [mavlink] MAVLink only on localhost (set param MAV
    {i}_BROADCAST = 1 to enable network)
    INFO [px4] Startup script returned successfully
    pxh> WARN [health_and_arming_checks] Too many arming check events (1, 14 > 14). Not reporting all
    WARN [health_and_arming_checks] Preflight Fail: Accel Sensor 0 missing
    WARN [health_and_arming_checks] Preflight Fail: barometer 0 missing
    WARN [health_and_arming_checks] Preflight Fail: ekf2 missing data
    WARN [health_and_arming_checks] Preflight Fail: Gyro Sensor 0 missing
    WARN [health_and_arming_checks] Preflight Fail: Found 0 compass (required: 1)

Here is the full log (px4launch is an alias i made for PX4_SYS_AUTOSTART=4050 ./build/px4_sitl_default/bin/px4):

px4launch


| __ \ \ \ / / / |
| |/ / \ V / / /| |
| __/ / \ / /
| |
| | / /^\ \ __ |
_| / / |_/

px4 starting.

INFO [px4] startup script: /bin/sh etc/init.d-posix/rcS 0
env SYS_AUTOSTART: 4050
INFO [param] selected parameter default file parameters.bson
INFO [param] importing from ā€˜parameters.bson’
INFO [parameters] BSON document size 343 bytes, decoded 343 bytes (INT32:12, FLOAT:5)
INFO [param] selected parameter backup file parameters_backup.bson
INFO [dataman] data manager file ā€˜./dataman’ size is 1208528 bytes
INFO [init] Gazebo simulator
INFO [init] Starting gazebo with world: /home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/worlds/indoor_env0.sdf
INFO [init] Starting gz gui
INFO [init] Gazebo world is ready
INFO [init] Spawning model
Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œbase_linkā€]/sensor[@name=ā€œair_pressure_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L173]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œbase_linkā€]/sensor[@name=ā€œmagnetometer_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L191]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œbase_linkā€]/sensor[@name=ā€œimu_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L221]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œlidar_linkā€]/sensor[@name=ā€œlidar_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L739]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œoptical_flow_linkā€]/sensor[@name=ā€œoptical_flow_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L968]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œrangefinder_linkā€]/sensor[@name=ā€œrangefinder_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L1035]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œultrasonic_front_linkā€]/sensor[@name=ā€œultrasonic_front_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L1146]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œultrasonic_left_linkā€]/sensor[@name=ā€œultrasonic_left_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L1255]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
Warning [Utils.cc:132] [/sdf/model[@name=ā€œx500_researchā€]/link[@name=ā€œultrasonic_right_linkā€]/sensor[@name=ā€œultrasonic_right_sensorā€]/gz_frame_id:/home/qsimmonds55/PX4-Autopilot/Tools/simulation/gz/models/x500_research/model.sdf:L1364]: XML Element[gz_frame_id], child of element[sensor], not defined in SDF. Copying[gz_frame_id] as children of [sensor].
libEGL warning: egl: failed to create dri2 screen
INFO [gz_bridge] world: indoor_env0, model: x500_research_0
INFO [lockstep_scheduler] setting initial absolute time to 2302000 us
INFO [commander] LED: open /dev/led0 failed (22)
WARN [health_and_arming_checks] Too many arming check events (1, 14 > 14). Not reporting all
WARN [health_and_arming_checks] Preflight Fail: Accel Sensor 0 missing
WARN [health_and_arming_checks] Preflight Fail: barometer 0 missing
WARN [health_and_arming_checks] Preflight Fail: ekf2 missing data
WARN [health_and_arming_checks] Preflight Fail: Gyro Sensor 0 missing
WARN [health_and_arming_checks] Preflight Fail: Found 0 compass (required: 1)
WARN [health_and_arming_checks] Preflight Fail: system power unavailable
INFO [uxrce_dds_client] init UDP agent IP:127.0.0.1, port:8888
INFO [mavlink] mode: Normal, data rate: 4000000 B/s on udp port 18570 remote port 14550
INFO [mavlink] mode: Onboard, data rate: 4000000 B/s on udp port 14580 remote port 14540
INFO [mavlink] mode: Onboard, data rate: 4000 B/s on udp port 14280 remote port 14030
INFO [mavlink] mode: Gimbal, data rate: 400000 B/s on udp port 13030 remote port 13280
INFO [logger] logger started (mode=all)
INFO [logger] removing log directory ./log/2025-08-18 to get more space (left=761298 MiB)
INFO [logger] Start file log (type: full)
INFO [logger] [logger] ./log/2025-11-08/04_21_34.ulg
INFO [logger] Opened full log file: ./log/2025-11-08/04_21_34.ulg
INFO [mavlink] MAVLink only on localhost (set param MAV_{i}BROADCAST = 1 to enable network)
INFO [mavlink] MAVLink only on localhost (set param MAV
{i}_BROADCAST = 1 to enable network)
INFO [px4] Startup script returned successfully
pxh> WARN [health_and_arming_checks] Too many arming check events (1, 14 > 14). Not reporting all
WARN [health_and_arming_checks] Preflight Fail: Accel Sensor 0 missing
WARN [health_and_arming_checks] Preflight Fail: barometer 0 missing
WARN [health_and_arming_checks] Preflight Fail: ekf2 missing data
WARN [health_and_arming_checks] Preflight Fail: Gyro Sensor 0 missing
WARN [health_and_arming_checks] Preflight Fail: Found 0 compass (required: 1)

Yes. indoor_env0 is the correct custom world. When I launch, the custom world and custom model spawn correctly. It is just the sensors keep failing preflight checks for some reason. I also added an example of my model sdf sensor plugin if that helps below. Thank you for helping me and taking the time.

x500 works but your model does not work. Your model also throws a lot of warnings when spawned. Please check that it complays with the other model structure and naming of link and joints. PX4 is quite rigit with gz topic names and it won’t subscribe to imu, mag, gps gz topic unless they follow the right structure.

1 Like