Add jsbsim bridge to enable jsbsim for px4 SITL on jsbsim (#15748)

* Add jsbsim bridge to enable jsbsim for px4 SITL/HIL on jsbsim

This is a PX4 HIL/SITL integration into JSBSim. JSBSim is an open source flight dynamics model (http://jsbsim.sourceforge.net/)

Currently there are three models available which is the rascal, quadrotor_x, hexarotor_x integrated into the bridge.

The simulation can be run with the firmware with the following command for example
```
make px4_sitl jsbsim_rascal
```

The visualization is done flightgear and is done by the bridge sending UDP packets to flightgear. To disable the visualization `HEADLESS=1` when running the make command.

The simulation can be configured through the configuration files under the `config` directory through a xml file. Senor configurations,  The xml file name should match the name of the model.

* Update Tools/sitl_run.sh

Co-authored-by: Beat Küng <beat-kueng@gmx.net>

Co-authored-by: Beat Küng <beat-kueng@gmx.net>
This commit is contained in:
JaeyoungLim
2020-09-17 20:32:42 +02:00
committed by GitHub
parent c5f479dac7
commit 458420f9cb
7 changed files with 202 additions and 1 deletions

1
Tools/jsbsim_bridge Submodule

Submodule Tools/jsbsim_bridge added at efe19dbec7

40
Tools/setup_jsbsim.bash Executable file
View File

@@ -0,0 +1,40 @@
#!/bin/bash
#
# Setup environment to make JSBSim visible to PX4.
#
# License: according to LICENSE.md in the root directory of the PX4 Firmware repository
if [ "$#" != 3 ]; then
echo -e "usage: source setup_jsbsim.bash src_dir build_dir model\n"
return 1
fi
SRC_DIR="$1"
BUILD_DIR="$2"
MODEL="$3"
export FG_AIRCRAFT="${SRC_DIR}/Tools/jsbsim_bridge/models"
# This is needed for aircraft namespace mapping
# Need more architectural discussions to make this more scalable
case "$MODEL" in
rascal)
AIRCRAFT_DIR="Rascal"
MODEL_NAME="Rascal110-JSBSim"
;;
quadrotor_x)
AIRCRAFT_DIR="quadrotor_x"
MODEL_NAME="quadrotor_x"
;;
hexarotor_x)
AIRCRAFT_DIR="hexarotor_x"
MODEL_NAME="hexarotor_x"
;;
*)
echo "Unknown Model"
exit 1
esac
export JSBSIM_AIRCRAFT_DIR="$AIRCRAFT_DIR"
export JSBSIM_AIRCRAFT_MODEL="$MODEL_NAME"

View File

@@ -58,7 +58,11 @@ fi
if [ "$model" == "" ] || [ "$model" == "none" ]; then
echo "empty model, setting iris as default"
model="iris"
if [ "$program" == "jsbsim" ]; then
model="rascal"
else
model="iris"
fi
fi
# kill process names that might stil
@@ -146,6 +150,21 @@ elif [ "$program" == "flightgear" ] && [ -z "$no_sim" ]; then
"${src_path}/Tools/flightgear_bridge/FG_run.py" "models/"${model}".json" 0
"${build_path}/build_flightgear_bridge/flightgear_bridge" 0 `./get_FGbridge_params.py "models/"${model}".json"` &
FG_BRIDGE_PID=$!
elif [ "$program" == "jsbsim" ] && [ -z "$no_sim" ]; then
source "$src_path/Tools/setup_jsbsim.bash" "${src_path}" "${build_path}" ${model}
if [[ -n "$HEADLESS" ]]; then
echo "not running flightgear gui"
else
fgfs --fdm=null \
--native-fdm=socket,in,60,,5550,udp \
--aircraft=$JSBSIM_AIRCRAFT_MODEL \
--airport=${world} \
--disable-hud \
--disable-ai-models &> /dev/null &
FGFS_PID=$!
fi
"${build_path}/build_jsbsim_bridge/jsbsim_bridge" "models/${JSBSIM_AIRCRAFT_DIR}" $JSBSIM_AIRCRAFT_MODEL ${model} "${src_path}/Tools/jsbsim_bridge/scene/${world}.xml" $HEADLESS 2> /dev/null &
JSBSIM_PID=$!
fi
pushd "$rootfs" >/dev/null
@@ -199,4 +218,7 @@ elif [ "$program" == "gazebo" ]; then
elif [ "$program" == "flightgear" ]; then
kill $FG_BRIDGE_PID
kill -9 `cat /tmp/px4fgfspid_0`
elif [ "$program" == "jsbsim" ]; then
kill $JSBSIM_PID
kill $FGFS_PID
fi