PX4-Autopilot/Tools/packaging/px4-gazebo.sh
Ramon Roche 1079c57fd0 build(packaging): add PX4 SITL .deb packages
Add cmake/cpack infrastructure for building .deb packages from
px4_sitl_sih and px4_sitl_default targets. Includes install rules,
package scripts, Gazebo wrapper, and CI workflow.

Signed-off-by: Ramon Roche <mrpollo@gmail.com>
2026-04-02 15:03:04 -06:00

33 lines
1.6 KiB
Bash

#!/usr/bin/env bash
# px4-gazebo: Launch PX4 SITL with Gazebo from the installed .deb package
set -e
PX4_GAZEBO_DIR="$(cd "$(dirname "$(readlink -f "$0")")/.." && pwd)"
PX4_BINARY="${PX4_GAZEBO_DIR}/bin/px4"
# Set Gazebo resource paths so gz-sim finds PX4 models, worlds, and plugins.
export PX4_GZ_MODELS="${PX4_GAZEBO_DIR}/share/gz/models"
export PX4_GZ_WORLDS="${PX4_GAZEBO_DIR}/share/gz/worlds"
export PX4_GZ_PLUGINS="${PX4_GAZEBO_DIR}/lib/gz/plugins"
export PX4_GZ_SERVER_CONFIG="${PX4_GAZEBO_DIR}/share/gz/server.config"
export GZ_SIM_RESOURCE_PATH="${GZ_SIM_RESOURCE_PATH}:${PX4_GZ_MODELS}:${PX4_GZ_WORLDS}"
export GZ_SIM_SYSTEM_PLUGIN_PATH="${GZ_SIM_SYSTEM_PLUGIN_PATH}:${PX4_GZ_PLUGINS}"
export GZ_SIM_SERVER_CONFIG_PATH="${PX4_GZ_SERVER_CONFIG}"
# Gazebo's Physics system searches for "gz-physics-dartsim-plugin" which maps
# to the unversioned libgz-physics-dartsim-plugin.so. The runtime package only
# ships versioned .so files; the unversioned symlink lives in the -dev package.
# Create it if missing so Gazebo finds the DART engine without installing -dev.
GZ_PHYSICS_ENGINE_DIR=$(find /usr/lib -maxdepth 3 -type d -name "engine-plugins" -path "*/gz-physics-7/*" 2>/dev/null | head -1)
if [ -n "$GZ_PHYSICS_ENGINE_DIR" ] && [ -d "$GZ_PHYSICS_ENGINE_DIR" ]; then
UNVERSIONED="$GZ_PHYSICS_ENGINE_DIR/libgz-physics-dartsim-plugin.so"
if [ ! -e "$UNVERSIONED" ]; then
VERSIONED=$(ls "$GZ_PHYSICS_ENGINE_DIR"/libgz-physics*-dartsim-plugin.so.* 2>/dev/null | head -1)
if [ -n "$VERSIONED" ]; then
ln -sf "$(basename "$VERSIONED")" "$UNVERSIONED" 2>/dev/null || true
fi
fi
fi
exec "${PX4_BINARY}" "$@"