mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-16 21:53:34 +08:00
rename 'gazebo' simulation to 'gazebo-classic' (#20936)
- use `gazebo-classic` everywhere consistently referring to the original Gazebo (eg version 9,10,11) - additional `gazebo_*` helper targets added for compatibility, but warn about deprecation and tell you the new target naming - use `gz` everywhere when referring to Gazebo (aka Ignition Gazebo or new Gazebo)
This commit is contained in:
@@ -56,6 +56,6 @@ px4_add_module(
|
||||
)
|
||||
|
||||
include(sitl_targets_flightgear.cmake)
|
||||
include(sitl_targets_gazebo.cmake)
|
||||
include(sitl_targets_gazebo-classic.cmake)
|
||||
include(sitl_targets_jmavsim.cmake)
|
||||
include(sitl_targets_jsbsim.cmake)
|
||||
|
||||
+57
-40
@@ -3,7 +3,7 @@ find_package(gazebo)
|
||||
|
||||
if(gazebo_FOUND)
|
||||
|
||||
message(STATUS "Found gazebo-classic ${gazebo_VERSION}, including sitl_gazebo-classic simulator and targets")
|
||||
message(STATUS "Found gazebo-classic ${gazebo_VERSION}, including sitl_gazebo-classic simulator and gazebo-classic targets")
|
||||
|
||||
# Estimate an appropriate number of parallel jobs
|
||||
cmake_host_system_information(RESULT AVAILABLE_PHYSICAL_MEMORY QUERY AVAILABLE_PHYSICAL_MEMORY)
|
||||
@@ -40,17 +40,17 @@ if(gazebo_FOUND)
|
||||
# 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/simulation/gazebo/sitl_gazebo")
|
||||
px4_add_git_submodule(TARGET git_sitl_gazebo-classic PATH "${PX4_SOURCE_DIR}/Tools/simulation/gazebo-classic/sitl_gazebo-classic")
|
||||
include(ExternalProject)
|
||||
ExternalProject_Add(sitl_gazebo
|
||||
SOURCE_DIR ${PX4_SOURCE_DIR}/Tools/simulation/gazebo/sitl_gazebo
|
||||
ExternalProject_Add(sitl_gazebo-classic
|
||||
SOURCE_DIR ${PX4_SOURCE_DIR}/Tools/simulation/gazebo-classic/sitl_gazebo-classic
|
||||
CMAKE_ARGS
|
||||
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
|
||||
-DSEND_ODOMETRY_DATA=ON
|
||||
-DGENERATE_ROS_MODELS=ON
|
||||
BINARY_DIR ${PX4_BINARY_DIR}/build_gazebo
|
||||
BINARY_DIR ${PX4_BINARY_DIR}/build_gazebo-classic
|
||||
INSTALL_COMMAND ""
|
||||
DEPENDS git_gazebo
|
||||
DEPENDS git_sitl_gazebo-classic
|
||||
USES_TERMINAL_CONFIGURE true
|
||||
USES_TERMINAL_BUILD true
|
||||
EXCLUDE_FROM_ALL true
|
||||
@@ -114,34 +114,34 @@ if(gazebo_FOUND)
|
||||
)
|
||||
|
||||
# find corresponding airframes
|
||||
file(GLOB gazebo_airframes
|
||||
RELATIVE ${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/init.d-posix/airframes
|
||||
${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/init.d-posix/airframes/*_gazebo_*
|
||||
file(GLOB gazebo-classic_airframes
|
||||
RELATIVE ${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/init.d-posix/airframes
|
||||
${PX4_SOURCE_DIR}/ROMFS/px4fmu_common/init.d-posix/airframes/*_gazebo-classic_*
|
||||
)
|
||||
|
||||
# remove any .post files
|
||||
foreach(gazebo_airframe IN LISTS gazebo_airframes)
|
||||
if(gazebo_airframe MATCHES ".post")
|
||||
list(REMOVE_ITEM gazebo_airframes ${gazebo_airframe})
|
||||
foreach(gazebo-classic_airframe IN LISTS gazebo-classic_airframes)
|
||||
if(gazebo-classic_airframe MATCHES ".post")
|
||||
list(REMOVE_ITEM gazebo-classic_airframes ${gazebo-classic_airframe})
|
||||
endif()
|
||||
endforeach()
|
||||
list(REMOVE_DUPLICATES gazebo_airframes)
|
||||
list(REMOVE_DUPLICATES gazebo-classic_airframes)
|
||||
|
||||
foreach(gazebo_airframe IN LISTS gazebo_airframes)
|
||||
foreach(gazebo-classic_airframe IN LISTS gazebo-classic_airframes)
|
||||
set(model_only)
|
||||
string(REGEX REPLACE ".*_gazebo_" "" model_only ${gazebo_airframe})
|
||||
string(REGEX REPLACE ".*_gazebo-classic_" "" model_only ${gazebo-classic_airframe})
|
||||
|
||||
if(EXISTS "${PX4_SOURCE_DIR}/Tools/simulation/gazebo/sitl_gazebo/models/${model_only}")
|
||||
if(EXISTS "${PX4_SOURCE_DIR}/Tools/simulation/gazebo-classic/sitl_gazebo-classic/models/${model_only}")
|
||||
|
||||
if((EXISTS "${PX4_SOURCE_DIR}/Tools/simulation/gazebo/sitl_gazebo/models/${model_only}/${model_only}.sdf")
|
||||
OR (EXISTS "${PX4_SOURCE_DIR}/Tools/simulation/gazebo/sitl_gazebo/models/${model_only}/${model_only}.sdf.jinja"))
|
||||
if((EXISTS "${PX4_SOURCE_DIR}/Tools/simulation/gazebo-classic/sitl_gazebo-classic/models/${model_only}/${model_only}.sdf")
|
||||
OR (EXISTS "${PX4_SOURCE_DIR}/Tools/simulation/gazebo-classic/sitl_gazebo-classic/models/${model_only}/${model_only}.sdf.jinja"))
|
||||
#message(STATUS "SDF file found for ${model_only}")
|
||||
else()
|
||||
message(WARNING "No SDF file found for ${model_only}")
|
||||
endif()
|
||||
|
||||
else()
|
||||
message(WARNING "model directory ${PX4_SOURCE_DIR}/Tools/simulation/gazebo/sitl_gazebo/models/${model_only} not found")
|
||||
message(WARNING "model directory ${PX4_SOURCE_DIR}/Tools/simulation/gazebo-classic/sitl_gazebo-classic/models/${model_only} not found")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
@@ -151,73 +151,90 @@ if(gazebo_FOUND)
|
||||
# match model to airframe
|
||||
set(airframe_model_only)
|
||||
set(airframe_sys_autostart)
|
||||
set(gazebo_airframe_found)
|
||||
foreach(gazebo_airframe IN LISTS gazebo_airframes)
|
||||
set(gazebo-classic_airframe_found)
|
||||
foreach(gazebo-classic_airframe IN LISTS gazebo-classic_airframes)
|
||||
|
||||
string(REGEX REPLACE ".*_gazebo_" "" airframe_model_only ${gazebo_airframe})
|
||||
string(REGEX REPLACE "_gazebo_.*" "" airframe_sys_autostart ${gazebo_airframe})
|
||||
string(REGEX REPLACE ".*_gazebo-classic_" "" airframe_model_only ${gazebo-classic_airframe})
|
||||
string(REGEX REPLACE "_gazebo-classic_.*" "" airframe_sys_autostart ${gazebo-classic_airframe})
|
||||
|
||||
if(model STREQUAL ${airframe_model_only})
|
||||
set(gazebo_airframe_found ${gazebo_airframe})
|
||||
set(gazebo-classic_airframe_found ${gazebo-classic_airframe})
|
||||
break()
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
if(gazebo_airframe_found)
|
||||
#message(STATUS "gazebo model: ${model} (${airframe_model_only}), airframe: ${gazebo_airframe_found}, SYS_AUTOSTART: ${airframe_sys_autostart}")
|
||||
if(gazebo-classic_airframe_found)
|
||||
#message(STATUS "gazebo-classic model: ${model} (${airframe_model_only}), airframe: ${gazebo-classic_airframe_found}, SYS_AUTOSTART: ${airframe_sys_autostart}")
|
||||
else()
|
||||
message(WARNING "gazebo missing model: ${model} (${airframe_model_only}), airframe: ${gazebo_airframe_found}, SYS_AUTOSTART: ${airframe_sys_autostart}")
|
||||
message(WARNING "gazebo-classic missing model: ${model} (${airframe_model_only}), airframe: ${gazebo-classic_airframe_found}, SYS_AUTOSTART: ${airframe_sys_autostart}")
|
||||
endif()
|
||||
|
||||
foreach(world ${worlds})
|
||||
if(world STREQUAL "none")
|
||||
if(debugger STREQUAL "none")
|
||||
if(model STREQUAL "none")
|
||||
set(_targ_name "gazebo")
|
||||
set(_targ_name "gazebo-classic")
|
||||
else()
|
||||
set(_targ_name "gazebo_${model}")
|
||||
set(_targ_name "gazebo-classic_${model}")
|
||||
endif()
|
||||
else()
|
||||
if(model STREQUAL "none")
|
||||
set(_targ_name "gazebo___${debugger}")
|
||||
set(_targ_name "gazebo-classic___${debugger}")
|
||||
else()
|
||||
set(_targ_name "gazebo_${model}_${debugger}")
|
||||
set(_targ_name "gazebo-classic_${model}_${debugger}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_custom_target(${_targ_name}
|
||||
COMMAND ${PX4_SOURCE_DIR}/Tools/simulation/gazebo/sitl_run.sh $<TARGET_FILE:px4> ${debugger} ${model} ${world} ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
|
||||
COMMAND ${PX4_SOURCE_DIR}/Tools/simulation/gazebo-classic/sitl_run.sh $<TARGET_FILE:px4> ${debugger} ${model} ${world} ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
|
||||
WORKING_DIRECTORY ${SITL_WORKING_DIR}
|
||||
USES_TERMINAL
|
||||
DEPENDS px4 sitl_gazebo
|
||||
DEPENDS px4 sitl_gazebo-classic
|
||||
)
|
||||
|
||||
string(REPLACE "gazebo-classic" "gazebo" _targ_name_compat ${_targ_name})
|
||||
add_custom_target(${_targ_name_compat}
|
||||
COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red "WARNING ${_targ_name_compat} target DEPRECATED, please use ${_targ_name}"
|
||||
COMMAND ${CMAKE_COMMAND} --build ${PX4_BINARY_DIR} -- ${_targ_name}
|
||||
USES_TERMINAL
|
||||
VERBATIM
|
||||
)
|
||||
else()
|
||||
if(debugger STREQUAL "none")
|
||||
if(model STREQUAL "none")
|
||||
set(_targ_name "gazebo___${world}")
|
||||
set(_targ_name "gazebo-classic___${world}")
|
||||
else()
|
||||
set(_targ_name "gazebo_${model}__${world}")
|
||||
set(_targ_name "gazebo-classic_${model}__${world}")
|
||||
endif()
|
||||
else()
|
||||
if(model STREQUAL "none")
|
||||
set(_targ_name "gazebo__${debugger}_${world}")
|
||||
set(_targ_name "gazebo-classic__${debugger}_${world}")
|
||||
else()
|
||||
set(_targ_name "gazebo_${model}_${debugger}_${world}")
|
||||
set(_targ_name "gazebo-classic_${model}_${debugger}_${world}")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
add_custom_target(${_targ_name}
|
||||
COMMAND ${PX4_SOURCE_DIR}/Tools/simulation/gazebo/sitl_run.sh $<TARGET_FILE:px4> ${debugger} ${model} ${world} ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
|
||||
COMMAND ${PX4_SOURCE_DIR}/Tools/simulation/gazebo-classic/sitl_run.sh $<TARGET_FILE:px4> ${debugger} ${model} ${world} ${PX4_SOURCE_DIR} ${PX4_BINARY_DIR}
|
||||
WORKING_DIRECTORY ${SITL_WORKING_DIR}
|
||||
USES_TERMINAL
|
||||
DEPENDS px4 sitl_gazebo
|
||||
DEPENDS px4 sitl_gazebo-classic
|
||||
)
|
||||
|
||||
string(REPLACE "gazebo-classic" "gazebo" _targ_name_compat ${_targ_name})
|
||||
add_custom_target(${_targ_name_compat}
|
||||
COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --red "WARNING ${_targ_name_compat} target DEPRECATED, please use ${_targ_name}"
|
||||
COMMAND ${CMAKE_COMMAND} --build ${PX4_BINARY_DIR} -- ${_targ_name}
|
||||
USES_TERMINAL
|
||||
VERBATIM
|
||||
)
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endforeach()
|
||||
|
||||
add_custom_target(gazebo DEPENDS gazebo_iris) # alias
|
||||
add_custom_target(gazebo-classic DEPENDS gazebo-classic_iris) # alias
|
||||
add_custom_target(gazebo DEPENDS gazebo-classic_iris) # alias
|
||||
|
||||
# mavsdk tests currently depend on sitl_gazebo
|
||||
ExternalProject_Add(mavsdk_tests
|
||||
Reference in New Issue
Block a user