From d83073f016d61a6054f882ee1a56266b4bf1d963 Mon Sep 17 00:00:00 2001 From: Daniel Agar Date: Tue, 17 Oct 2017 16:29:55 -0400 Subject: [PATCH] move RTPS to dedicated px4fmu-v{3,4,4pro,5}, posix, sdflight builds (#8113) --- .gitmodules | 2 +- CMakeLists.txt | 16 --- Makefile | 20 ++- Tools/astyle/files_to_check_code_style.sh | 3 +- cmake/common/px4_git.cmake | 9 +- cmake/configs/nuttx_mindpx-v2_default.cmake | 13 +- cmake/configs/nuttx_nxphlite-v3_default.cmake | 15 +- cmake/configs/nuttx_px4fmu-v3_default.cmake | 13 +- cmake/configs/nuttx_px4fmu-v3_rtps.cmake | 5 + cmake/configs/nuttx_px4fmu-v4_default.cmake | 13 +- cmake/configs/nuttx_px4fmu-v4_rtps.cmake | 5 + .../configs/nuttx_px4fmu-v4pro_default.cmake | 13 +- cmake/configs/nuttx_px4fmu-v4pro_rtps.cmake | 5 + cmake/configs/nuttx_px4fmu-v5_default.cmake | 13 +- cmake/configs/nuttx_px4fmu-v5_rtps.cmake | 5 + cmake/configs/posix_sdflight_default.cmake | 13 +- cmake/configs/posix_sdflight_legacy.cmake | 5 +- cmake/configs/posix_sdflight_rtps.cmake | 5 + cmake/configs/posix_sitl_default.cmake | 34 +---- cmake/configs/posix_sitl_rtps.cmake | 5 + msg/CMakeLists.txt | 73 ---------- src/modules/micrortps_bridge/CMakeLists.txt | 134 ++++++++++++++++++ .../micrortps_bridge}/micro-CDR | 0 .../micrortps_client/CMakeLists.txt | 133 ++++++++--------- 24 files changed, 260 insertions(+), 292 deletions(-) create mode 100644 cmake/configs/nuttx_px4fmu-v3_rtps.cmake create mode 100644 cmake/configs/nuttx_px4fmu-v4_rtps.cmake create mode 100644 cmake/configs/nuttx_px4fmu-v4pro_rtps.cmake create mode 100644 cmake/configs/nuttx_px4fmu-v5_rtps.cmake create mode 100644 cmake/configs/posix_sdflight_rtps.cmake create mode 100644 cmake/configs/posix_sitl_rtps.cmake create mode 100644 src/modules/micrortps_bridge/CMakeLists.txt rename src/{lib => modules/micrortps_bridge}/micro-CDR (100%) diff --git a/.gitmodules b/.gitmodules index a51777e110..f229c222e9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -35,7 +35,7 @@ path = src/drivers/gps/devices url = https://github.com/PX4/GpsDrivers.git [submodule "src/lib/micro-CDR"] - path = src/lib/micro-CDR + path = src/modules/micrortps_bridge/micro-CDR url = https://github.com/eProsima/micro-CDR.git [submodule "platforms/nuttx/NuttX/nuttx"] path = platforms/nuttx/NuttX/nuttx diff --git a/CMakeLists.txt b/CMakeLists.txt index dc21806a60..e0fb889ed5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -355,22 +355,6 @@ include_directories(${include_dirs}) link_directories(${link_dirs}) add_definitions(${definitions}) -#============================================================================= -# RTPS and micro-cdr -# - -find_program(FASTRTPSGEN fastrtpsgen PATHS $ENV{FASTRTPSGEN_DIR}) -if (FASTRTPSGEN AND (config_rtps_send_topics OR config_rtps_receive_topics)) - option(GENERATE_RTPS_BRIDGE "enable RTPS and microCDR" ON) -endif() - -if (GENERATE_RTPS_BRIDGE) - # add micro-CDR - message(STATUS "RTPS bridge enabled, send: ${config_rtps_send_topics} receive: ${config_rtps_receive_topics}") - px4_add_git_submodule(TARGET git_micro_cdr PATH src/lib/micro-CDR) - add_subdirectory(src/lib/micro-CDR EXCLUDE_FROM_ALL) -endif() - #============================================================================= # message, and airframe generation # diff --git a/Makefile b/Makefile index 7a1084416c..996c7d93dc 100644 --- a/Makefile +++ b/Makefile @@ -159,21 +159,25 @@ all_nuttx_targets: $(NUTTX_CONFIG_TARGETS) posix: posix_sitl_default broadcast: posix_sitl_broadcast +# All targets with just dependencies but no recipe must either be marked as phony (or have the special @: as recipe). +.PHONY: all posix broadcast all_nuttx_targets + # Multi- config targets. eagle_default: posix_eagle_default qurt_eagle_default +eagle_rtps: posix_eagle_rtps qurt_eagle_default eagle_legacy_default: posix_eagle_legacy qurt_eagle_legacy excelsior_default: posix_excelsior_default qurt_excelsior_default +excelsior_rtps: posix_excelsior_rtps qurt_excelsior_default excelsior_legacy_default: posix_excelsior_legacy qurt_excelsior_legacy - -# All targets with just dependencies but no recipe must either be marked as phony (or have the special @: as recipe). -.PHONY: all posix broadcast eagle_default eagle_legacy_default excelsior_legacy_default excelsior_default all_nuttx_targets +.PHONY: eagle_default eagle_rtps eagle_legacy_default +.PHONY: excelsior_default excelsior_rtps excelsior_legacy_default # Other targets # -------------------------------------------------------------------- .PHONY: qgc_firmware px4fmu_firmware misc_qgc_extra_firmware alt_firmware -.PHONY: sizes check quick_check +.PHONY: sizes check quick_check check_rtps # QGroundControl flashable NuttX firmware qgc_firmware: px4fmu_firmware misc_qgc_extra_firmware sizes @@ -209,6 +213,14 @@ alt_firmware: \ check_s2740vc-v1_default \ sizes +# builds with RTPS +check_rtps: \ + check_px4fmu-v3_rtps \ + check_px4fmu-v4_rtps \ + check_px4fmu-v4pro_rtps \ + check_posix_sitl_rtps \ + sizes + sizes: @-find build -name *.elf -type f | xargs size 2> /dev/null || : diff --git a/Tools/astyle/files_to_check_code_style.sh b/Tools/astyle/files_to_check_code_style.sh index 4d03dfd0fa..1fc7daf032 100755 --- a/Tools/astyle/files_to_check_code_style.sh +++ b/Tools/astyle/files_to_check_code_style.sh @@ -14,9 +14,8 @@ exec find src \ -path src/lib/DriverFramework -prune -o \ -path src/lib/ecl -prune -o \ -path src/lib/matrix -prune -o \ - -path src/lib/micro-CDR -prune -o \ -path src/modules/commander -prune -o \ - -path src/modules/micrortps_bridge/micrortps_agent -prune -o \ + -path src/modules/micrortps_bridge/micro-CDR -prune -o \ -path src/modules/sdlog2 -prune -o \ -path src/modules/systemlib/uthash -prune -o \ -path src/modules/uavcan/libuavcan -prune -o \ diff --git a/cmake/common/px4_git.cmake b/cmake/common/px4_git.cmake index 5ffb3e65e0..b0877e2773 100644 --- a/cmake/common/px4_git.cmake +++ b/cmake/common/px4_git.cmake @@ -41,7 +41,6 @@ include(common/px4_base) # utility functions # # * px4_add_git_submodule -# * px4_create_git_hash_header # #============================================================================= @@ -71,13 +70,13 @@ function(px4_add_git_submodule) string(REPLACE "/" "_" NAME ${PATH}) - add_custom_command(OUTPUT ${PX4_BINARY_DIR}/git_init_${NAME}.stamp + add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/git_init_${NAME}.stamp COMMAND bash ${PX4_SOURCE_DIR}/Tools/check_submodules.sh ${PATH} - COMMAND cmake -E touch ${PX4_BINARY_DIR}/git_init_${NAME}.stamp + COMMAND cmake -E touch ${CMAKE_CURRENT_BINARY_DIR}/git_init_${NAME}.stamp DEPENDS ${PX4_SOURCE_DIR}/.gitmodules ${PATH}/.git - WORKING_DIRECTORY ${PX4_SOURCE_DIR} COMMENT "git submodule ${PATH}" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} ) - add_custom_target(${TARGET} DEPENDS ${PX4_BINARY_DIR}/git_init_${NAME}.stamp) + add_custom_target(${TARGET} DEPENDS git_init_${NAME}.stamp) endfunction() diff --git a/cmake/configs/nuttx_mindpx-v2_default.cmake b/cmake/configs/nuttx_mindpx-v2_default.cmake index 446a5aaa77..c354da6d2f 100644 --- a/cmake/configs/nuttx_mindpx-v2_default.cmake +++ b/cmake/configs/nuttx_mindpx-v2_default.cmake @@ -134,9 +134,6 @@ set(config_module_list modules/uORB modules/dataman - # micro RTPS - modules/micrortps_bridge/micrortps_client - # # Libraries # @@ -197,12 +194,4 @@ set(config_module_list # EKF #examples/ekf_att_pos_estimator -) - -set(config_rtps_send_topics - sensor_combined - ) - -set(config_rtps_receive_topics - sensor_baro - ) +) \ No newline at end of file diff --git a/cmake/configs/nuttx_nxphlite-v3_default.cmake b/cmake/configs/nuttx_nxphlite-v3_default.cmake index e010c843ac..8ae578e3d3 100644 --- a/cmake/configs/nuttx_nxphlite-v3_default.cmake +++ b/cmake/configs/nuttx_nxphlite-v3_default.cmake @@ -143,10 +143,6 @@ set(config_module_list modules/uORB modules/dataman - # micro RTPS - modules/micrortps_bridge/micrortps_client - - # # Libraries # @@ -214,13 +210,4 @@ set(config_module_list # EKF examples/ekf_att_pos_estimator -) - - -set(config_rtps_send_topics - sensor_combined - ) - -set(config_rtps_receive_topics - sensor_baro - ) +) \ No newline at end of file diff --git a/cmake/configs/nuttx_px4fmu-v3_default.cmake b/cmake/configs/nuttx_px4fmu-v3_default.cmake index a11d48bead..76dfee191b 100644 --- a/cmake/configs/nuttx_px4fmu-v3_default.cmake +++ b/cmake/configs/nuttx_px4fmu-v3_default.cmake @@ -138,9 +138,6 @@ set(config_module_list modules/systemlib/mixer modules/uORB - # micro RTPS - modules/micrortps_bridge/micrortps_client - # # Libraries # @@ -207,12 +204,4 @@ set(config_module_list # EKF examples/ekf_att_pos_estimator -) - -set(config_rtps_send_topics - sensor_combined - ) - -set(config_rtps_receive_topics - sensor_baro - ) +) \ No newline at end of file diff --git a/cmake/configs/nuttx_px4fmu-v3_rtps.cmake b/cmake/configs/nuttx_px4fmu-v3_rtps.cmake new file mode 100644 index 0000000000..cdbf9d449c --- /dev/null +++ b/cmake/configs/nuttx_px4fmu-v3_rtps.cmake @@ -0,0 +1,5 @@ +include(configs/nuttx_px4fmu-v3_default) + +list(APPEND config_module_list + modules/micrortps_bridge +) \ No newline at end of file diff --git a/cmake/configs/nuttx_px4fmu-v4_default.cmake b/cmake/configs/nuttx_px4fmu-v4_default.cmake index 417d17a36e..28fa0efa57 100644 --- a/cmake/configs/nuttx_px4fmu-v4_default.cmake +++ b/cmake/configs/nuttx_px4fmu-v4_default.cmake @@ -139,9 +139,6 @@ set(config_module_list modules/uORB modules/dataman - # micro RTPS - modules/micrortps_bridge/micrortps_client - # # Libraries # @@ -209,12 +206,4 @@ set(config_module_list # EKF examples/ekf_att_pos_estimator -) - -set(config_rtps_send_topics - sensor_combined - ) - -set(config_rtps_receive_topics - sensor_baro - ) +) \ No newline at end of file diff --git a/cmake/configs/nuttx_px4fmu-v4_rtps.cmake b/cmake/configs/nuttx_px4fmu-v4_rtps.cmake new file mode 100644 index 0000000000..53e7d10b19 --- /dev/null +++ b/cmake/configs/nuttx_px4fmu-v4_rtps.cmake @@ -0,0 +1,5 @@ +include(configs/nuttx_px4fmu-v4_default) + +list(APPEND config_module_list + modules/micrortps_bridge +) \ No newline at end of file diff --git a/cmake/configs/nuttx_px4fmu-v4pro_default.cmake b/cmake/configs/nuttx_px4fmu-v4pro_default.cmake index 20c54bf9ac..fc54b471c6 100644 --- a/cmake/configs/nuttx_px4fmu-v4pro_default.cmake +++ b/cmake/configs/nuttx_px4fmu-v4pro_default.cmake @@ -139,9 +139,6 @@ set(config_module_list modules/systemlib/mixer modules/uORB - # micro RTPS - modules/micrortps_bridge/micrortps_client - # # Libraries # @@ -208,12 +205,4 @@ set(config_module_list # EKF #examples/ekf_att_pos_estimator -) - -set(config_rtps_send_topics - sensor_combined - ) - -set(config_rtps_receive_topics - sensor_baro - ) +) \ No newline at end of file diff --git a/cmake/configs/nuttx_px4fmu-v4pro_rtps.cmake b/cmake/configs/nuttx_px4fmu-v4pro_rtps.cmake new file mode 100644 index 0000000000..1b8c648b03 --- /dev/null +++ b/cmake/configs/nuttx_px4fmu-v4pro_rtps.cmake @@ -0,0 +1,5 @@ +include(configs/nuttx_px4fmu-v4pro_default) + +list(APPEND config_module_list + modules/micrortps_bridge +) \ No newline at end of file diff --git a/cmake/configs/nuttx_px4fmu-v5_default.cmake b/cmake/configs/nuttx_px4fmu-v5_default.cmake index f26c3192a2..f6f70824f2 100644 --- a/cmake/configs/nuttx_px4fmu-v5_default.cmake +++ b/cmake/configs/nuttx_px4fmu-v5_default.cmake @@ -139,9 +139,6 @@ set(config_module_list modules/systemlib/mixer modules/uORB - # micro RTPS - modules/micrortps_bridge/micrortps_client - # # Libraries # @@ -209,12 +206,4 @@ set(config_module_list # EKF #examples/ekf_att_pos_estimator -) - -set(config_rtps_send_topics - sensor_combined - ) - -set(config_rtps_receive_topics - sensor_baro - ) +) \ No newline at end of file diff --git a/cmake/configs/nuttx_px4fmu-v5_rtps.cmake b/cmake/configs/nuttx_px4fmu-v5_rtps.cmake new file mode 100644 index 0000000000..53e7d10b19 --- /dev/null +++ b/cmake/configs/nuttx_px4fmu-v5_rtps.cmake @@ -0,0 +1,5 @@ +include(configs/nuttx_px4fmu-v4_default) + +list(APPEND config_module_list + modules/micrortps_bridge +) \ No newline at end of file diff --git a/cmake/configs/posix_sdflight_default.cmake b/cmake/configs/posix_sdflight_default.cmake index edb9a72f61..3389938414 100644 --- a/cmake/configs/posix_sdflight_default.cmake +++ b/cmake/configs/posix_sdflight_default.cmake @@ -66,9 +66,6 @@ set(config_module_list modules/commander modules/navigator - # micro RTPS - modules/micrortps_bridge/micrortps_client - lib/controllib lib/mathlib lib/mathlib/math/filter @@ -86,12 +83,4 @@ set(config_module_list platforms/common platforms/posix/px4_layer platforms/posix/work_queue - ) - -set(config_rtps_send_topics - sensor_baro - ) - -set(config_rtps_receive_topics - sensor_combined - ) + ) \ No newline at end of file diff --git a/cmake/configs/posix_sdflight_legacy.cmake b/cmake/configs/posix_sdflight_legacy.cmake index 9770066464..f13018c5dc 100644 --- a/cmake/configs/posix_sdflight_legacy.cmake +++ b/cmake/configs/posix_sdflight_legacy.cmake @@ -58,9 +58,6 @@ set(config_module_list modules/commander modules/navigator - # micro RTPS - modules/micrortps_bridge/micrortps_client - lib/controllib lib/mathlib lib/mathlib/math/filter @@ -78,4 +75,4 @@ set(config_module_list platforms/common platforms/posix/px4_layer platforms/posix/work_queue - ) + ) \ No newline at end of file diff --git a/cmake/configs/posix_sdflight_rtps.cmake b/cmake/configs/posix_sdflight_rtps.cmake new file mode 100644 index 0000000000..481cb02b39 --- /dev/null +++ b/cmake/configs/posix_sdflight_rtps.cmake @@ -0,0 +1,5 @@ +include(configs/posix_sdflight_default) + +list(APPEND config_module_list + modules/micrortps_bridge +) \ No newline at end of file diff --git a/cmake/configs/posix_sitl_default.cmake b/cmake/configs/posix_sitl_default.cmake index 8eff874d92..c9836ab8e7 100644 --- a/cmake/configs/posix_sitl_default.cmake +++ b/cmake/configs/posix_sitl_default.cmake @@ -114,9 +114,6 @@ set(config_module_list modules/systemlib/mixer modules/uORB - # micro RTPS - modules/micrortps_bridge/micrortps_client - # # Libraries # @@ -189,39 +186,18 @@ set(config_module_list # EKF examples/ekf_att_pos_estimator - - # micro-RTPS ) -set(config_rtps_send_topics - sensor_baro - ) - -set(config_rtps_receive_topics - sensor_combined - ) - # Default config_sitl_rcS_dir (posix_sitl_default), this is overwritten later # for the config posix_sitl_efk2 and set again, explicitly, for posix_sitl_lpe, # which are based on posix_sitl_default. -set(config_sitl_rcS_dir - posix-configs/SITL/init/ekf2 - CACHE INTERNAL "init script dir for sitl" - ) +set(config_sitl_rcS_dir posix-configs/SITL/init/ekf2 CACHE INTERNAL "init script dir for sitl") -set(config_sitl_viewer - jmavsim - CACHE STRING "viewer for sitl" - ) -set_property(CACHE config_sitl_viewer - PROPERTY STRINGS "jmavsim;none") +set(config_sitl_viewer jmavsim CACHE STRING "viewer for sitl") +set_property(CACHE config_sitl_viewer PROPERTY STRINGS "jmavsim;none") -set(config_sitl_debugger - disable - CACHE STRING "debugger for sitl" - ) -set_property(CACHE config_sitl_debugger - PROPERTY STRINGS "disable;gdb;lldb") +set(config_sitl_debugger disable CACHE STRING "debugger for sitl") +set_property(CACHE config_sitl_debugger PROPERTY STRINGS "disable;gdb;lldb") # If the environment variable 'replay' is defined, we are building with replay # support. In this case, we enable the orb publisher rules. diff --git a/cmake/configs/posix_sitl_rtps.cmake b/cmake/configs/posix_sitl_rtps.cmake new file mode 100644 index 0000000000..e5f793f794 --- /dev/null +++ b/cmake/configs/posix_sitl_rtps.cmake @@ -0,0 +1,5 @@ +include(configs/posix_sitl_default) + +list(APPEND config_module_list + modules/micrortps_bridge +) \ No newline at end of file diff --git a/msg/CMakeLists.txt b/msg/CMakeLists.txt index 9b0181d391..b9b44f06a0 100644 --- a/msg/CMakeLists.txt +++ b/msg/CMakeLists.txt @@ -177,76 +177,3 @@ add_custom_command(OUTPUT ${uorb_sources} px4_add_library(uorb_msgs ${uorb_sources}) add_dependencies(uorb_msgs uorb_headers) - -############################################################################### -# micro-cdr serialization -############################################################################### -# if RTPS is enabled generate serialization code for each uORB message -if (GENERATE_RTPS_BRIDGE) - - set(msg_out_path_microcdr ${PX4_BINARY_DIR}/uORB_microcdr/topics) - set(msg_source_out_path_microcdr ${CMAKE_CURRENT_BINARY_DIR}/topics_microcdr_sources) - - set(uorb_headers_microcdr) - set(uorb_sources_microcdr) - - # send topic files - set(send_topic_files) - foreach(topic ${config_rtps_send_topics}) - list(APPEND send_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg) - list(APPEND uorb_headers_microcdr ${msg_out_path_microcdr}/${topic}.h) - list(APPEND uorb_sources_microcdr ${msg_source_out_path_microcdr}/${topic}.cpp) - endforeach() - - # receive topic files - set(receive_topic_files) - foreach(topic ${config_rtps_receive_topics}) - list(APPEND receive_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg) - list(APPEND uorb_headers_microcdr ${msg_out_path_microcdr}/${topic}.h) - list(APPEND uorb_sources_microcdr ${msg_source_out_path_microcdr}/${topic}.cpp) - endforeach() - - list(REMOVE_DUPLICATES uorb_headers_microcdr) - list(REMOVE_DUPLICATES uorb_sources_microcdr) - - # Generate uORB serialization headers - add_custom_command(OUTPUT ${uorb_headers_microcdr} - COMMAND ${PYTHON_EXECUTABLE} tools/px_generate_uorb_topic_files.py - --headers - -f ${send_topic_files} ${receive_topic_files} - -i ${CMAKE_CURRENT_SOURCE_DIR} - -o ${msg_out_path_microcdr} - -e templates/uorb_microcdr - -t ${CMAKE_CURRENT_BINARY_DIR}/tmp/headers_microcdr - -q - DEPENDS ${msg_files} - COMMENT "Generating uORB microcdr topic headers" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - VERBATIM - ) - add_custom_target(uorb_headers_microcdr DEPENDS ${uorb_headers_microcdr}) - - # Generate uORB serialization sources - add_custom_command(OUTPUT ${uorb_sources_microcdr} - COMMAND ${PYTHON_EXECUTABLE} tools/px_generate_uorb_topic_files.py - --sources - -f ${send_topic_files} ${receive_topic_files} - -i ${CMAKE_CURRENT_SOURCE_DIR} - -o ${msg_source_out_path_microcdr} - -e templates/uorb_microcdr - -t ${CMAKE_CURRENT_BINARY_DIR}/tmp/sources_microcdr - -q - DEPENDS ${msg_files} - COMMENT "Generating uORB microcdr topic sources" - WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - VERBATIM - ) - px4_add_library(uorb_msgs_microcdr ${uorb_sources_microcdr}) - add_dependencies(uorb_msgs_microcdr uorb_headers_microcdr uorb_headers) - - # microCDR - target_include_directories(uorb_msgs_microcdr - PRIVATE ${PX4_SOURCE_DIR}/src/lib/micro-CDR/include - PRIVATE ${PX4_BINARY_DIR}/src/lib/micro-CDR/include/microcdr - ) -endif() diff --git a/src/modules/micrortps_bridge/CMakeLists.txt b/src/modules/micrortps_bridge/CMakeLists.txt new file mode 100644 index 0000000000..9966ffe518 --- /dev/null +++ b/src/modules/micrortps_bridge/CMakeLists.txt @@ -0,0 +1,134 @@ +############################################################################ +# +# Copyright (c) 2017 PX4 Development Team. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name PX4 nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +#============================================================================= +# RTPS and micro-cdr +# + +find_program(FASTRTPSGEN fastrtpsgen PATHS $ENV{FASTRTPSGEN_DIR}) +if(NOT FASTRTPSGEN) + message(FATAL_ERROR "Unable to find fastrtpsgen") +endif() + +set(config_rtps_send_topics + sensor_combined + ) + +set(config_rtps_receive_topics + sensor_baro + ) + +if (FASTRTPSGEN AND (config_rtps_send_topics OR config_rtps_receive_topics)) + option(GENERATE_RTPS_BRIDGE "enable RTPS and microCDR" ON) +endif() + +if (GENERATE_RTPS_BRIDGE) + + add_subdirectory(micrortps_client) + + ############################################################################### + # micro-cdr serialization + ############################################################################### + include(common/px4_git) + px4_add_git_submodule(TARGET git_micro_cdr PATH micro-CDR) + add_subdirectory(micro-CDR) + + set(msg_out_path_microcdr ${PX4_BINARY_DIR}/uORB_microcdr/topics) + set(msg_source_out_path_microcdr ${CMAKE_CURRENT_BINARY_DIR}/topics_microcdr_sources) + + set(uorb_headers_microcdr) + set(uorb_sources_microcdr) + + # send topic files + set(send_topic_files) + foreach(topic ${config_rtps_send_topics}) + list(APPEND send_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg) + list(APPEND uorb_headers_microcdr ${msg_out_path_microcdr}/${topic}.h) + list(APPEND uorb_sources_microcdr ${msg_source_out_path_microcdr}/${topic}.cpp) + endforeach() + + # receive topic files + set(receive_topic_files) + foreach(topic ${config_rtps_receive_topics}) + list(APPEND receive_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg) + list(APPEND uorb_headers_microcdr ${msg_out_path_microcdr}/${topic}.h) + list(APPEND uorb_sources_microcdr ${msg_source_out_path_microcdr}/${topic}.cpp) + endforeach() + + list(REMOVE_DUPLICATES uorb_headers_microcdr) + list(REMOVE_DUPLICATES uorb_sources_microcdr) + + # Generate uORB serialization headers + add_custom_command(OUTPUT ${uorb_headers_microcdr} + COMMAND ${PYTHON_EXECUTABLE} tools/px_generate_uorb_topic_files.py + --headers + -f ${send_topic_files} ${receive_topic_files} + -i . + -o ${msg_out_path_microcdr} + -e templates/uorb_microcdr + -t ${CMAKE_CURRENT_BINARY_DIR}/tmp/headers_microcdr + -q + DEPENDS ${msg_files} + COMMENT "Generating uORB microcdr topic headers" + WORKING_DIRECTORY ${PX4_SOURCE_DIR}/msg/ + VERBATIM + ) + add_custom_target(uorb_headers_microcdr DEPENDS ${uorb_headers_microcdr}) + + # Generate uORB serialization sources + add_custom_command(OUTPUT ${uorb_sources_microcdr} + COMMAND ${PYTHON_EXECUTABLE} tools/px_generate_uorb_topic_files.py + --sources + -f ${send_topic_files} ${receive_topic_files} + -i . + -o ${msg_source_out_path_microcdr} + -e templates/uorb_microcdr + -t ${CMAKE_CURRENT_BINARY_DIR}/tmp/sources_microcdr + -q + DEPENDS ${msg_files} + COMMENT "Generating uORB microcdr topic sources" + WORKING_DIRECTORY ${PX4_SOURCE_DIR}/msg/ + VERBATIM + ) + px4_add_library(uorb_msgs_microcdr ${uorb_sources_microcdr}) + add_dependencies(uorb_msgs_microcdr uorb_headers_microcdr uorb_headers git_micro_cdr lib__micro-CDR) + + target_link_libraries(uorb_msgs_microcdr PRIVATE lib__micro-CDR) + + # microCDR + target_include_directories(uorb_msgs_microcdr + PUBLIC + ${CMAKE_CURRENT_SOURCE_DIR}/micro-CDR/include + ${CMAKE_CURRENT_BINARY_DIR}/micro-CDR/include/microcdr + ) +endif() diff --git a/src/lib/micro-CDR b/src/modules/micrortps_bridge/micro-CDR similarity index 100% rename from src/lib/micro-CDR rename to src/modules/micrortps_bridge/micro-CDR diff --git a/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt b/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt index 1aaaaa4ac1..49400bff26 100644 --- a/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt +++ b/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt @@ -31,86 +31,75 @@ # ############################################################################ -if(GENERATE_RTPS_BRIDGE) +set(msg_out_path ${CMAKE_CURRENT_BINARY_DIR}) - find_program(FASTRTPSGEN fastrtpsgen PATHS $ENV{FASTRTPSGEN_DIR}) - if(NOT FASTRTPSGEN) - message(STATUS "WARNING: Unable to find fastrtpsgen. Building PX4 without RTPS bridge support") +if (NOT "${config_rtps_send_topics}" STREQUAL "" OR NOT "${config_rtps_receive_topics}" STREQUAL "") - return() + set(send_topic_files) + foreach(topic ${config_rtps_send_topics}) + list(APPEND send_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg) + endforeach() + + set(receive_topic_files) + foreach(topic ${config_rtps_receive_topics}) + list(APPEND receive_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg) + endforeach() + + foreach(topic ${config_rtps_send_topics}) + list(APPEND topic_bridge_files_out ${msg_out_path}/micrortps_agent/${topic}_Publisher.cpp) + list(APPEND topic_bridge_files_out ${msg_out_path}/micrortps_agent/${topic}_Publisher.h) + endforeach() + + foreach(topic ${config_rtps_receive_topics}) + list(APPEND topic_bridge_files_out ${msg_out_path}/micrortps_agent/${topic}_Subscriber.cpp) + list(APPEND topic_bridge_files_out ${msg_out_path}/micrortps_agent/${topic}_Subscriber.h) + endforeach() + + set(send_topic_files_opt) + if (NOT "${send_topic_files}" STREQUAL "") + set(send_topic_opt "--send") endif() - # Do not delete everything in the current dir - set(msg_out_path ${CMAKE_CURRENT_BINARY_DIR}) + set(receive_topic_files_opt) + if (NOT "${receive_topic_files}" STREQUAL "") + set(receive_topic_opt "--receive") + endif() - if (NOT "${config_rtps_send_topics}" STREQUAL "" OR NOT "${config_rtps_receive_topics}" STREQUAL "") + list(APPEND topic_bridge_files_out + ${msg_out_path}/micrortps_client/microRTPS_client.cpp + ${msg_out_path}/micrortps_client/microRTPS_transport.cpp + ${msg_out_path}/micrortps_client/microRTPS_transport.h + ) - set(send_topic_files) - foreach(topic ${config_rtps_send_topics}) - list(APPEND send_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg) - endforeach() + add_custom_command(OUTPUT ${topic_bridge_files_out} + COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/msg/tools/generate_microRTPS_bridge.py + --fastrtpsgen-dir $ENV{FASTRTPSGEN_DIR} + ${send_topic_opt} ${send_topic_files} + ${receive_topic_opt} ${receive_topic_files} + --topic-msg-dir ${PX4_SOURCE_DIR}/msg + --agent-outdir ${CMAKE_CURRENT_BINARY_DIR}/micrortps_agent + --client-outdir ${CMAKE_CURRENT_BINARY_DIR}/micrortps_client + >micrortps_bridge.log 2>&1 || cat micrortps_bridge.log # quiet successful build output + DEPENDS ${send_topic_files} ${receive_topic_files} + COMMENT "Generating RTPS topic bridge" + ) + add_custom_target(topic_bridge_files DEPENDS ${topic_bridge_files_out}) - set(receive_topic_files) - foreach(topic ${config_rtps_receive_topics}) - list(APPEND receive_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg) - endforeach() + include_directories(${CMAKE_CURRENT_SOURCE_DIR}) + include_directories(${CMAKE_CURRENT_BINARY_DIR}/micrortps_client) - foreach(topic ${config_rtps_send_topics}) - list(APPEND topic_bridge_files_out ${msg_out_path}/micrortps_agent/${topic}_Publisher.cpp) - list(APPEND topic_bridge_files_out ${msg_out_path}/micrortps_agent/${topic}_Publisher.h) - endforeach() - - foreach(topic ${config_rtps_receive_topics}) - list(APPEND topic_bridge_files_out ${msg_out_path}/micrortps_agent/${topic}_Subscriber.cpp) - list(APPEND topic_bridge_files_out ${msg_out_path}/micrortps_agent/${topic}_Subscriber.h) - endforeach() - - set(send_topic_files_opt) - if (NOT "${send_topic_files}" STREQUAL "") - set(send_topic_opt "--send") - endif() - - set(receive_topic_files_opt) - if (NOT "${receive_topic_files}" STREQUAL "") - set(receive_topic_opt "--receive") - endif() - - list(APPEND topic_bridge_files_out + px4_add_module( + MODULE modules__micrortps_bridge__micrortps_client + MAIN micrortps_client + STACK_MAIN 4096 + SRCS + microRTPS_client_main.cpp ${msg_out_path}/micrortps_client/microRTPS_client.cpp ${msg_out_path}/micrortps_client/microRTPS_transport.cpp - ${msg_out_path}/micrortps_client/microRTPS_transport.h - ) - - add_custom_command(OUTPUT ${topic_bridge_files_out} - COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/msg/tools/generate_microRTPS_bridge.py - --fastrtpsgen-dir $ENV{FASTRTPSGEN_DIR} - ${send_topic_opt} ${send_topic_files} - ${receive_topic_opt} ${receive_topic_files} - --topic-msg-dir ${PX4_SOURCE_DIR}/msg - --agent-outdir ${CMAKE_CURRENT_BINARY_DIR}/micrortps_agent - --client-outdir ${CMAKE_CURRENT_BINARY_DIR}/micrortps_client - >micrortps_bridge.log 2>&1 || cat micrortps_bridge.log # quiet successful build output - DEPENDS ${send_topic_files} ${receive_topic_files} - COMMENT "Generating RTPS topic bridge" - ) - add_custom_target(topic_bridge_files DEPENDS ${topic_bridge_files_out}) - - include_directories(${CMAKE_CURRENT_SOURCE_DIR}) - include_directories(${CMAKE_CURRENT_BINARY_DIR}/micrortps_client) - - px4_add_module( - MODULE modules__micrortps_bridge__micrortps_client - MAIN micrortps_client - STACK_MAIN 4096 - SRCS - microRTPS_client_main.cpp - ${msg_out_path}/micrortps_client/microRTPS_client.cpp - ${msg_out_path}/micrortps_client/microRTPS_transport.cpp - DEPENDS - platforms__common - topic_bridge_files - uorb_headers_microcdr - ) - target_link_libraries(modules__micrortps_bridge__micrortps_client PRIVATE lib__micro-CDR) - endif() + DEPENDS + platforms__common + topic_bridge_files + uorb_headers_microcdr + ) + target_link_libraries(modules__micrortps_bridge__micrortps_client PRIVATE uorb_msgs_microcdr) endif() \ No newline at end of file