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

View File

@@ -26,6 +26,7 @@ add_custom_target(run_config
px4_add_git_submodule(TARGET git_gazebo PATH "${PX4_SOURCE_DIR}/Tools/sitl_gazebo")
px4_add_git_submodule(TARGET git_jmavsim PATH "${PX4_SOURCE_DIR}/Tools/jMAVSim")
px4_add_git_submodule(TARGET git_flightgear_bridge PATH "${PX4_SOURCE_DIR}/Tools/flightgear_bridge")
px4_add_git_submodule(TARGET git_jsbsim_bridge PATH "${PX4_SOURCE_DIR}/Tools/jsbsim_bridge")
# Add support for external project building
include(ExternalProject)
@@ -73,6 +74,20 @@ ExternalProject_Add(flightgear_bridge
BUILD_ALWAYS 1
)
ExternalProject_Add(jsbsim_bridge
SOURCE_DIR ${PX4_SOURCE_DIR}/Tools/jsbsim_bridge
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
BINARY_DIR ${PX4_BINARY_DIR}/build_jsbsim_bridge
INSTALL_COMMAND ""
DEPENDS
git_jsbsim_bridge
USES_TERMINAL_CONFIGURE true
USES_TERMINAL_BUILD true
EXCLUDE_FROM_ALL true
BUILD_ALWAYS 1
)
# create targets for each viewer/model/debugger combination
set(viewers none jmavsim gazebo)
set(debuggers none ide gdb lldb ddd valgrind callgrind)
@@ -161,6 +176,79 @@ foreach(viewer ${viewers})
endforeach()
endforeach()
# create targets for jsbsim
set(models_jsbsim none rascal quadrotor_x hexarotor_x)
set(worlds_jsbsim none LSZH)
foreach(debugger ${debuggers})
foreach(model ${models_jsbsim})
foreach(world ${worlds_jsbsim})
if (world STREQUAL "none")
if (debugger STREQUAL "none")
if (model STREQUAL "none")
set(_targ_name "jsbsim")
else()
set(_targ_name "jsbsim_${model}")
endif()
else()
if (model STREQUAL "none")
set(_targ_name "jsbsim__${debugger}_${world}")
else()
set(_targ_name "jsbsim_${model}_${debugger}_${world}")
endif()
endif()
add_custom_target(${_targ_name}
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh
$<TARGET_FILE:px4>
${debugger}
jsbsim
${model}
"LSZH"
${PX4_SOURCE_DIR}
${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS
logs_symlink
)
list(APPEND all_posix_vmd_make_targets ${_targ_name})
add_dependencies(${_targ_name} px4 jsbsim_bridge)
else()
if (debugger STREQUAL "none")
if (model STREQUAL "none")
set(_targ_name "jsbsim___${world}")
else()
set(_targ_name "jsbsim_${model}__${world}")
endif()
else()
if (model STREQUAL "none")
set(_targ_name "jsbsim___${debugger}_${world}")
else()
set(_targ_name "jsbsim_${model}_${debugger}_${world}")
endif()
endif()
add_custom_target(${_targ_name}
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh
$<TARGET_FILE:px4>
${debugger}
jsbsim
${model}
${world}
${PX4_SOURCE_DIR}
${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS
logs_symlink
)
list(APPEND all_posix_vmd_make_targets ${_targ_name})
add_dependencies(${_targ_name} px4 jsbsim_bridge)
endif()
endforeach()
endforeach()
endforeach()
#add flighgear targets
if( ENABLE_LOCKSTEP_SCHEDULER STREQUAL "no")
set(models