mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-31 18:47:21 +08:00
SITL jsbsim make airframes simulator specific
This commit is contained in:
@@ -53,10 +53,9 @@ px4_add_romfs_files(
|
|||||||
1030_plane
|
1030_plane
|
||||||
1031_plane_cam
|
1031_plane_cam
|
||||||
1032_plane_catapult
|
1032_plane_catapult
|
||||||
1033_rascal
|
1033_jsbsim_rascal
|
||||||
1034_rascal-electric
|
|
||||||
1035_techpod
|
1035_techpod
|
||||||
1036_malolo
|
1036_jsbsim_malolo
|
||||||
1037_believer
|
1037_believer
|
||||||
1038_glider
|
1038_glider
|
||||||
1039_advanced_plane
|
1039_advanced_plane
|
||||||
@@ -69,8 +68,9 @@ px4_add_romfs_files(
|
|||||||
1061_r1_rover
|
1061_r1_rover
|
||||||
1062_tf-r1
|
1062_tf-r1
|
||||||
1070_boat
|
1070_boat
|
||||||
3010_quadrotor_x
|
|
||||||
3011_hexarotor_x
|
3010_jsbsim_quadrotor_x
|
||||||
|
3011_jsbsim_hexarotor_x
|
||||||
|
|
||||||
4001_x500
|
4001_x500
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ else
|
|||||||
no_pxh=""
|
no_pxh=""
|
||||||
fi
|
fi
|
||||||
|
|
||||||
export PX4_SIM_MODEL=${model}
|
export PX4_SIM_MODEL=jsbsim_${model}
|
||||||
export PX4_SIM_WORLD=${world}
|
export PX4_SIM_WORLD=${world}
|
||||||
|
|
||||||
# This is needed for aircraft namespace mapping
|
# This is needed for aircraft namespace mapping
|
||||||
|
|||||||
@@ -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
|
if(DEFINED ENV{JSBSIM_ROOT_DIR} )
|
||||||
SOURCE_DIR ${PX4_SOURCE_DIR}/Tools/simulation/jsbsim/jsbsim_bridge
|
set(JSBSIM_ROOT_DIR "$ENV{JSBSIM_ROOT_DIR}" )
|
||||||
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
|
endif()
|
||||||
BINARY_DIR ${PX4_BINARY_DIR}/build_jsbsim_bridge
|
|
||||||
INSTALL_COMMAND ""
|
find_path(JSBSIM_INCLUDE_DIR
|
||||||
DEPENDS git_jsbsim_bridge
|
NAMES
|
||||||
USES_TERMINAL_CONFIGURE true
|
FGFDMExec.h
|
||||||
USES_TERMINAL_BUILD true
|
PATHS
|
||||||
EXCLUDE_FROM_ALL true
|
${JSBSIM_ROOT_DIR}/include/JSBSim
|
||||||
BUILD_ALWAYS 1
|
/usr/include/JSBSim
|
||||||
|
/usr/local/include/JSBSim
|
||||||
)
|
)
|
||||||
|
|
||||||
# jsbsim: create targets for jsbsim
|
if(JSBSIM_INCLUDE_DIR)
|
||||||
set(models
|
|
||||||
rascal
|
|
||||||
quadrotor_x
|
|
||||||
hexarotor_x
|
|
||||||
malolo
|
|
||||||
)
|
|
||||||
|
|
||||||
set(worlds
|
px4_add_git_submodule(TARGET git_jsbsim_bridge PATH "${PX4_SOURCE_DIR}/Tools/simulation/jsbsim/jsbsim_bridge")
|
||||||
none
|
|
||||||
LSZH
|
|
||||||
)
|
|
||||||
|
|
||||||
# default jsbsim target
|
include(ExternalProject)
|
||||||
add_custom_target(jsbsim
|
ExternalProject_Add(jsbsim_bridge
|
||||||
COMMAND ${PX4_SOURCE_DIR}/Tools/simulation/jsbsim/sitl_run.sh $<TARGET_FILE:px4> "rascal" "LSZH" ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
|
SOURCE_DIR ${PX4_SOURCE_DIR}/Tools/simulation/jsbsim/jsbsim_bridge
|
||||||
WORKING_DIRECTORY ${SITL_WORKING_DIR}
|
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
|
||||||
USES_TERMINAL
|
BINARY_DIR ${PX4_BINARY_DIR}/build_jsbsim_bridge
|
||||||
DEPENDS px4 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})
|
# jsbsim: create targets for jsbsim
|
||||||
foreach(world ${worlds})
|
set(models
|
||||||
if(world STREQUAL "none")
|
rascal
|
||||||
add_custom_target(jsbsim_${model}
|
quadrotor_x
|
||||||
COMMAND ${PX4_SOURCE_DIR}/Tools/simulation/jsbsim/sitl_run.sh $<TARGET_FILE:px4> ${model} "LSZH" ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
|
hexarotor_x
|
||||||
WORKING_DIRECTORY ${SITL_WORKING_DIR}
|
malolo
|
||||||
USES_TERMINAL
|
)
|
||||||
DEPENDS px4 jsbsim_bridge
|
|
||||||
)
|
set(worlds
|
||||||
else()
|
none
|
||||||
add_custom_target(jsbsim_${model}__${world}
|
LSZH
|
||||||
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
|
# 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()
|
endif()
|
||||||
endforeach()
|
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()
|
||||||
|
|||||||
Reference in New Issue
Block a user