SITL jsbsim make airframes simulator specific

This commit is contained in:
Daniel Agar 2023-01-04 19:09:29 -05:00
parent 75125da34c
commit 1abe35c220
7 changed files with 110 additions and 53 deletions

View File

@ -53,10 +53,9 @@ px4_add_romfs_files(
1030_plane
1031_plane_cam
1032_plane_catapult
1033_rascal
1034_rascal-electric
1033_jsbsim_rascal
1035_techpod
1036_malolo
1036_jsbsim_malolo
1037_believer
1038_glider
1039_advanced_plane
@ -69,8 +68,9 @@ px4_add_romfs_files(
1061_r1_rover
1062_tf-r1
1070_boat
3010_quadrotor_x
3011_hexarotor_x
3010_jsbsim_quadrotor_x
3011_jsbsim_hexarotor_x
4001_x500

View File

@ -37,7 +37,7 @@ else
no_pxh=""
fi
export PX4_SIM_MODEL=${model}
export PX4_SIM_MODEL=jsbsim_${model}
export PX4_SIM_WORLD=${world}
# This is needed for aircraft namespace mapping

View File

@ -1,56 +1,113 @@
px4_add_git_submodule(TARGET git_jsbsim_bridge PATH "${PX4_SOURCE_DIR}/Tools/simulation/jsbsim/jsbsim_bridge")
include(ExternalProject)
ExternalProject_Add(jsbsim_bridge
SOURCE_DIR ${PX4_SOURCE_DIR}/Tools/simulation/jsbsim/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
if(DEFINED ENV{JSBSIM_ROOT_DIR} )
set(JSBSIM_ROOT_DIR "$ENV{JSBSIM_ROOT_DIR}" )
endif()
find_path(JSBSIM_INCLUDE_DIR
NAMES
FGFDMExec.h
PATHS
${JSBSIM_ROOT_DIR}/include/JSBSim
/usr/include/JSBSim
/usr/local/include/JSBSim
)
# jsbsim: create targets for jsbsim
set(models
rascal
quadrotor_x
hexarotor_x
malolo
)
if(JSBSIM_INCLUDE_DIR)
set(worlds
none
LSZH
)
px4_add_git_submodule(TARGET git_jsbsim_bridge PATH "${PX4_SOURCE_DIR}/Tools/simulation/jsbsim/jsbsim_bridge")
# default jsbsim target
add_custom_target(jsbsim
COMMAND ${PX4_SOURCE_DIR}/Tools/simulation/jsbsim/sitl_run.sh $<TARGET_FILE:px4> "rascal" "LSZH" ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS px4 jsbsim_bridge
)
include(ExternalProject)
ExternalProject_Add(jsbsim_bridge
SOURCE_DIR ${PX4_SOURCE_DIR}/Tools/simulation/jsbsim/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
)
foreach(model ${models})
foreach(world ${worlds})
if(world STREQUAL "none")
add_custom_target(jsbsim_${model}
COMMAND ${PX4_SOURCE_DIR}/Tools/simulation/jsbsim/sitl_run.sh $<TARGET_FILE:px4> ${model} "LSZH" ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS px4 jsbsim_bridge
)
else()
add_custom_target(jsbsim_${model}__${world}
COMMAND ${PX4_SOURCE_DIR}/Tools/simulation/jsbsim/sitl_run.sh $<TARGET_FILE:px4> ${model} ${world} ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS px4 jsbsim_bridge
)
# jsbsim: create targets for jsbsim
set(models
rascal
quadrotor_x
hexarotor_x
malolo
)
set(worlds
none
LSZH
)
# find corresponding airframes
file(GLOB jsbsim_airframes
RELATIVE ${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/init.d-posix/airframes
${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/init.d-posix/airframes/*_jsbsim_*
)
# remove any .post files
foreach(jsbsim_airframe IN LISTS jsbsim_airframes)
if(jsbsim_airframe MATCHES ".post")
list(REMOVE_ITEM jsbsim_airframes ${jsbsim_airframe})
endif()
endforeach()
endforeach()
list(REMOVE_DUPLICATES jsbsim_airframes)
# default jsbsim target
add_custom_target(jsbsim
COMMAND ${PX4_SOURCE_DIR}/Tools/simulation/jsbsim/sitl_run.sh $<TARGET_FILE:px4> "rascal" "LSZH" ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS px4 jsbsim_bridge
)
foreach(model ${models})
# match model to airframe
set(airframe_model_only)
set(airframe_sys_autostart)
set(jsbsim_airframe_found)
foreach(jsbsim_airframe IN LISTS jsbsim_airframes)
string(REGEX REPLACE ".*_jsbsim_" "" airframe_model_only ${jsbsim_airframe})
string(REGEX REPLACE "_jsbsim_.*" "" airframe_sys_autostart ${jsbsim_airframe})
if(model STREQUAL ${airframe_model_only})
set(jsbsim_airframe_found ${jsbsim_airframe})
break()
endif()
endforeach()
if(jsbsim_airframe_found)
#message(STATUS "jsbsim model: ${model} (${airframe_model_only}), airframe: ${jsbsim_airframe_found}, SYS_AUTOSTART: ${airframe_sys_autostart}")
else()
message(WARNING "jsbsim missing model: ${model} (${airframe_model_only}), airframe: ${jsbsim_airframe_found}, SYS_AUTOSTART: ${airframe_sys_autostart}")
endif()
foreach(world ${worlds})
if(world STREQUAL "none")
add_custom_target(jsbsim_${model}
COMMAND ${PX4_SOURCE_DIR}/Tools/simulation/jsbsim/sitl_run.sh $<TARGET_FILE:px4> ${model} "LSZH" ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS px4 jsbsim_bridge
)
else()
add_custom_target(jsbsim_${model}__${world}
COMMAND ${PX4_SOURCE_DIR}/Tools/simulation/jsbsim/sitl_run.sh $<TARGET_FILE:px4> ${model} ${world} ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS px4 jsbsim_bridge
)
endif()
endforeach()
endforeach()
endif()