simulation organization and cleanup

- new modules/simulation directory to collect all simulators and related modules
 - new Tools/simulation directory to collect and organize scattered simulation submodules, scripts, etc
 - simulation module renamed to simulator_mavlink
 - sih renamed to simulator_sih (not a great name, but I wanted to be clear it was a simulator)
 - ignition_simulator renamed to simulator_ignition_bridge
 - large sitl_target.cmake split by simulation option and in some cases pushed to appropriate modules
 - sitl targets broken down to what's actually available (eg jmavsim only has 1 model and 1 world)
 - new Gazebo consistently referred to as Ignition for now (probably the least confusing thing until we fully drop Gazebo classic support someday)
This commit is contained in:
Daniel Agar
2022-08-25 09:10:03 -04:00
parent 6b2509cbba
commit 4040e4cdf2
200 changed files with 1778 additions and 2806 deletions
+20 -10
View File
@@ -31,6 +31,8 @@ if (CMAKE_BUILD_TYPE STREQUAL FuzzTesting)
apps.cpp
)
else()
add_definitions(-DPX4_SOURCE_DIR="${PX4_SOURCE_DIR}" -DPX4_BINARY_DIR="${PX4_BINARY_DIR}")
add_executable(px4
src/px4/common/main.cpp
apps.cpp
@@ -84,7 +86,7 @@ px4_posix_generate_symlinks(
TARGET px4
)
if (config_romfs_root)
if(config_romfs_root)
add_subdirectory(${PX4_SOURCE_DIR}/ROMFS ${PX4_BINARY_DIR}/ROMFS)
add_dependencies(px4 romfs_gen_files_target)
endif()
@@ -110,11 +112,19 @@ elseif("${PX4_BOARD}" MATCHES "sitl")
# vscode launch.json
if(${PX4_BOARD_LABEL} MATCHES "replay")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Debug/launch_replay.json.in ${PX4_SOURCE_DIR}/.vscode/launch.json COPYONLY)
elseif(${PX4_CONFIG} MATCHES "px4_sitl_ign")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Debug/launch_sitl_ignition.json.in ${PX4_SOURCE_DIR}/.vscode/launch.json COPYONLY)
else()
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Debug/launch_sim.json.in ${PX4_SOURCE_DIR}/.vscode/launch.json COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Debug/launch_sitl_default.json.in ${PX4_SOURCE_DIR}/.vscode/launch.json COPYONLY)
endif()
include(sitl_target)
set(SITL_WORKING_DIR ${PX4_BINARY_DIR}/rootfs)
file(MAKE_DIRECTORY ${SITL_WORKING_DIR})
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Debug/posix.lldbinit ${SITL_WORKING_DIR}/.lldbinit COPYONLY)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Debug/posix.gdbinit ${SITL_WORKING_DIR}/.gdbinit COPYONLY)
if(BUILD_TESTING)
include(sitl_tests)
endif()
@@ -153,7 +163,7 @@ elseif("${PX4_BOARD}" MATCHES "sitl")
# px4 Tools files
install(
PROGRAMS
${PROJECT_SOURCE_DIR}/Tools/setup_gazebo.bash
${PROJECT_SOURCE_DIR}/Tools/simulation/gazebo/setup_gazebo.bash
${PROJECT_SOURCE_DIR}/Tools/upload_log.py
DESTINATION
${PROJECT_NAME}/Tools
@@ -181,19 +191,19 @@ elseif("${PX4_BOARD}" MATCHES "sitl")
# sitl_gazebo dirs
install(
DIRECTORY
${PROJECT_SOURCE_DIR}/Tools/sitl_gazebo/models
${PROJECT_SOURCE_DIR}/Tools/sitl_gazebo/worlds
${PROJECT_SOURCE_DIR}/Tools/simulation/gazebo/sitl_gazebo/models
${PROJECT_SOURCE_DIR}/Tools/simulation/gazebo/sitl_gazebo/worlds
DESTINATION
${PROJECT_NAME}/Tools/sitl_gazebo
${PROJECT_NAME}/Tools/simulation/gazebo/sitl_gazebo
)
# sitl_gazebo files
install(
FILES
${PROJECT_SOURCE_DIR}/Tools/sitl_gazebo/CMakeLists.txt
${PROJECT_SOURCE_DIR}/Tools/sitl_gazebo/package.xml
${PROJECT_SOURCE_DIR}/Tools/simulation/gazebo/sitl_gazebo/CMakeLists.txt
${PROJECT_SOURCE_DIR}/Tools/simulation/gazebo/sitl_gazebo/package.xml
DESTINATION
${PROJECT_NAME}/Tools/sitl_gazebo
${PROJECT_NAME}/Tools/simulation/gazebo/sitl_gazebo
)
endif()
+1 -1
View File
@@ -14,7 +14,7 @@
"${workspaceFolder}/test_data"
],
"stopAtEntry": false,
"cwd": "${command:cmake.buildDirectory}/tmp",
"cwd": "${command:cmake.buildDirectory}/rootfs",
"environment": [
{
"name": "replay",
@@ -2,17 +2,59 @@
"version": "0.2.0",
"configurations": [
{
"name": "SITL (gazebo)",
"name": "SITL (sihsim 10040_quadx)",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [
"${workspaceFolder}/ROMFS/px4fmu_common",
"-s", "etc/init.d-posix/rcS",
"-t", "${workspaceFolder}/test_data"
"${workspaceFolder}/ROMFS/px4fmu_common"
],
"stopAtEntry": false,
"cwd": "${command:cmake.buildDirectory}/tmp",
"cwd": "${command:cmake.buildDirectory}/rootfs",
"environment": [
{
"name": "PX4_SIM_MODEL",
"value": "quadx"
}
],
"externalConsole": false,
"postDebugTask": "px4_sitl_cleanup",
"linux": {
"MIMode": "gdb",
"externalConsole": false,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "PX4 ignore wq signals",
"text": "handle SIGCONT nostop noprint nopass",
"ignoreFailures": true
}
]
},
"osx": {
"MIMode": "lldb",
"externalConsole": true,
"setupCommands": [
{
"text": "pro hand -p true -s false -n false SIGCONT",
}
]
}
},
{
"name": "SITL (Gazebo Classic)",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [
"${workspaceFolder}/ROMFS/px4fmu_common"
],
"stopAtEntry": false,
"cwd": "${command:cmake.buildDirectory}/rootfs",
"environment": [
{
"name": "PX4_SIM_MODEL",
@@ -49,17 +91,15 @@
}
},
{
"name": "SITL (jmavsim iris)",
"name": "SITL (jmavsim)",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [
"${workspaceFolder}/ROMFS/px4fmu_common",
"-s", "etc/init.d-posix/rcS",
"-t", "${workspaceFolder}/test_data"
"${workspaceFolder}/ROMFS/px4fmu_common"
],
"stopAtEntry": false,
"cwd": "${command:cmake.buildDirectory}/tmp",
"cwd": "${command:cmake.buildDirectory}/rootfs",
"environment": [
{
"name": "PX4_SIM_MODEL",
@@ -100,12 +140,10 @@
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [
"${workspaceFolder}/ROMFS/px4fmu_common",
"-s", "etc/init.d-posix/rcS",
"-t", "${workspaceFolder}/test_data"
"${workspaceFolder}/ROMFS/px4fmu_common"
],
"stopAtEntry": false,
"cwd": "${command:cmake.buildDirectory}/tmp",
"cwd": "${command:cmake.buildDirectory}/rootfs",
"environment": [
{
"name": "PX4_SIM_MODEL",
@@ -145,10 +183,18 @@
"id": "PX4_SIM_MODEL",
"description": "PX4_SIM_MODEL",
"options": [
"x3",
"x4"
"iris",
"typhoon_h480",
"plane",
"plane_catapult",
"plane_lidar",
"standard_vtol",
"tailsitter",
"tiltrotor",
"r1_rover",
"boat"
],
"default": "x3"
"default": "iris"
}
]
}
@@ -0,0 +1,63 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "SITL (Ignition Gazebo)",
"type": "cppdbg",
"request": "launch",
"program": "${command:cmake.launchTargetPath}",
"args": [
"${workspaceFolder}/ROMFS/px4fmu_common",
"-s", "etc/init.d-posix/rcS"
],
"stopAtEntry": false,
"cwd": "${command:cmake.buildDirectory}/rootfs",
"environment": [
{
"name": "PX4_SIM_MODEL",
"value": "${input:PX4_SIM_MODEL}"
}
],
"externalConsole": false,
"preLaunchTask": "ign gazebo",
"postDebugTask": "ign gazebo kill",
"linux": {
"MIMode": "gdb",
"externalConsole": false,
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
},
{
"description": "PX4 ignore wq signals",
"text": "handle SIGCONT nostop noprint nopass",
"ignoreFailures": true
}
]
},
"osx": {
"MIMode": "lldb",
"externalConsole": true,
"setupCommands": [
{
"text": "pro hand -p true -s false -n false SIGCONT",
}
]
}
}
],
"inputs": [
{
"type": "pickString",
"id": "PX4_SIM_MODEL",
"description": "PX4_SIM_MODEL",
"options": [
"x3",
"x4"
],
"default": "x3"
}
]
}
+2
View File
@@ -0,0 +1,2 @@
handle SIGCONT nostop noprint nopass
run
+3
View File
@@ -0,0 +1,3 @@
run
pro hand -p true -s false -n false SIGCONT
continue
-418
View File
@@ -1,418 +0,0 @@
set(SITL_WORKING_DIR ${PX4_BINARY_DIR}/tmp)
file(MAKE_DIRECTORY ${SITL_WORKING_DIR})
file(MAKE_DIRECTORY ${SITL_WORKING_DIR}/rootfs)
# add a symlink to the logs dir to make it easier to find them
add_custom_command(OUTPUT ${PX4_BINARY_DIR}/logs
COMMAND ${CMAKE_COMMAND} -E create_symlink ${SITL_WORKING_DIR}/rootfs/log logs
WORKING_DIRECTORY ${PX4_BINARY_DIR}
)
add_custom_target(logs_symlink DEPENDS ${PX4_BINARY_DIR}/logs)
add_dependencies(px4 logs_symlink)
add_custom_target(run_config
COMMAND Tools/sitl_run.sh $<TARGET_FILE:px4> ${config_sitl_debugger} ${config_sitl_viewer} ${config_sitl_model} ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS px4 logs_symlink
)
px4_add_git_submodule(TARGET git_jmavsim PATH "${PX4_SOURCE_DIR}/Tools/jMAVSim")
# Add support for external project building
include(ExternalProject)
# Estimate an appropriate number of parallel jobs
cmake_host_system_information(RESULT AVAILABLE_PHYSICAL_MEMORY QUERY AVAILABLE_PHYSICAL_MEMORY)
cmake_host_system_information(RESULT NUMBER_OF_LOGICAL_CORES QUERY NUMBER_OF_LOGICAL_CORES)
set(parallel_jobs 1)
if(NOT NUMBER_OF_LOGICAL_CORES)
include(ProcessorCount)
ProcessorCount(NUMBER_OF_LOGICAL_CORES)
endif()
if(NOT AVAILABLE_PHYSICAL_MEMORY AND NUMBER_OF_LOGICAL_CORES GREATER_EQUAL 4)
# Memory estimate unavailable, use N-2 jobs
math(EXPR parallel_jobs "${NUMBER_OF_LOGICAL_CORES} - 2")
endif()
if (AVAILABLE_PHYSICAL_MEMORY)
# Allow an additional job for every 1.5GB of available physical memory
math(EXPR parallel_jobs "${AVAILABLE_PHYSICAL_MEMORY}/(3*1024/2)")
else()
set(AVAILABLE_PHYSICAL_MEMORY "?")
endif()
if(parallel_jobs GREATER NUMBER_OF_LOGICAL_CORES)
set(parallel_jobs ${NUMBER_OF_LOGICAL_CORES})
endif()
if(parallel_jobs LESS 1)
set(parallel_jobs 1)
endif()
message(DEBUG "${NUMBER_OF_LOGICAL_CORES} logical cores detected and ${AVAILABLE_PHYSICAL_MEMORY} megabytes of memory available.
Limiting sitl_gazebo concurrent jobs to ${parallel_jobs}")
# project to build sitl_gazebo if necessary
px4_add_git_submodule(TARGET git_gazebo PATH "${PX4_SOURCE_DIR}/Tools/sitl_gazebo")
ExternalProject_Add(sitl_gazebo
SOURCE_DIR ${PX4_SOURCE_DIR}/Tools/sitl_gazebo
CMAKE_ARGS
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DSEND_ODOMETRY_DATA=ON
-DGENERATE_ROS_MODELS=ON
BINARY_DIR ${PX4_BINARY_DIR}/build_gazebo
INSTALL_COMMAND ""
DEPENDS git_gazebo
USES_TERMINAL_CONFIGURE true
USES_TERMINAL_BUILD true
EXCLUDE_FROM_ALL true
BUILD_ALWAYS 1
BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> -- -j ${parallel_jobs}
)
ExternalProject_Add(mavsdk_tests
SOURCE_DIR ${PX4_SOURCE_DIR}/test/mavsdk_tests
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
BINARY_DIR ${PX4_BINARY_DIR}/mavsdk_tests
INSTALL_COMMAND ""
USES_TERMINAL_CONFIGURE true
USES_TERMINAL_BUILD true
EXCLUDE_FROM_ALL true
BUILD_ALWAYS 1
)
px4_add_git_submodule(TARGET git_flightgear_bridge PATH "${PX4_SOURCE_DIR}/Tools/flightgear_bridge")
ExternalProject_Add(flightgear_bridge
SOURCE_DIR ${PX4_SOURCE_DIR}/Tools/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
)
px4_add_git_submodule(TARGET git_jsbsim_bridge PATH "${PX4_SOURCE_DIR}/Tools/jsbsim_bridge")
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
gdb
lldb
valgrind
callgrind
)
set(models
none
believer
boat
cloudship
glider
iris
iris_dual_gps
iris_foggy_lidar
iris_irlock
iris_obs_avoid
iris_opt_flow
iris_opt_flow_mockup
iris_rplidar
iris_vision
nxp_cupcar
omnicopter
plane
plane_cam
plane_catapult
plane_lidar
px4vision
r1_rover
rover
shell
standard_vtol
standard_vtol_drop
tailsitter
techpod
tiltrotor
typhoon_h480
uuv_bluerov2_heavy
uuv_hippocampus
)
set(worlds
none
baylands
empty
ksql_airport
mcmillan_airfield
sonoma_raceway
warehouse
windy
yosemite
)
set(all_posix_vmd_make_targets)
foreach(viewer ${viewers})
foreach(debugger ${debuggers})
foreach(model ${models})
foreach(world ${worlds})
if(world STREQUAL "none")
if(debugger STREQUAL "none")
if(model STREQUAL "none")
set(_targ_name "${viewer}")
else()
set(_targ_name "${viewer}_${model}")
endif()
else()
if(model STREQUAL "none")
set(_targ_name "${viewer}___${debugger}")
else()
set(_targ_name "${viewer}_${model}_${debugger}")
endif()
endif()
add_custom_target(${_targ_name}
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh $<TARGET_FILE:px4> ${debugger} ${viewer} ${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})
if(viewer STREQUAL "gazebo")
add_dependencies(${_targ_name} px4 sitl_gazebo)
elseif(viewer STREQUAL "jmavsim")
add_dependencies(${_targ_name} px4 git_jmavsim)
endif()
else()
if(viewer STREQUAL "gazebo")
if(debugger STREQUAL "none")
if(model STREQUAL "none")
set(_targ_name "${viewer}___${world}")
else()
set(_targ_name "${viewer}_${model}__${world}")
endif()
else()
if(model STREQUAL "none")
set(_targ_name "${viewer}__${debugger}_${world}")
else()
set(_targ_name "${viewer}_${model}_${debugger}_${world}")
endif()
endif()
add_custom_target(${_targ_name}
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh $<TARGET_FILE:px4> ${debugger} ${viewer} ${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 sitl_gazebo)
endif()
endif()
endforeach()
endforeach()
endforeach()
endforeach()
# create targets for jsbsim
set(models_jsbsim
none
rascal
quadrotor_x
hexarotor_x
malolo
)
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()
# create targets for sihsim
set(models_sih
none
airplane
quadx
xvert
)
set(worlds_sih
none
)
foreach(debugger ${debuggers})
foreach(model ${models_sih})
foreach(world ${worlds_sih})
if(world STREQUAL "none")
if(debugger STREQUAL "none")
if(model STREQUAL "none")
set(_targ_name "sihsim")
else()
set(_targ_name "sihsim_${model}")
endif()
else()
if(model STREQUAL "none")
set(_targ_name "sihsim__${debugger}_${world}")
else()
set(_targ_name "sihsim_${model}_${debugger}_${world}")
endif()
endif()
add_custom_target(${_targ_name}
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh $<TARGET_FILE:px4> ${debugger} sihsim ${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})
else()
if(debugger STREQUAL "none")
if(model STREQUAL "none")
set(_targ_name "sihsim___${world}")
else()
set(_targ_name "sihsim_${model}__${world}")
endif()
else()
if(model STREQUAL "none")
set(_targ_name "sihsim___${debugger}_${world}")
else()
set(_targ_name "sihsim_${model}_${debugger}_${world}")
endif()
endif()
add_custom_target(${_targ_name}
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh $<TARGET_FILE:px4> ${debugger} sihsim ${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})
endif()
endforeach()
endforeach()
endforeach()
# add flighgear targets
if(ENABLE_LOCKSTEP_SCHEDULER STREQUAL "no")
set(models
rascal
rascal-electric
tf-g1
tf-g2
tf-r1
)
set(all_posix_vmd_make_targets)
foreach(model ${models})
set(_targ_name "flightgear_${model}")
add_custom_target(${_targ_name}
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh $<TARGET_FILE:px4> none flightgear ${model} none ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS logs_symlink
)
add_dependencies(${_targ_name} px4 flightgear_bridge)
list(APPEND all_posix_vmd_make_targets ${_targ_name})
endforeach()
endif()
# Ignition Gazebo
add_custom_target(ignition_x3
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh $<TARGET_FILE:px4> none ignition x3 empty ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS logs_symlink
)
add_custom_target(ignition_x4
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh $<TARGET_FILE:px4> none ignition x4 empty ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
WORKING_DIRECTORY ${SITL_WORKING_DIR}
USES_TERMINAL
DEPENDS logs_symlink
)
string(REPLACE ";" "," posix_vmd_make_target_list "${all_posix_vmd_make_targets}")
add_custom_target(list_vmd_make_targets
COMMAND sh -c "printf \"${posix_vmd_make_target_list}\\n\""
COMMENT "List of acceptable '${PX4_BOARD}' <viewer_model_debugger> targets:"
VERBATIM
)
+3 -10
View File
@@ -121,16 +121,9 @@ sanitizer_fail_test_on_error(sitl-imu_filtering)
# Dynamic module loading test
add_test(NAME dyn
COMMAND ${PX4_SOURCE_DIR}/Tools/sitl_run.sh
$<TARGET_FILE:px4>
none
none
test_dyn_hello
none
${PX4_SOURCE_DIR}
${PX4_BINARY_DIR}
$<TARGET_FILE:examples__dyn_hello>
WORKING_DIRECTORY ${SITL_WORKING_DIR})
COMMAND $<TARGET_FILE:px4> -s "${PX4_SOURCE_DIR}/posix-configs/SITL/init/test/test_dyn_hello"
WORKING_DIRECTORY ${PX4_BINARY_DIR}/src/examples/dyn_hello
)
set_tests_properties(dyn PROPERTIES PASS_REGULAR_EXPRESSION "1: PASSED")
sanitizer_fail_test_on_error(dyn)
+58 -17
View File
@@ -195,12 +195,15 @@ int main(int argc, char **argv)
#endif // (_POSIX_MEMLOCK > 0) && !ENABLE_LOCKSTEP_SCHEDULER
/* Server/daemon apps need to parse the command line arguments. */
std::string data_path{};
std::string commands_file = "etc/init.d/rcS";
std::string test_data_path{};
std::string working_directory{};
std::string test_data_path{};
std::string commands_file{};
bool working_directory_default = false;
int instance = 0;
bool instance_provided = false;
int myoptind = 1;
int ch;
@@ -226,6 +229,7 @@ int main(int argc, char **argv)
case 'i':
instance = strtoul(myoptarg, nullptr, 10);
instance_provided = true;
break;
case 'w':
@@ -239,17 +243,6 @@ int main(int argc, char **argv)
}
}
PX4_DEBUG("instance: %i", instance);
// change the CWD befre setting up links and other directories
if (!working_directory.empty()) {
int ret = change_directory(working_directory);
if (ret != PX4_OK) {
return ret;
}
}
if (myoptind < argc) {
std::string optional_arg = argv[myoptind];
@@ -258,6 +251,54 @@ int main(int argc, char **argv)
} // else: ROS argument (in the form __<name>:=<value>)
}
if (instance_provided) {
PX4_INFO("instance: %i", instance);
}
#if defined(PX4_BINARY_DIR)
// data_path & working_directory: if no commands specified or in current working directory),
// rootfs, or working directory specified then default to build directory (if it still exists)
if (commands_file.empty() && data_path.empty() && working_directory.empty()
&& dir_exists(PX4_BINARY_DIR"/etc")
) {
data_path = PX4_BINARY_DIR"/etc";
working_directory = PX4_BINARY_DIR"/rootfs";
working_directory_default = true;
}
#endif // PX4_BINARY_DIR
#if defined(PX4_SOURCE_DIR)
// test_data_path: default to build source test_data directory (if it exists)
if (test_data_path.empty() && dir_exists(PX4_SOURCE_DIR"/test_data")) {
test_data_path = PX4_SOURCE_DIR"/test_data";
}
#endif // PX4_SOURCE_DIR
if (commands_file.empty()) {
commands_file = "etc/init.d-posix/rcS";
}
// change the CWD befre setting up links and other directories
if (!working_directory.empty()) {
// if instance specified, but
if (instance_provided && working_directory_default) {
working_directory += "/" + std::to_string(instance);
PX4_INFO("working directory %s", working_directory.c_str());
}
int ret = change_directory(working_directory);
if (ret != PX4_OK) {
return ret;
}
}
if (is_server_running(instance, true)) {
// allow running multiple instances, but the server is only started for the first
PX4_INFO("PX4 daemon already running for instance %i (%s)", instance, strerror(errno));
@@ -362,7 +403,7 @@ int create_symlinks_if_needed(std::string &data_path)
}
PX4_INFO_RAW("Creating symlink %s -> %s\n", src_path.c_str(), dest_path.c_str());
PX4_DEBUG("Creating symlink %s -> %s\n", src_path.c_str(), dest_path.c_str());
// create sym-link
int ret = symlink(src_path.c_str(), dest_path.c_str());
@@ -517,7 +558,7 @@ int run_startup_script(const std::string &commands_file, const std::string &abso
}
PX4_INFO("Calling startup script: %s", shell_command.c_str());
PX4_INFO("startup script: %s", shell_command.c_str());
int ret = 0;
@@ -552,7 +593,7 @@ void print_usage()
printf("\n");
printf(" px4 [-h|-d] [-s <startup_file>] [-t <test_data_directory>] [<rootfs_directory>] [-i <instance>] [-w <working_directory>]\n");
printf("\n");
printf(" -s <startup_file> shell script to be used as startup (default=etc/init.d/rcS)\n");
printf(" -s <startup_file> shell script to be used as startup (default=etc/init.d-posix/rcS)\n");
printf(" <rootfs_directory> directory where startup files and mixers are located,\n");
printf(" (if not given, CWD is used)\n");
printf(" -i <instance> px4 instance id to run multiple instances [0...N], default=0\n");