mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-09-25 20:28:26 +08:00
initial minimal PX4_ROS2 platform and px4_ros2_default build (#20689)
- new ROS2 platform in PX4 intended for creating configs that build and run entirely in ROS2 - PX4_CONFIG defaults to px4_ros2_default if no config specified and in a colcon workspace with ROS_VERSION=2 - currently doesn't do much other than allow you to build px4 msgs interface package
This commit is contained in:
@@ -57,4 +57,7 @@ else()
|
||||
endif()
|
||||
|
||||
include(CPack)
|
||||
include(bloaty)
|
||||
|
||||
if(${PX4_PLATFORM} MATCHES "nuttx")
|
||||
include(bloaty)
|
||||
endif()
|
||||
|
||||
@@ -155,9 +155,6 @@ function(px4_add_common_flags)
|
||||
# CXX only flags
|
||||
set(cxx_flags)
|
||||
list(APPEND cxx_flags
|
||||
-fno-exceptions
|
||||
-fno-threadsafe-statics
|
||||
|
||||
-Wreorder
|
||||
|
||||
# disabled warnings
|
||||
|
||||
@@ -39,7 +39,9 @@ include(px4_list_make_absolute)
|
||||
# Like add_library but with PX4 platform dependencies
|
||||
#
|
||||
function(px4_add_library target)
|
||||
add_library(${target} EXCLUDE_FROM_ALL ${ARGN})
|
||||
add_library(${target} STATIC EXCLUDE_FROM_ALL
|
||||
${ARGN}
|
||||
)
|
||||
|
||||
target_compile_definitions(${target} PRIVATE MODULE_NAME="${target}")
|
||||
|
||||
|
||||
@@ -33,6 +33,16 @@
|
||||
|
||||
# find PX4 config
|
||||
# look for in tree board config that matches CONFIG input
|
||||
|
||||
if(NOT CONFIG)
|
||||
# default to px4_ros2_default if building within a ROS2 colcon environment
|
||||
if(("$ENV{COLCON}" MATCHES "1") AND ("$ENV{ROS_VERSION}" MATCHES "2"))
|
||||
set(CONFIG "px4_ros2_default" CACHE STRING "desired configuration")
|
||||
else()
|
||||
set(CONFIG "px4_sitl_default" CACHE STRING "desired configuration")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT PX4_CONFIG_FILE)
|
||||
|
||||
file(GLOB_RECURSE board_configs
|
||||
@@ -40,8 +50,6 @@ if(NOT PX4_CONFIG_FILE)
|
||||
"boards/*.px4board"
|
||||
)
|
||||
|
||||
set(PX4_CONFIGS ${board_configs} CACHE STRING "PX4 board configs" FORCE)
|
||||
|
||||
foreach(filename ${board_configs})
|
||||
# parse input CONFIG into components to match with existing in tree configs
|
||||
# the platform prefix (eg nuttx_) is historical, and removed if present
|
||||
@@ -63,9 +71,9 @@ if(NOT PX4_CONFIG_FILE)
|
||||
)
|
||||
set(PX4_CONFIG_FILE "${PX4_SOURCE_DIR}/boards/${filename}" CACHE FILEPATH "path to PX4 CONFIG file" FORCE)
|
||||
set(PX4_BOARD_DIR "${PX4_SOURCE_DIR}/boards/${vendor}/${model}" CACHE STRING "PX4 board directory" FORCE)
|
||||
set(MODEL "${model}" CACHE STRING "PX4 board model" FORCE)
|
||||
set(VENDOR "${vendor}" CACHE STRING "PX4 board vendor" FORCE)
|
||||
set(LABEL "${label}" CACHE STRING "PX4 board vendor" FORCE)
|
||||
set(MODEL "${model}" CACHE STRING "PX4 board model" FORCE)
|
||||
set(VENDOR "${vendor}" CACHE STRING "PX4 board vendor" FORCE)
|
||||
set(LABEL "${label}" CACHE STRING "PX4 board vendor" FORCE)
|
||||
break()
|
||||
endif()
|
||||
|
||||
@@ -76,19 +84,15 @@ if(NOT PX4_CONFIG_FILE)
|
||||
)
|
||||
set(PX4_CONFIG_FILE "${PX4_SOURCE_DIR}/boards/${filename}" CACHE FILEPATH "path to PX4 CONFIG file" FORCE)
|
||||
set(PX4_BOARD_DIR "${PX4_SOURCE_DIR}/boards/${vendor}/${model}" CACHE STRING "PX4 board directory" FORCE)
|
||||
set(MODEL "${model}" CACHE STRING "PX4 board model" FORCE)
|
||||
set(VENDOR "${vendor}" CACHE STRING "PX4 board vendor" FORCE)
|
||||
set(LABEL "${label}" CACHE STRING "PX4 board vendor" FORCE)
|
||||
set(MODEL "${model}" CACHE STRING "PX4 board model" FORCE)
|
||||
set(VENDOR "${vendor}" CACHE STRING "PX4 board vendor" FORCE)
|
||||
set(LABEL "${label}" CACHE STRING "PX4 board vendor" FORCE)
|
||||
break()
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endif()
|
||||
|
||||
if(NOT PX4_CONFIG_FILE)
|
||||
message(FATAL_ERROR "PX4 config file not set, try one of ${PX4_CONFIGS}")
|
||||
endif()
|
||||
|
||||
message(STATUS "PX4 config file: ${PX4_CONFIG_FILE}")
|
||||
|
||||
include_directories(${PX4_BOARD_DIR}/src)
|
||||
@@ -108,9 +112,9 @@ set(PX4_BOARD_LABEL ${LABEL} CACHE STRING "PX4 board label" FORCE)
|
||||
set(PX4_CONFIG "${PX4_BOARD_VENDOR}_${PX4_BOARD_MODEL}_${PX4_BOARD_LABEL}" CACHE STRING "PX4 config" FORCE)
|
||||
|
||||
if(EXISTS "${PX4_BOARD_DIR}/uavcan_board_identity")
|
||||
include ("${PX4_BOARD_DIR}/uavcan_board_identity")
|
||||
include ("${PX4_BOARD_DIR}/uavcan_board_identity")
|
||||
endif()
|
||||
|
||||
if(EXISTS "${PX4_BOARD_DIR}/sitl.cmake")
|
||||
include ("${PX4_BOARD_DIR}/sitl.cmake")
|
||||
include ("${PX4_BOARD_DIR}/sitl.cmake")
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user