SITL sihsim make airframes simulator specific

This commit is contained in:
Daniel Agar 2023-01-04 17:44:03 -05:00
parent 95a6eba36c
commit 75125da34c
7 changed files with 46 additions and 11 deletions

View File

@ -41,4 +41,3 @@ param set-default PWM_MAIN_FUNC3 103
param set-default PWM_MAIN_FUNC4 104
param set SIH_VEHICLE_TYPE 0

View File

@ -37,9 +37,6 @@ px4_add_romfs_files(
10018_iris_foggy_lidar
10019_omnicopter
10030_px4vision
10040_quadx
10041_airplane
10042_xvert
1010_iris_opt_flow
1010_iris_opt_flow.post
1011_iris_irlock
@ -83,4 +80,8 @@ px4_add_romfs_files(
6011_typhoon_h480
6011_typhoon_h480.post
10040_sihsim_quadx
10041_sihsim_airplane
10042_sihsim_xvert
)

View File

@ -6,6 +6,8 @@ param set-default IMU_INTEG_RATE 250
if [ "$PX4_SIMULATOR" = "sihsim" ] || [ "$(param show -q SYS_AUTOSTART)" -eq "0" ]; then
echo "INFO [init] SIH simulator"
if simulator_sih start; then
sensor_baro_sim start

View File

@ -46,7 +46,7 @@
}
},
{
"name": "SITL (sihsim 10040_quadx)",
"name": "SITL (sihsim_quadx SYS_AUTOSTART=10040)",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
@ -57,15 +57,13 @@
"cwd": "${command:cmake.buildDirectory}/rootfs",
"environment": [
{
"name": "PX4_SIM_MODEL",
"value": "quadx"
"name": "PX4_SYS_AUTOSTART",
"value": "10040"
}
],
"externalConsole": false,
"postDebugTask": "px4_sitl_cleanup",
"linux": {
"MIMode": "gdb",
"externalConsole": false,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
@ -81,7 +79,6 @@
},
"osx": {
"MIMode": "lldb",
"externalConsole": true,
"setupCommands": [
{
"text": "pro hand -p true -s false -n false SIGCONT",

View File

@ -54,9 +54,45 @@ if(PX4_PLATFORM MATCHES "posix")
xvert
)
# find corresponding airframes
file(GLOB sihsim_airframes
RELATIVE ${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/init.d-posix/airframes
${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/init.d-posix/airframes/*_sihsim_*
)
# remove any .post files
foreach(sihsim_airframe IN LISTS sihsim_airframes)
if(sihsim_airframe MATCHES ".post")
list(REMOVE_ITEM sihsim_airframes ${sihsim_airframe})
endif()
endforeach()
list(REMOVE_DUPLICATES sihsim_airframes)
foreach(model ${models})
# match model to airframe
set(airframe_model_only)
set(airframe_sys_autostart)
set(sihsim_airframe_found)
foreach(sihsim_airframe IN LISTS sihsim_airframes)
string(REGEX REPLACE ".*_sihsim_" "" airframe_model_only ${sihsim_airframe})
string(REGEX REPLACE "_sihsim_.*" "" airframe_sys_autostart ${sihsim_airframe})
if(model STREQUAL ${airframe_model_only})
set(sihsim_airframe_found ${sihsim_airframe})
break()
endif()
endforeach()
if(sihsim_airframe_found)
#message(STATUS "sihsim model: ${model} (${airframe_model_only}), airframe: ${sihsim_airframe_found}, SYS_AUTOSTART: ${airframe_sys_autostart}")
else()
message(WARNING "sihsim missing model: ${model} (${airframe_model_only}), airframe: ${sihsim_airframe_found}, SYS_AUTOSTART: ${airframe_sys_autostart}")
endif()
add_custom_target(sihsim_${model}
COMMAND ${CMAKE_COMMAND} -E env PX4_SIM_MODEL=${model} PX4_SIMULATOR=sihsim $<TARGET_FILE:px4>
COMMAND ${CMAKE_COMMAND} -E env PX4_SIM_MODEL=sihsim_${model} PX4_SIMULATOR=sihsim $<TARGET_FILE:px4>
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS px4