From 4f2918ee3b0d193fafd7dc02f4204d237b2f7e81 Mon Sep 17 00:00:00 2001 From: Ramon Roche Date: Thu, 5 Mar 2026 14:48:25 -0800 Subject: [PATCH] feat(sim): add SIH SITL build target and multi-instance args - Add boards/px4/sitl/sih.px4board disabling Gazebo bridge/msgs/plugins - Update sitl_multiple_run.sh to accept model and build target arguments - Add openjdk@17 to macOS setup script for jMAVSim display-only mode Signed-off-by: Ramon Roche --- Tools/setup/macos.sh | 7 +++++++ Tools/simulation/sitl_multiple_run.sh | 23 +++++++++++++---------- boards/px4/sitl/sih.px4board | 3 +++ 3 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 boards/px4/sitl/sih.px4board diff --git a/Tools/setup/macos.sh b/Tools/setup/macos.sh index 8218b4e9ab..7cffb6ed3d 100755 --- a/Tools/setup/macos.sh +++ b/Tools/setup/macos.sh @@ -79,6 +79,13 @@ if [[ $INSTALL_SIM == "--sim-tools" ]]; then elif [[ $REINSTALL_FORMULAS == "--reinstall" ]]; then brew reinstall px4-sim fi + + # jMAVSim requires a JDK (Java 17 LTS recommended) + if ! brew ls --versions openjdk@17 > /dev/null; then + echo "[macos.sh] Installing OpenJDK 17 (required for jMAVSim)" + brew install openjdk@17 + sudo ln -sfn $(brew --prefix openjdk@17)/libexec/openjdk.jdk /Library/Java/JavaVirtualMachines/openjdk-17.jdk + fi fi echo "[macos.sh] All set! The PX4 Autopilot toolchain was installed." diff --git a/Tools/simulation/sitl_multiple_run.sh b/Tools/simulation/sitl_multiple_run.sh index 6b95de44cf..a5c1c98d29 100755 --- a/Tools/simulation/sitl_multiple_run.sh +++ b/Tools/simulation/sitl_multiple_run.sh @@ -1,25 +1,28 @@ #!/bin/bash -# run multiple instances of the 'px4' binary, but w/o starting the simulator. -# It assumes px4 is already built, with 'make px4_sitl_default' +# Run multiple instances of the 'px4' binary, without starting an external simulator. +# It assumes px4 is already built with the specified build target. +# +# Usage: ./Tools/simulation/sitl_multiple_run.sh [num_instances] [model] [build_target] +# Examples: +# ./Tools/simulation/sitl_multiple_run.sh 3 sihsim_quadx px4_sitl_sih +# ./Tools/simulation/sitl_multiple_run.sh 2 gazebo-classic_iris px4_sitl_default +# ./Tools/simulation/sitl_multiple_run.sh # defaults: 2 instances, gazebo-classic_iris, px4_sitl_default -# The simulator is expected to send to TCP port 4560+i for i in [0, N-1] -# For example jmavsim can be run like this: -#./Tools/simulation/jmavsim/jmavsim_run.sh -p 4561 -l - -sitl_num=2 -[ -n "$1" ] && sitl_num="$1" +sitl_num=${1:-2} +sim_model=${2:-gazebo-classic_iris} +build_target=${3:-px4_sitl_default} SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" src_path="$SCRIPT_DIR/../../" -build_path=${src_path}/build/px4_sitl_default +build_path=${src_path}/build/${build_target} echo "killing running instances" pkill -x px4 || true sleep 1 -export PX4_SIM_MODEL=gazebo-classic_iris +export PX4_SIM_MODEL=${sim_model} n=0 while [ $n -lt $sitl_num ]; do diff --git a/boards/px4/sitl/sih.px4board b/boards/px4/sitl/sih.px4board new file mode 100644 index 0000000000..7bdc63a069 --- /dev/null +++ b/boards/px4/sitl/sih.px4board @@ -0,0 +1,3 @@ +CONFIG_MODULES_SIMULATION_GZ_BRIDGE=n +CONFIG_MODULES_SIMULATION_GZ_MSGS=n +CONFIG_MODULES_SIMULATION_GZ_PLUGINS=n