mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-03 14:08:52 +08:00
Add Zenoh pico support
This commit is contained in:
committed by
Daniel Agar
parent
5137ca1ccc
commit
019d232911
@@ -336,3 +336,128 @@ add_custom_command(
|
||||
add_library(uorb_msgs ${uorb_headers} ${msg_out_path}/uORBTopics.hpp ${uorb_sources} ${msg_source_out_path}/uORBTopics.cpp)
|
||||
target_link_libraries(uorb_msgs PRIVATE m)
|
||||
add_dependencies(uorb_msgs prebuild_targets uorb_headers)
|
||||
|
||||
if(CONFIG_LIB_CDRSTREAM)
|
||||
set(uorb_cdr_idl)
|
||||
set(uorb_cdr_msg)
|
||||
set(uorb_cdr_idl_uorb)
|
||||
set(idl_include_path ${PX4_BINARY_DIR}/uORB/idl)
|
||||
set(idl_out_path ${idl_include_path}/px4/msg)
|
||||
set(idl_uorb_path ${PX4_BINARY_DIR}/msg/px4/msg)
|
||||
|
||||
# Make sure that CycloneDDS has been checkout out
|
||||
execute_process(COMMAND git submodule sync src/lib/cdrstream/cyclonedds
|
||||
WORKING_DIRECTORY ${PX4_SOURCE_DIR} )
|
||||
execute_process(COMMAND git submodule update --init --force src/lib/cdrstream/cyclonedds
|
||||
WORKING_DIRECTORY ${PX4_SOURCE_DIR} )
|
||||
|
||||
# CycloneDDS-tools doesn't ship with the cdrstream-desc feature thus we've to compile idlc from source
|
||||
MESSAGE(STATUS "Configuring idlc :" ${CMAKE_CURRENT_BINARY_DIR}/idlc)
|
||||
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/idlc)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} ${PX4_SOURCE_DIR}/src/lib/cdrstream/cyclonedds
|
||||
-DCMAKE_C_COMPILER=/usr/bin/gcc
|
||||
-DBUILD_EXAMPLES=OFF
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/idlc
|
||||
RESULT_VARIABLE CMD_ERROR
|
||||
OUTPUT_FILE CMD_OUTPUT )
|
||||
MESSAGE(STATUS "Building idlc :" ${CMAKE_CURRENT_BINARY_DIR}/idlc)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} --build . --target idlc
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/idlc
|
||||
RESULT_VARIABLE CMD_ERROR
|
||||
OUTPUT_FILE CMD_OUTPUT )
|
||||
list(APPEND CMAKE_PROGRAM_PATH "${CMAKE_CURRENT_BINARY_DIR}/idlc/bin")
|
||||
|
||||
# Copy .msg files
|
||||
foreach(msg_file ${msg_files})
|
||||
get_filename_component(msg ${msg_file} NAME_WE)
|
||||
configure_file(${PX4_SOURCE_DIR}/msg/${msg}.msg ${idl_out_path}/${msg}.msg COPYONLY)
|
||||
list(APPEND uorb_cdr_idl ${idl_out_path}/${msg}.idl)
|
||||
list(APPEND uorb_cdr_msg ${idl_out_path}/${msg}.msg)
|
||||
list(APPEND uorb_cdr_idl_uorb ${idl_uorb_path}/${msg}.h)
|
||||
endforeach()
|
||||
|
||||
# Generate IDL from .msg using rosidl_adapter
|
||||
# Note this a submodule inside PX4 hence no ROS2 installation required
|
||||
add_custom_command(
|
||||
OUTPUT ${uorb_cdr_idl}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-E env "PYTHONPATH=${PX4_SOURCE_DIR}/src/lib/cdrstream/rosidl/rosidl_adapter:${PX4_SOURCE_DIR}/src/lib/cdrstream/rosidl/rosidl_cli"
|
||||
${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/src/lib/cdrstream/msg2idl.py
|
||||
${uorb_cdr_msg}
|
||||
DEPENDS
|
||||
${uorb_cdr_msg}
|
||||
git_cyclonedds
|
||||
COMMENT "Generating IDL from uORB topic headers"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
VERBATIM
|
||||
)
|
||||
|
||||
# Generate C definitions from IDL
|
||||
set(CYCLONEDDS_DIR ${PX4_SOURCE_DIR}/src/lib/cdrstream/cyclonedds)
|
||||
include("${CYCLONEDDS_DIR}/cmake/Modules/Generate.cmake")
|
||||
idlc_generate(TARGET uorb_cdrstream
|
||||
FEATURES "cdrstream-desc"
|
||||
FILES ${uorb_cdr_idl}
|
||||
INCLUDES ${idl_include_path}
|
||||
BASE_DIR ${idl_include_path}
|
||||
WARNINGS no-implicit-extensibility)
|
||||
target_link_libraries(uorb_cdrstream INTERFACE cdr)
|
||||
|
||||
# Generate and overwrite IDL header with custom headers for uORB operatability
|
||||
# We typedef the IDL struct the uORB struct so that the IDL offset calculate
|
||||
# the offset of internal uORB struct for serialization/deserialization
|
||||
|
||||
# In the future we might want to turn this around let the IDL struct be the leading ABI
|
||||
# However we need to remove the padding for logging and remove the re-ordering of fields
|
||||
|
||||
add_custom_target(
|
||||
uorb_idl_header
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_topic_files.py
|
||||
--uorb-idl-header
|
||||
-f ${msg_files}
|
||||
-i ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-o ${idl_uorb_path}
|
||||
-e ${PX4_SOURCE_DIR}/Tools/msg/templates/cdrstream
|
||||
DEPENDS
|
||||
uorb_cdrstream
|
||||
${msg_files}
|
||||
${PX4_SOURCE_DIR}/Tools/msg/templates/cdrstream/uorb_idl_header.h.em
|
||||
${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_topic_files.py
|
||||
${PX4_SOURCE_DIR}/Tools/msg/px_generate_uorb_topic_helper.py
|
||||
COMMENT "Generating uORB compatible IDL headers"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
VERBATIM
|
||||
)
|
||||
add_dependencies(uorb_msgs uorb_idl_header)
|
||||
|
||||
# Compile all CDR compatible message defnitions
|
||||
target_link_libraries(uorb_msgs PRIVATE uorb_cdrstream )
|
||||
endif()
|
||||
|
||||
if(CONFIG_MODULES_ZENOH)
|
||||
# Update kconfig file for topics
|
||||
execute_process(COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/zenoh/px_generate_zenoh_topic_files.py
|
||||
--zenoh-config
|
||||
-f ${msg_files}
|
||||
-o ${PX4_SOURCE_DIR}/src/modules/zenoh/
|
||||
-e ${PX4_SOURCE_DIR}/Tools/zenoh/templates/zenoh
|
||||
)
|
||||
add_custom_command(
|
||||
OUTPUT
|
||||
${PX4_BINARY_DIR}/src/modules/zenoh/uorb_pubsub_factory.hpp
|
||||
COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/zenoh/px_generate_zenoh_topic_files.py
|
||||
--zenoh-pub-sub
|
||||
-f ${msg_files}
|
||||
-o ${PX4_BINARY_DIR}/src/modules/zenoh/
|
||||
-e ${PX4_SOURCE_DIR}/Tools/zenoh/templates/zenoh
|
||||
DEPENDS
|
||||
${msg_files}
|
||||
${PX4_SOURCE_DIR}/Tools/zenoh/templates/zenoh/uorb_pubsub_factory.hpp.em
|
||||
${PX4_SOURCE_DIR}/Tools/zenoh/px_generate_zenoh_topic_files.py
|
||||
COMMENT "Generating Zenoh Topic Code"
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||
VERBATIM
|
||||
)
|
||||
add_library(zenoh_topics ${PX4_BINARY_DIR}/src/modules/zenoh/uorb_pubsub_factory.hpp)
|
||||
set_target_properties(zenoh_topics PROPERTIES LINKER_LANGUAGE CXX)
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user