diff --git a/.gitignore b/.gitignore index f99223db53..dae302ec51 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,3 @@ -*.d -!ROMFS/*/*.d -!ROMFS/*/*/*.d -!ROMFS/*/*/*/*.d -*.px4log *.dSYM *.o *.gch @@ -17,8 +12,6 @@ .settings .swp .~lock.* -Archives/* -Build/* Testing/ Packages/* s3deploy-branch/ @@ -62,13 +55,6 @@ GTAGS *.creator.user *.files *.includes -src/modules/micrortps_bridge/micrortps_agent/ -src/modules/micrortps_bridge/micrortps_listener/ - -# uavcan firmware -ROMFS/px4fmu_common/uavcan/ -vectorcontrol/ - # CLion ignores .idea diff --git a/.gitmodules b/.gitmodules index fef3e7ed69..a51777e110 100644 --- a/.gitmodules +++ b/.gitmodules @@ -8,10 +8,10 @@ path = src/modules/uavcan/libuavcan url = https://github.com/UAVCAN/libuavcan.git [submodule "Tools/genmsg"] - path = Tools/genmsg + path = msg/tools/genmsg url = https://github.com/ros/genmsg.git [submodule "Tools/gencpp"] - path = Tools/gencpp + path = msg/tools/gencpp url = https://github.com/ros/gencpp.git [submodule "Tools/jMAVSim"] path = Tools/jMAVSim diff --git a/CMakeLists.txt b/CMakeLists.txt index 5acead0d32..8d5ab7cea4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -192,8 +192,6 @@ px4_add_git_submodule(TARGET git_ecl PATH "src/lib/ecl") px4_add_git_submodule(TARGET git_gazebo PATH "Tools/sitl_gazebo") px4_add_git_submodule(TARGET git_gazebo_flow PATH "Tools/sitl_gazebo/external/OpticalFlow") px4_add_git_submodule(TARGET git_gazebo_klt PATH "Tools/sitl_gazebo/external/OpticalFlow/external/klt_feature_tracker") -px4_add_git_submodule(TARGET git_gencpp PATH "Tools/gencpp") -px4_add_git_submodule(TARGET git_genmsg PATH "Tools/genmsg") px4_add_git_submodule(TARGET git_gps_devices PATH "src/drivers/gps/devices") px4_add_git_submodule(TARGET git_jmavsim PATH "Tools/jMAVSim") px4_add_git_submodule(TARGET git_matrix PATH "src/lib/matrix") @@ -361,16 +359,9 @@ add_definitions(${definitions}) #============================================================================= # message, and airframe generation # - include(common/px4_metadata) add_subdirectory(msg) -px4_generate_messages(TARGET msg_gen - MSG_FILES ${msg_files} - OS ${OS} - INCLUDES ${msg_include_paths} - DEPENDS prebuild_targets - ) px4_generate_airframes_xml(BOARD ${BOARD}) diff --git a/cmake/common/px4_metadata.cmake b/cmake/common/px4_metadata.cmake index 3ab3b8f097..9971204e54 100644 --- a/cmake/common/px4_metadata.cmake +++ b/cmake/common/px4_metadata.cmake @@ -37,135 +37,9 @@ # # utility functions # -# * px4_generate_messages # * px4_generate_airframes_xml # -#============================================================================= -# -# px4_generate_messages -# -# This function generates source code from ROS msg definitions. -# -# Usage: -# px4_generate_messages(TARGET MSGS ) -# -# Input: -# MSG_FILES : the ROS msgs to generate files from -# OS : the operating system selected -# DEPENDS : dependencies -# -# Output: -# TARGET : the message generation target -# -# Example: -# px4_generate_messages(TARGET -# MSG_FILES OS -# [ DEPENDS ] -# ) -# -function(px4_generate_messages) - px4_parse_function_args( - NAME px4_generate_messages - OPTIONS VERBOSE - ONE_VALUE OS TARGET - MULTI_VALUE MSG_FILES DEPENDS INCLUDES - REQUIRED MSG_FILES OS TARGET - ARGN ${ARGN}) - - set(QUIET) - if (NOT VERBOSE) - set(QUIET "-q") - endif() - - # headers - set(msg_out_path ${PX4_BINARY_DIR}/src/modules/uORB/topics) - set(msg_list) - foreach(msg_file ${MSG_FILES}) - get_filename_component(msg ${msg_file} NAME_WE) - list(APPEND msg_list ${msg}) - endforeach() - - set(msg_files_out) - foreach(msg ${msg_list}) - list(APPEND msg_files_out ${msg_out_path}/${msg}.h) - endforeach() - - add_custom_command(OUTPUT ${msg_files_out} - COMMAND ${PYTHON_EXECUTABLE} - Tools/px_generate_uorb_topic_files.py - --headers - ${QUIET} - -f ${MSG_FILES} - -i ${INCLUDES} - -o ${msg_out_path} - -e msg/templates/uorb - -t ${PX4_BINARY_DIR}/topics_temporary_header - DEPENDS ${DEPENDS} ${MSG_FILES} - WORKING_DIRECTORY ${PX4_SOURCE_DIR} - COMMENT "Generating uORB topic headers" - VERBATIM - ) - - # !sources - set(msg_source_out_path ${PX4_BINARY_DIR}/topics_sources) - set(msg_source_files_out ${msg_source_out_path}/uORBTopics.cpp) - foreach(msg ${msg_list}) - list(APPEND msg_source_files_out ${msg_source_out_path}/${msg}.cpp) - endforeach() - add_custom_command(OUTPUT ${msg_source_files_out} - COMMAND ${PYTHON_EXECUTABLE} - Tools/px_generate_uorb_topic_files.py - --sources - ${QUIET} - -f ${MSG_FILES} - -i ${INCLUDES} - -o ${msg_source_out_path} - -e msg/templates/uorb - -t ${PX4_BINARY_DIR}/topics_temporary_sources - DEPENDS ${DEPENDS} ${MSG_FILES} - WORKING_DIRECTORY ${PX4_SOURCE_DIR} - COMMENT "Generating uORB topic sources" - VERBATIM - ) - set_source_files_properties(${msg_source_files_out} PROPERTIES GENERATED TRUE) - - # multi messages for target OS - set(msg_multi_out_path ${PX4_BINARY_DIR}/src/platforms/${OS}/px4_messages) - set(msg_multi_files_out) - foreach(msg ${msg_list}) - list(APPEND msg_multi_files_out ${msg_multi_out_path}/px4_${msg}.h) - endforeach() - add_custom_command(OUTPUT ${msg_multi_files_out} - COMMAND ${PYTHON_EXECUTABLE} - Tools/px_generate_uorb_topic_files.py - --headers - ${QUIET} - -f ${MSG_FILES} - -i ${INCLUDES} - -o ${msg_multi_out_path} - -e msg/templates/px4/uorb - -t ${PX4_BINARY_DIR}/multi_topics_temporary/${OS} - -p "px4_" - DEPENDS ${DEPENDS} ${MSG_FILES} - WORKING_DIRECTORY ${PX4_SOURCE_DIR} - COMMENT "Generating uORB topic multi headers for ${OS}" - VERBATIM - ) - - px4_add_library(${TARGET} - ${msg_source_files_out} - ${msg_multi_files_out} - ${msg_files_out} - ) - - target_include_directories(${TARGET} - PRIVATE ${PX4_SOURCE_DIR}/src/lib/micro-CDR/include - PRIVATE ${PX4_BINARY_DIR}/src/lib/micro-CDR/include/microcdr - ) - target_link_libraries(${TARGET} PRIVATE lib__micro-CDR) -endfunction() - #============================================================================= # # px4_generate_airframes_xml diff --git a/cmake/configs/posix_sitl_default.cmake b/cmake/configs/posix_sitl_default.cmake index 4bba97fa05..8fbbaec0d8 100644 --- a/cmake/configs/posix_sitl_default.cmake +++ b/cmake/configs/posix_sitl_default.cmake @@ -114,8 +114,8 @@ set(config_module_list modules/systemlib/mixer modules/uORB - # micro RTPS - modules/micrortps_bridge/micrortps_client + # micro RTPS + modules/micrortps_bridge/micrortps_client # # Libraries @@ -231,4 +231,3 @@ if(REPLAY_FILE) message("Building with uorb publisher rules support") add_definitions(-DORB_USE_PUBLISHER_RULES) endif() - diff --git a/eclipse.cproject b/eclipse.cproject index 0c5182db61..5f15f538f4 100644 --- a/eclipse.cproject +++ b/eclipse.cproject @@ -32,7 +32,6 @@ - @@ -54,7 +53,6 @@ - @@ -83,7 +81,6 @@ - diff --git a/eclipse.project b/eclipse.project index 1cfbea66fc..383d0487b8 100644 --- a/eclipse.project +++ b/eclipse.project @@ -59,11 +59,11 @@ uORB_LOC - $%7BPROJECT_LOC%7D/build/posix_sitl_default/src/modules/uORB + $%7BPROJECT_LOC%7D/build/posix_sitl_default/uORB uORB_SRC - $%7BPROJECT_LOC%7D/build/posix_sitl_default/topics_sources + $%7BPROJECT_LOC%7D/build/posix_sitl_default/msg/topics_sources diff --git a/msg/CMakeLists.txt b/msg/CMakeLists.txt index 40a34dd8b5..5e2b2166a7 100644 --- a/msg/CMakeLists.txt +++ b/msg/CMakeLists.txt @@ -31,7 +31,7 @@ # ############################################################################ -set(msg_file_names +set(msg_files actuator_armed.msg actuator_controls.msg actuator_direct.msg @@ -127,17 +127,63 @@ set(msg_file_names wind_estimate.msg ) -# Get absolute paths -set(msg_files) -set(msg_include_paths) +px4_add_git_submodule(TARGET git_gencpp PATH "Tools/gencpp") +px4_add_git_submodule(TARGET git_genmsg PATH "Tools/genmsg") -foreach(msg_file ${msg_file_names}) - list(APPEND msg_files ${CMAKE_CURRENT_SOURCE_DIR}/${msg_file}) +# headers +set(msg_out_path ${PX4_BINARY_DIR}/uORB/topics) +set(msg_source_out_path ${CMAKE_CURRENT_BINARY_DIR}/topics_sources) +#set(msg_source_files_out ${CMAKE_CURRENT_BINARY_DIR}/uORBTopics.cpp) + +set(msg_list) +set(uorb_headers) +set(uorb_sources ${msg_source_out_path}/uORBTopics.cpp) +foreach(msg_file ${msg_files}) + get_filename_component(msg ${msg_file} NAME_WE) + list(APPEND msg_list ${msg}) + list(APPEND uorb_headers ${msg_out_path}/${msg}.h) + list(APPEND uorb_sources ${msg_source_out_path}/${msg}.cpp) endforeach() -list(APPEND msg_include_paths ${CMAKE_CURRENT_SOURCE_DIR}) -set(msg_include_paths ${msg_include_paths} PARENT_SCOPE) +# Generate uORB headers +add_custom_command(OUTPUT ${uorb_headers} + COMMAND ${PYTHON_EXECUTABLE} tools/px_generate_uorb_topic_files.py + --headers + -f ${msg_files} + -i ${CMAKE_CURRENT_SOURCE_DIR} + -o ${msg_out_path} + -e templates/uorb + -t ${CMAKE_CURRENT_BINARY_DIR}/tmp/headers + -q + DEPENDS ${msg_files} + COMMENT "Generating uORB topic headers" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + VERBATIM + ) +add_custom_target(uorb_headers DEPENDS ${uorb_headers}) -set(msg_files ${msg_files} PARENT_SCOPE) +# Generate uORB sources +add_custom_command(OUTPUT ${uorb_sources} + COMMAND ${PYTHON_EXECUTABLE} tools/px_generate_uorb_topic_files.py + --sources + -f ${msg_files} + -i ${CMAKE_CURRENT_SOURCE_DIR} + -o ${msg_source_out_path} + -e templates/uorb + -t ${CMAKE_CURRENT_BINARY_DIR}/tmp/sources + -q + DEPENDS ${msg_files} + COMMENT "Generating uORB topic sources" + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + VERBATIM + ) -# vim: set noet ft=cmake fenc=utf-8 ff=unix : +add_library(uorb_msgs STATIC EXCLUDE_FROM_ALL ${uorb_sources}) +add_dependencies(uorb_msgs uorb_headers prebuild_targets) + +# microCDR now part of uORB +target_include_directories(uorb_msgs + PRIVATE ${PX4_SOURCE_DIR}/src/lib/micro-CDR/include + PRIVATE ${PX4_BINARY_DIR}/src/lib/micro-CDR/include/microcdr + ) +target_link_libraries(uorb_msgs PRIVATE lib__micro-CDR) diff --git a/msg/templates/uorb/msg.cpp.template b/msg/templates/uorb/msg.cpp.template index 23cef4574b..5c3523c44a 100644 --- a/msg/templates/uorb/msg.cpp.template +++ b/msg/templates/uorb/msg.cpp.template @@ -74,8 +74,7 @@ topic_fields = ["uint64_t timestamp"]+["%s %s" % (convert_type(field.type), fiel constexpr char __orb_@(topic_name)_fields[] = "@( ";".join(topic_fields) );"; @[for multi_topic in topics]@ -ORB_DEFINE(@multi_topic, struct @uorb_struct, @(struct_size-padding_end_size), - __orb_@(topic_name)_fields); +ORB_DEFINE(@multi_topic, struct @uorb_struct, @(struct_size-padding_end_size), __orb_@(topic_name)_fields); @[end for] @################################################# diff --git a/Tools/gencpp b/msg/tools/gencpp similarity index 100% rename from Tools/gencpp rename to msg/tools/gencpp diff --git a/Tools/generate_microRTPS_bridge.py b/msg/tools/generate_microRTPS_bridge.py similarity index 99% rename from Tools/generate_microRTPS_bridge.py rename to msg/tools/generate_microRTPS_bridge.py index 6cdb3af4e9..fbff244b82 100644 --- a/Tools/generate_microRTPS_bridge.py +++ b/msg/tools/generate_microRTPS_bridge.py @@ -40,7 +40,7 @@ import sys, os, argparse, shutil import px_generate_uorb_topic_files import subprocess, glob -import errno +import errno def get_absolute_path(arg_parse_dir): root_path = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) diff --git a/Tools/genmsg b/msg/tools/genmsg similarity index 100% rename from Tools/genmsg rename to msg/tools/genmsg diff --git a/Tools/px_generate_uorb_topic_files.py b/msg/tools/px_generate_uorb_topic_files.py similarity index 99% rename from Tools/px_generate_uorb_topic_files.py rename to msg/tools/px_generate_uorb_topic_files.py index 4a6e22bd29..a519431f60 100755 --- a/Tools/px_generate_uorb_topic_files.py +++ b/msg/tools/px_generate_uorb_topic_files.py @@ -47,7 +47,7 @@ import sys px4_tools_dir = os.path.dirname(os.path.abspath(__file__)) sys.path.append(px4_tools_dir + "/genmsg/src") sys.path.append(px4_tools_dir + "/gencpp/src") -px4_msg_dir = os.path.join(px4_tools_dir,"../msg") +px4_msg_dir = os.path.join(px4_tools_dir, "..") try: import em diff --git a/Tools/px_generate_uorb_topic_helper.py b/msg/tools/px_generate_uorb_topic_helper.py similarity index 100% rename from Tools/px_generate_uorb_topic_helper.py rename to msg/tools/px_generate_uorb_topic_helper.py diff --git a/Tools/uorb_rtps_message_ids.py b/msg/tools/uorb_rtps_message_ids.py similarity index 100% rename from Tools/uorb_rtps_message_ids.py rename to msg/tools/uorb_rtps_message_ids.py diff --git a/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt b/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt index 9091f79318..8b0e1db119 100644 --- a/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt +++ b/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt @@ -47,73 +47,77 @@ if(NOT GENERATE_RTPS_BRIDGE MATCHES "off") return() endif() - include_directories(.) - include_directories(${CMAKE_CURRENT_BINARY_DIR}) - include_directories(${PX4_SOURCE_DIR}/src/lib/micro-CDR/include) - include_directories(${PX4_BINARY_DIR}/src/lib/micro-CDR/include/microcdr) - # Do not delete everything in the current dir set(msg_out_path ${CMAKE_CURRENT_BINARY_DIR}) - set(topic_msg_path ${PX4_SOURCE_DIR}/msg) - set(send_topic_files) - foreach(topic ${config_rtps_send_topics}) - list(APPEND send_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg) - endforeach() + if (NOT "${config_rtps_send_topics}" STREQUAL "" OR NOT "${config_rtps_receive_topics}" STREQUAL "") - set(receive_topic_files) - foreach(topic ${config_rtps_receive_topics}) - list(APPEND receive_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg) - endforeach() + set(send_topic_files) + foreach(topic ${config_rtps_send_topics}) + list(APPEND send_topic_files ${PX4_SOURCE_DIR}/msg/${topic}.msg) + endforeach() - foreach(topic ${config_rtps_send_topics}) - list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Publisher.cpp) - list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Publisher.h) - 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_receive_topics}) - list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Subscriber.cpp) - list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Subscriber.h) - endforeach() + foreach(topic ${config_rtps_send_topics}) + list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Publisher.cpp) + list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Publisher.h) + endforeach() - if (NOT "${config_rtps_send_topics}" STREQUAL "" OR NOT "${config_rtps_receive_topics}" STREQUAL "") - set(topic_bridge_files_out microRTPS_client.cpp microRTPS_transport.cpp microRTPS_transport.h) + foreach(topic ${config_rtps_receive_topics}) + list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Subscriber.cpp) + list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Subscriber.h) + endforeach() - set(send_topic_files_opt) - if (NOT "${send_topic_files}" STREQUAL "") - set(send_topic_opt "-s") - endif() + 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 "-r") - endif() + set(receive_topic_files_opt) + if (NOT "${receive_topic_files}" STREQUAL "") + set(receive_topic_opt "--receive") + endif() - add_custom_command(OUTPUT ${topic_bridge_files_out} - COMMAND ${PYTHON_EXECUTABLE} - ${PX4_SOURCE_DIR}/Tools/generate_microRTPS_bridge.py - -f $ENV{FASTRTPSGEN_DIR} - ${send_topic_opt} ${send_topic_files} - ${receive_topic_opt} ${receive_topic_files} - -t ${topic_msg_path} - -u ${msg_out_path} - DEPENDS ${DEPENDS} ${send_topic_files} ${receive_topic_files} - COMMENT "Generating RTPS topic bridge" - VERBATIM - ) - add_custom_target(topic_bridge_files DEPENDS ${topic_bridge_files_out}) + 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 + ) - px4_add_module( - MODULE modules__micrortps_bridge__micrortps_client - MAIN micrortps_client - STACK_MAIN 4096 - SRCS - ${msg_out_path}/microRTPS_transport.cpp - ${msg_out_path}/microRTPS_client.cpp - microRTPS_client_main.cpp - DEPENDS - platforms__common - topic_bridge_files + 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 + DEPENDS ${send_topic_files} ${receive_topic_files} + COMMENT "Generating RTPS topic bridge" + VERBATIM ) - endif() + 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 + ${CMAKE_CURRENT_BINARY_DIR}/micrortps_client/microRTPS_transport.cpp + ${CMAKE_CURRENT_BINARY_DIR}/micrortps_client/microRTPS_client.cpp + microRTPS_client_main.cpp + DEPENDS + platforms__common + topic_bridge_files + uorb_headers + ) + target_link_libraries(modules__micrortps_bridge__micrortps_client PRIVATE lib__micro-CDR) + endif() endif() \ No newline at end of file diff --git a/src/modules/uORB/CMakeLists.txt b/src/modules/uORB/CMakeLists.txt index 1274da703d..95b5121363 100644 --- a/src/modules/uORB/CMakeLists.txt +++ b/src/modules/uORB/CMakeLists.txt @@ -49,3 +49,4 @@ px4_add_module( DEPENDS platforms__common ) +target_link_libraries(modules__uORB uorb_msgs) diff --git a/src/platforms/common/CMakeLists.txt b/src/platforms/common/CMakeLists.txt index 7e536726c1..5f6f57f6cb 100644 --- a/src/platforms/common/CMakeLists.txt +++ b/src/platforms/common/CMakeLists.txt @@ -30,10 +30,6 @@ # POSSIBILITY OF SUCH DAMAGE. # ############################################################################ -set(depends - msg_gen - prebuild_targets - ) px4_add_module( MODULE platforms__common @@ -42,6 +38,7 @@ px4_add_module( px4_getopt.c shutdown.cpp DEPENDS - ${depends} + prebuild_targets + uorb_headers ) # vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/systemcmds/topic_listener/CMakeLists.txt b/src/systemcmds/topic_listener/CMakeLists.txt index ec6351364d..9bae4dacde 100644 --- a/src/systemcmds/topic_listener/CMakeLists.txt +++ b/src/systemcmds/topic_listener/CMakeLists.txt @@ -33,11 +33,12 @@ add_custom_command(OUTPUT topic_listener.cpp COMMAND ${PYTHON_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/generate_listener.py ${PX4_SOURCE_DIR} > topic_listener.cpp - DEPENDS generate_listener.py msg_gen + DEPENDS generate_listener.py uorb_headers ) add_custom_target(generate_topic_listener - DEPENDS topic_listener.cpp generate_listener.py) + DEPENDS topic_listener.cpp generate_listener.py + ) px4_add_module( MODULE systemcmds__topic_listener