uORB generation move to msg/

This commit is contained in:
Daniel Agar 2017-09-25 18:00:59 -04:00
parent 03784c6b01
commit 48f1e3ed1c
19 changed files with 132 additions and 237 deletions

14
.gitignore vendored
View File

@ -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

4
.gitmodules vendored
View File

@ -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

View File

@ -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})

View File

@ -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 <target> MSGS <msg-files>)
#
# 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 <target>
# MSG_FILES <files> OS <operating-system>
# [ DEPENDS <dependencies> ]
# )
#
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

View File

@ -231,4 +231,3 @@ if(REPLAY_FILE)
message("Building with uorb publisher rules support")
add_definitions(-DORB_USE_PUBLISHER_RULES)
endif()

View File

@ -32,7 +32,6 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/src/lib}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/src/lib/geo}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/src/platforms}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/src/modules/uORB}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/src/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/uORB/topics}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware}&quot;"/>
@ -54,7 +53,6 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/src/lib}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/src/lib/geo}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/src/platforms}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/src/modules/uORB}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/src/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/uORB/topics}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware}&quot;"/>
@ -83,7 +81,6 @@
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/src/modules/systemlib}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/src/lib/geo}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/src/platforms}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/src/modules/uORB}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/src/include}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware/uORB/topics}&quot;"/>
<listOptionValue builtIn="false" value="&quot;${workspace_loc:/PX4-Firmware}&quot;"/>

View File

@ -59,11 +59,11 @@
<variableList>
<variable>
<name>uORB_LOC</name>
<value>$%7BPROJECT_LOC%7D/build/posix_sitl_default/src/modules/uORB</value>
<value>$%7BPROJECT_LOC%7D/build/posix_sitl_default/uORB</value>
</variable>
<variable>
<name>uORB_SRC</name>
<value>$%7BPROJECT_LOC%7D/build/posix_sitl_default/topics_sources</value>
<value>$%7BPROJECT_LOC%7D/build/posix_sitl_default/msg/topics_sources</value>
</variable>
</variableList>
</projectDescription>

View File

@ -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)

View File

@ -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]
@#################################################

View File

@ -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

View File

@ -47,14 +47,10 @@ 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)
if (NOT "${config_rtps_send_topics}" STREQUAL "" OR NOT "${config_rtps_receive_topics}" STREQUAL "")
set(send_topic_files)
foreach(topic ${config_rtps_send_topics})
@ -76,44 +72,52 @@ if(NOT GENERATE_RTPS_BRIDGE MATCHES "off")
list(APPEND topic_bridge_files_out ${msg_out_path}/${topic}_Subscriber.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)
set(send_topic_files_opt)
if (NOT "${send_topic_files}" STREQUAL "")
set(send_topic_opt "-s")
set(send_topic_opt "--send")
endif()
set(receive_topic_files_opt)
if (NOT "${receive_topic_files}" STREQUAL "")
set(receive_topic_opt "-r")
set(receive_topic_opt "--receive")
endif()
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
)
add_custom_command(OUTPUT ${topic_bridge_files_out}
COMMAND ${PYTHON_EXECUTABLE}
${PX4_SOURCE_DIR}/Tools/generate_microRTPS_bridge.py
-f $ENV{FASTRTPSGEN_DIR}
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}
-t ${topic_msg_path}
-u ${msg_out_path}
DEPENDS ${DEPENDS} ${send_topic_files} ${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
)
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
${msg_out_path}/microRTPS_transport.cpp
${msg_out_path}/microRTPS_client.cpp
${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()

View File

@ -49,3 +49,4 @@ px4_add_module(
DEPENDS
platforms__common
)
target_link_libraries(modules__uORB uorb_msgs)

View File

@ -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 :

View File

@ -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