SITL flightgear make airframes simulator specific

This commit is contained in:
Daniel Agar 2023-01-04 20:22:04 -05:00
parent 1abe35c220
commit ae4cb24100
7 changed files with 78 additions and 36 deletions

View File

@ -54,6 +54,7 @@ px4_add_romfs_files(
1031_plane_cam
1032_plane_catapult
1033_jsbsim_rascal
1034_flightgear_rascal-electric
1035_techpod
1036_jsbsim_malolo
1037_believer
@ -66,7 +67,6 @@ px4_add_romfs_files(
1044_plane_lidar
1060_rover
1061_r1_rover
1062_tf-r1
1070_boat
3010_jsbsim_quadrotor_x
@ -74,8 +74,6 @@ px4_add_romfs_files(
4001_x500
17001_tf-g1
17002_tf-g2
2507_cloudship
6011_typhoon_h480
@ -84,4 +82,7 @@ px4_add_romfs_files(
10040_sihsim_quadx
10041_sihsim_airplane
10042_sihsim_xvert
17001_flightgear_tf-g1
17002_flightgear_tf-g2
)

View File

@ -22,7 +22,7 @@ echo build_path: $build_path
rootfs="$build_path/rootfs" # this is the working directory
mkdir -p "$rootfs"
export PX4_SIM_MODEL=${model}
export PX4_SIM_MODEL=flightgear_${model}
echo "FG setup"
cd "${src_path}/Tools/simulation/flightgear/flightgear_bridge/"

View File

@ -1,43 +1,84 @@
if(ENABLE_LOCKSTEP_SCHEDULER STREQUAL "no")
px4_add_git_submodule(TARGET git_flightgear_bridge PATH "${PX4_SOURCE_DIR}/Tools/simulation/flightgear/flightgear_bridge")
find_program(FGFS_PATH "fgfs")
include(ExternalProject)
ExternalProject_Add(flightgear_bridge
SOURCE_DIR ${PX4_SOURCE_DIR}/Tools/simulation/flightgear/flightgear_bridge
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
BINARY_DIR ${PX4_BINARY_DIR}/build_flightgear_bridge
INSTALL_COMMAND ""
DEPENDS git_flightgear_bridge
USES_TERMINAL_CONFIGURE true
USES_TERMINAL_BUILD true
EXCLUDE_FROM_ALL true
BUILD_ALWAYS 1
)
if(FGFS_PATH)
# flighgear targets
set(models
rascal
rascal-electric
tf-g1
tf-g2
tf-r1
)
px4_add_git_submodule(TARGET git_flightgear_bridge PATH "${PX4_SOURCE_DIR}/Tools/simulation/flightgear/flightgear_bridge")
# default flightgear target
add_custom_target(flightgear
COMMAND ${PX4_SOURCE_DIR}/Tools/simulation/flightgear/sitl_run.sh $<TARGET_FILE:px4> "rascal" ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS px4 flightgear_bridge
)
include(ExternalProject)
ExternalProject_Add(flightgear_bridge
SOURCE_DIR ${PX4_SOURCE_DIR}/Tools/simulation/flightgear/flightgear_bridge
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
BINARY_DIR ${PX4_BINARY_DIR}/build_flightgear_bridge
INSTALL_COMMAND ""
DEPENDS git_flightgear_bridge
USES_TERMINAL_CONFIGURE true
USES_TERMINAL_BUILD true
EXCLUDE_FROM_ALL true
BUILD_ALWAYS 1
)
foreach(model ${models})
add_custom_target(flightgear_${model}
COMMAND ${PX4_SOURCE_DIR}/Tools/simulation/flightgear/sitl_run.sh $<TARGET_FILE:px4> ${model} ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
# flighgear targets
set(models
rascal
rascal-electric
tf-g1
tf-g2
tf-r1
)
# find corresponding airframes
file(GLOB flightgear_airframes
RELATIVE ${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/init.d-posix/airframes
${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/init.d-posix/airframes/*_flightgear_*
)
# remove any .post files
foreach(flightgear_airframe IN LISTS flightgear_airframes)
if(flightgear_airframe MATCHES ".post")
list(REMOVE_ITEM flightgear_airframes ${flightgear_airframe})
endif()
endforeach()
list(REMOVE_DUPLICATES flightgear_airframes)
# default flightgear target
add_custom_target(flightgear
COMMAND ${PX4_SOURCE_DIR}/Tools/simulation/flightgear/sitl_run.sh $<TARGET_FILE:px4> "rascal" ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS px4 flightgear_bridge
)
endforeach()
foreach(model ${models})
# match model to airframe
set(airframe_model_only)
set(airframe_sys_autostart)
set(flightgear_airframe_found)
foreach(flightgear_airframe IN LISTS flightgear_airframes)
string(REGEX REPLACE ".*_flightgear_" "" airframe_model_only ${flightgear_airframe})
string(REGEX REPLACE "_flightgear_.*" "" airframe_sys_autostart ${flightgear_airframe})
if(model STREQUAL ${airframe_model_only})
set(flightgear_airframe_found ${flightgear_airframe})
break()
endif()
endforeach()
if(flightgear_airframe_found)
#message(STATUS "flightgear model: ${model} (${airframe_model_only}), airframe: ${flightgear_airframe_found}, SYS_AUTOSTART: ${airframe_sys_autostart}")
else()
message(WARNING "flightgear missing model: ${model} (${airframe_model_only}), airframe: ${flightgear_airframe_found}, SYS_AUTOSTART: ${airframe_sys_autostart}")
endif()
add_custom_target(flightgear_${model}
COMMAND ${PX4_SOURCE_DIR}/Tools/simulation/flightgear/sitl_run.sh $<TARGET_FILE:px4> ${model} ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS px4 flightgear_bridge
)
endforeach()
endif()
endif()