mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-11-01 04:51:36 +08:00
- new modules/simulation directory to collect all simulators and related modules - new Tools/simulation directory to collect and organize scattered simulation submodules, scripts, etc - simulation module renamed to simulator_mavlink - sih renamed to simulator_sih (not a great name, but I wanted to be clear it was a simulator) - ignition_simulator renamed to simulator_ignition_bridge - large sitl_target.cmake split by simulation option and in some cases pushed to appropriate modules - sitl targets broken down to what's actually available (eg jmavsim only has 1 model and 1 world) - new Gazebo consistently referred to as Ignition for now (probably the least confusing thing until we fully drop Gazebo classic support someday)
69 lines
1.9 KiB
Bash
69 lines
1.9 KiB
Bash
#!/bin/sh
|
|
# shellcheck disable=SC2154
|
|
|
|
# Simulator IMU data provided at 250 Hz
|
|
param set-default IMU_INTEG_RATE 250
|
|
|
|
if [ "$PX4_SIMULATOR" = "sihsim" ] || [ "$(param show -q SYS_AUTOSTART)" -eq "0" ]; then
|
|
|
|
if ! simulator_sih start; then
|
|
echo "ERROR [init] simulator_sih failed to start"
|
|
exit 1
|
|
fi
|
|
|
|
elif [ "$PX4_SIMULATOR" = "ignition" ]; then
|
|
|
|
# source generated gazebo_env.sh for IGN_GAZEBO_RESOURCE_PATH
|
|
if [ -f gazebo_env.sh ]; then
|
|
. ./gazebo_env.sh
|
|
elif [ -f ../gazebo_env.sh ]; then
|
|
. ../gazebo_env.sh
|
|
fi
|
|
|
|
if ! ign service --info --service /world/${PX4_SIM_WORLD}/create | grep "ignition.msgs.EntityFactory"; then
|
|
# starting ign gazebo with ${PX4_SIM_WORLD} world
|
|
echo "INFO [init] starting ign gazebo"
|
|
|
|
if [ -z $HEADLESS ]; then
|
|
ign gazebo --verbose=1 -r "${PX4_IGN_GAZEBO_WORLDS}/${PX4_SIM_WORLD}.sdf" &
|
|
else
|
|
# starting ign gazebo headless
|
|
ign gazebo --verbose=1 -r -s "${PX4_IGN_GAZEBO_WORLDS}/${PX4_SIM_WORLD}.sdf" &
|
|
fi
|
|
else
|
|
echo "INFO [init] ign gazebo already running"
|
|
fi
|
|
|
|
if simulator_ignition_bridge start -m "${PX4_SIM_MODEL}" -w "${PX4_SIM_WORLD}"; then
|
|
sensor_baro_sim start
|
|
sensor_gps_sim start
|
|
sensor_mag_sim start
|
|
else
|
|
echo "ERROR [init] ign gazebo failed to start"
|
|
exit 1
|
|
fi
|
|
|
|
else
|
|
# otherwise start simulator (mavlink) module
|
|
simulator_tcp_port=$((4560+px4_instance))
|
|
|
|
# Check if PX4_SIM_HOSTNAME environment variable is empty
|
|
# If empty check if PX4_SIM_HOST_ADDR environment variable is empty
|
|
# If both are empty use localhost for simulator
|
|
if [ -z "${PX4_SIM_HOSTNAME}" ]; then
|
|
|
|
if [ -z "${PX4_SIM_HOST_ADDR}" ]; then
|
|
echo "PX4 SIM HOST: localhost"
|
|
simulator_mavlink start -c $simulator_tcp_port
|
|
else
|
|
echo "PX4 SIM HOST: $PX4_SIM_HOST_ADDR"
|
|
simulator_mavlink start -t $PX4_SIM_HOST_ADDR $simulator_tcp_port
|
|
fi
|
|
|
|
else
|
|
echo "PX4 SIM HOST: $PX4_SIM_HOSTNAME"
|
|
simulator_mavlink start -h $PX4_SIM_HOSTNAME $simulator_tcp_port
|
|
fi
|
|
|
|
fi
|