Files
PX4-Autopilot/ROMFS
mt 9b25e6df33 fix(simulation): preserve gravity and step_size in px4-rc.gzsim set_physics (#27488)
* fix(simulation): preserve gravity and step_size in px4-rc.gzsim set_physics

The set_physics service call in px4-rc.gzsim sent only real_time_factor.
Other fields in gz.msgs.Physics (gravity, max_step_size) defaulted to 0
per protobuf semantics, silently zeroing world gravity in the gz physics
engine when PX4_SIM_SPEED_FACTOR was set. Vehicles became weightless
while PX4's accelerometer (sourced from the gz IMU plugin's cached SDF
gravity) continued to report -9.81 m/s², making the bug invisible from
PX4's side.

Resolve the values via the live gz physics topic, fall back to the
world SDF, and finally to Earth gravity / gz-harmonic default step
size, then include the full set in the set_physics request.

Fixes #27480

Signed-off-by: Marko T <marko.tavcar@c-astral.com>

* fix(simulation): resolve world name in standalone and drop dead physics topic

The gz physics topic queried for gravity/max_step_size does not exist in
gz Harmonic (only a write-only set_physics service), so that branch always
timed out and fell through. Read both values directly from the world SDF,
which is the source of truth at load time.

Also resolve PX4_GZ_WORLD from the running gz instance (clock topic) inside
the readiness check, so standalone launches — where the world name is not
known up front — can find the scene and the world SDF.

Signed-off-by: Marko T <marko.tavcar@c-astral.com>

* Update ROMFS/px4fmu_common/init.d-posix/px4-rc.gzsim

Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>

* Update ROMFS/px4fmu_common/init.d-posix/px4-rc.gzsim

Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>

* docs(simulation): clarify gravity-default fallback comment in px4-rc.gzsim

Fix typo ("greavity") and reword the comment to clearly state that the
hardcoded gravity/step-size defaults are only used when the world SDF
cannot be located, and are wrong for custom-gravity worlds.

Signed-off-by: Marko T <marko.tavcar@c-astral.com>

---------

Signed-off-by: Marko T <marko.tavcar@c-astral.com>
Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>
2026-06-08 20:50:07 -06:00
..
2025-08-21 16:46:06 +02:00