px4-rc.simulator 639 Bytes
#!/bin/sh
# shellcheck disable=SC2154

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 start -c $simulator_tcp_port
  else
    echo "PX4 SIM HOST: $PX4_SIM_HOST_ADDR"
    simulator start -t $PX4_SIM_HOST_ADDR $simulator_tcp_port
  fi
else
  echo "PX4 SIM HOST: $PX4_SIM_HOSTNAME"
  simulator start -h $PX4_SIM_HOSTNAME $simulator_tcp_port
fi