diff --git a/.ci/Jenkinsfile-compile b/.ci/Jenkinsfile-compile
index 44936a53e8..570b7feacc 100644
--- a/.ci/Jenkinsfile-compile
+++ b/.ci/Jenkinsfile-compile
@@ -28,7 +28,7 @@ pipeline {
]
def base_builds = [
- target: ["px4_sitl_rtps"],
+ target: ["px4_sitl_default"],
image: docker_images.base,
archive: false
]
@@ -63,23 +63,17 @@ pipeline {
"matek_gnss-m9n-f4_canbootloader",
"matek_gnss-m9n-f4_default",
"modalai_fc-v1_default",
- "modalai_fc-v1_rtps",
"modalai_fc-v2_default",
"mro_ctrl-zero-f7_default",
"mro_ctrl-zero-f7-oem_default",
"mro_ctrl-zero-h7_default",
- "mro_ctrl-zero-h7_rtps",
"mro_ctrl-zero-h7-oem_default",
- "mro_ctrl-zero-h7-oem_rtps",
"mro_pixracerpro_default",
- "mro_pixracerpro_rtps",
"mro_x21-777_default",
"mro_x21_default",
"nxp_fmuk66-e_default",
- "nxp_fmuk66-e_rtps",
"nxp_fmuk66-e_socketcan",
"nxp_fmuk66-v3_default",
- "nxp_fmuk66-v3_rtps",
"nxp_fmuk66-v3_socketcan",
"nxp_fmurt1062-v1_default",
"nxp_ucans32k146_canbootloader",
@@ -95,7 +89,6 @@ pipeline {
"px4_fmu-v4pro_default",
"px4_fmu-v5_debug",
"px4_fmu-v5_default",
- "px4_fmu-v5_rtps",
"px4_fmu-v5_stackcheck",
"px4_fmu-v5_uavcanv0periph",
"px4_fmu-v5_uavcanv1",
diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml
index bcae79ad69..42296a43e4 100644
--- a/.github/workflows/checks.yml
+++ b/.github/workflows/checks.yml
@@ -23,7 +23,6 @@ jobs:
"shellcheck_all",
"NO_NINJA_BUILD=1 px4_fmu-v5_default",
"NO_NINJA_BUILD=1 px4_sitl_default",
- "BUILD_MICRORTPS_AGENT=1 px4_sitl_rtps",
"airframe_metadata",
"module_documentation",
"parameters_metadata",
diff --git a/.github/workflows/metadata.yml b/.github/workflows/metadata.yml
index 3adb3e565e..a7a9f9faca 100644
--- a/.github/workflows/metadata.yml
+++ b/.github/workflows/metadata.yml
@@ -115,43 +115,3 @@ jobs:
cd Tools/uorb_graph
ls -ls *
# TODO: deploy graph_px4_sitl.json to S3 px4-travis:Firmware/master/
-
- micrortps_agent:
- runs-on: ubuntu-latest
- container: px4io/px4-dev-base-focal:2021-09-08
- steps:
- - uses: actions/checkout@v1
- with:
- token: ${{ secrets.ACCESS_TOKEN }}
-
- - name: microRTPS agent
- run: |
- make px4_sitl_rtps
- git clone https://github.com/PX4/micrortps_agent.git
- cp -R build/px4_sitl_rtps/src/modules/micrortps_bridge/micrortps_agent/* micrortps_agent
-
- ROS_msgs:
- runs-on: ubuntu-latest
- container: px4io/px4-dev-base-focal:2021-09-08
- steps:
- - uses: actions/checkout@v1
- with:
- token: ${{ secrets.ACCESS_TOKEN }}
-
- - name: PX4 ROS msgs
- run: |
- git clone https://github.com/PX4/px4_msgs.git
- python3 msg/tools/uorb_to_ros_msgs.py msg/ px4_msgs/msg/
-
- ROS2_bridge:
- runs-on: ubuntu-latest
- container: px4io/px4-dev-base-focal:2021-09-08
- steps:
- - uses: actions/checkout@v1
- with:
- token: ${{ secrets.ACCESS_TOKEN }}
-
- - name: PX4 ROS2 bridge
- run: |
- git clone https://github.com/PX4/px4_ros_com.git
- ./msg/tools/uorb_to_ros_urtps_topics.py -i msg/tools/urtps_bridge_topics.yaml -o px4_ros_com/templates/urtps_bridge_topics.yaml
diff --git a/.gitmodules b/.gitmodules
index f23a7a3e78..1573bf09e8 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -18,10 +18,6 @@
path = src/drivers/gps/devices
url = https://github.com/PX4/PX4-GPSDrivers.git
branch = master
-[submodule "src/modules/micrortps_bridge/micro-CDR"]
- path = src/modules/micrortps_bridge/micro-CDR
- url = https://github.com/PX4/Micro-CDR.git
- branch = master
[submodule "platforms/nuttx/NuttX/nuttx"]
path = platforms/nuttx/NuttX/nuttx
url = https://github.com/PX4/NuttX.git
diff --git a/.vscode/cmake-variants.yaml b/.vscode/cmake-variants.yaml
index 4c023f3580..96b3bf3276 100644
--- a/.vscode/cmake-variants.yaml
+++ b/.vscode/cmake-variants.yaml
@@ -6,11 +6,6 @@ CONFIG:
buildType: RelWithDebInfo
settings:
CONFIG: px4_sitl_default
- px4_sitl_rtps:
- short: px4_sitl_rtps
- buildType: RelWithDebInfo
- settings:
- CONFIG: px4_sitl_rtps
px4_sitl_asan:
short: px4_sitl (AddressSanitizer)
buildType: AddressSanitizer
@@ -31,6 +26,11 @@ CONFIG:
buildType: RelWithDebInfo
settings:
CONFIG: px4_sitl_test
+ px4_ros2_default:
+ short: px4_ros2
+ buildType: RelWithDebInfo
+ settings:
+ CONFIG: px4_ros2_default
px4_io-v2_default:
short: px4_io-v2
buildType: MinSizeRel
diff --git a/.vscode/settings.json b/.vscode/settings.json
index 1bf4e6eb2f..c917fe0a03 100644
--- a/.vscode/settings.json
+++ b/.vscode/settings.json
@@ -6,7 +6,7 @@
"C_Cpp.autoAddFileAssociations": false,
"C_Cpp.clang_format_fallbackStyle": "none",
"C_Cpp.default.browse.limitSymbolsToIncludedHeaders": true,
- "C_Cpp.default.cppStandard": "c++14",
+ "C_Cpp.default.cppStandard": "c++17",
"C_Cpp.default.cStandard": "c11",
"C_Cpp.formatting": "Disabled",
"C_Cpp.intelliSenseEngine": "Default",
@@ -121,6 +121,7 @@
"variant": "cpp",
"vector": "cpp"
},
+ "ros.distro": "foxy",
"search.exclude": {
"${workspaceFolder}/build": true
},
@@ -136,5 +137,7 @@
"yaml.schemas": {
"${workspaceFolder}/validation/module_schema.yaml": "${workspaceFolder}/src/modules/*/module.yaml"
},
- "cortex-debug.openocdPath": "${env:PICO_SDK_PATH}/../openocd/src/openocd" // Added for rp2040
+ "python.autoComplete.extraPaths": [
+ "/opt/ros/foxy/lib/python3.8/site-packages"
+ ]
}
diff --git a/.ycm_extra_conf.py b/.ycm_extra_conf.py
deleted file mode 100644
index 4f7cfc2020..0000000000
--- a/.ycm_extra_conf.py
+++ /dev/null
@@ -1,172 +0,0 @@
-# This file is NOT licensed under the GPLv3, which is the license for the rest
-# of YouCompleteMe.
-#
-# Here's the license text for this file:
-#
-# This is free and unencumbered software released into the public domain.
-#
-# Anyone is free to copy, modify, publish, use, compile, sell, or
-# distribute this software, either in source code form or as a compiled
-# binary, for any purpose, commercial or non-commercial, and by any
-# means.
-#
-# In jurisdictions that recognize copyright laws, the author or authors
-# of this software dedicate any and all copyright interest in the
-# software to the public domain. We make this dedication for the benefit
-# of the public at large and to the detriment of our heirs and
-# successors. We intend this dedication to be an overt act of
-# relinquishment in perpetuity of all present and future rights to this
-# software under copyright law.
-#
-# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-# IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-# OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-# ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-# OTHER DEALINGS IN THE SOFTWARE.
-#
-# For more information, please refer to
-
-import os
-import ycm_core
-
-# These are the compilation flags that will be used in case there's no
-# compilation database set (by default, one is not set).
-# CHANGE THIS LIST OF FLAGS. YES, THIS IS THE DROID YOU HAVE BEEN LOOKING FOR.
-flags = [
-'-Wall',
-'-Wextra',
-'-Werror',
-#'-Wc++98-compat',
-'-Wno-long-long',
-'-Wno-variadic-macros',
-'-fexceptions',
-'-DNDEBUG',
-# You 100% do NOT need -DUSE_CLANG_COMPLETER in your flags; only the YCM
-# source code needs it.
-#'-DUSE_CLANG_COMPLETER',
-# THIS IS IMPORTANT! Without a "-std=" flag, clang won't know which
-# language to use when compiling headers. So it will guess. Badly. So C++
-# headers will be compiled as C headers. You don't want that so ALWAYS specify
-# a "-std=".
-# For a C project, you would set this to something like 'c99' instead of
-# 'c++14'.
-'-std=c++14',
-# ...and the same thing goes for the magic -x option which specifies the
-# language that the files to be compiled are written in. This is mostly
-# relevant for c++ headers.
-# For a C project, you would set this to 'c' instead of 'c++'.
-'-x',
-'c++',
-'-undef', # get rid of standard definitions to allow us to include arm math header
-'-I', os.path.join(os.path.expanduser("~"),'gcc-arm-none-eabi-4_7-2013q3/arm-none-eabi/include'),
-'-I', 'Build/px4_io-v2_default.build/nuttx-export/include/',
-'-I', './NuttX/nuttx/arch/arm/include',
-'-include', './src/include/visibility.h',
-'-I', './src',
-'-I', './src/modules',
-'-I', './src/include',
-'-I', './src/lib',
-'-I', './NuttX',
-]
-
-
-# Set this to the absolute path to the folder (NOT the file!) containing the
-# compile_commands.json file to use that instead of 'flags'. See here for
-# more details: http://clang.llvm.org/docs/JSONCompilationDatabase.html
-#
-# Most projects will NOT need to set this to anything; you can just change the
-# 'flags' list of compilation flags. Notice that YCM itself uses that approach.
-compilation_database_folder = ''
-
-if os.path.exists( compilation_database_folder ):
- database = ycm_core.CompilationDatabase( compilation_database_folder )
-else:
- database = None
-
-SOURCE_EXTENSIONS = [ '.cpp', '.cxx', '.cc', '.c', '.m', '.mm' ]
-
-def DirectoryOfThisScript():
- return os.path.dirname( os.path.abspath( __file__ ) )
-
-
-def MakeRelativePathsInFlagsAbsolute( flags, working_directory ):
- if not working_directory:
- return list( flags )
- new_flags = []
- make_next_absolute = False
- path_flags = [ '-isystem', '-I', '-iquote', '--sysroot=' ]
- for flag in flags:
- new_flag = flag
-
- if make_next_absolute:
- make_next_absolute = False
- if not flag.startswith( '/' ):
- new_flag = os.path.join( working_directory, flag )
-
- for path_flag in path_flags:
- if flag == path_flag:
- make_next_absolute = True
- break
-
- if flag.startswith( path_flag ):
- path = flag[ len( path_flag ): ]
- new_flag = path_flag + os.path.join( working_directory, path )
- break
-
- if new_flag:
- new_flags.append( new_flag )
- return new_flags
-
-
-def IsHeaderFile( filename ):
- extension = os.path.splitext( filename )[ 1 ]
- return extension in [ '.h', '.hxx', '.hpp', '.hh' ]
-
-
-def GetCompilationInfoForFile( filename ):
- # The compilation_commands.json file generated by CMake does not have entries
- # for header files. So we do our best by asking the db for flags for a
- # corresponding source file, if any. If one exists, the flags for that file
- # should be good enough.
- if IsHeaderFile( filename ):
- basename = os.path.splitext( filename )[ 0 ]
- for extension in SOURCE_EXTENSIONS:
- replacement_file = basename + extension
- if os.path.exists( replacement_file ):
- compilation_info = database.GetCompilationInfoForFile(
- replacement_file )
- if compilation_info.compiler_flags_:
- return compilation_info
- return None
- return database.GetCompilationInfoForFile( filename )
-
-
-def FlagsForFile( filename, **kwargs ):
- if database:
- # Bear in mind that compilation_info.compiler_flags_ does NOT return a
- # python list, but a "list-like" StringVec object
- compilation_info = GetCompilationInfoForFile( filename )
- if not compilation_info:
- return None
-
- final_flags = MakeRelativePathsInFlagsAbsolute(
- compilation_info.compiler_flags_,
- compilation_info.compiler_working_dir_ )
-
- # NOTE: This is just for YouCompleteMe; it's highly likely that your project
- # does NOT need to remove the stdlib flag. DO NOT USE THIS IN YOUR
- # ycm_extra_conf IF YOU'RE NOT 100% SURE YOU NEED IT.
- #try:
- # final_flags.remove( '-stdlib=libc++' )
- #except ValueError:
- # pass
- else:
- relative_to = DirectoryOfThisScript()
- final_flags = MakeRelativePathsInFlagsAbsolute( flags, relative_to )
-
- return {
- 'flags': final_flags,
- 'do_cache': True
- }
diff --git a/CMakeLists.txt b/CMakeLists.txt
index a6288819a9..8d6006c0fb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
############################################################################
#
-# Copyright (c) 2017 - 2019 PX4 Development Team. All rights reserved.
+# Copyright (c) 2017 - 2022 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
@@ -101,6 +101,8 @@
cmake_minimum_required(VERSION 3.2 FATAL_ERROR)
+cmake_policy(SET CMP0058 NEW)
+
set(PX4_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}" CACHE FILEPATH "PX4 source directory" FORCE)
set(PX4_BINARY_DIR "${CMAKE_CURRENT_BINARY_DIR}" CACHE FILEPATH "PX4 binary directory" FORCE)
@@ -138,30 +140,41 @@ define_property(GLOBAL PROPERTY PX4_SRC_FILES
BRIEF_DOCS "src files from all PX4 modules & libs"
FULL_DOCS "SRC files from px4_add_{module,library}"
)
-
+define_property(GLOBAL PROPERTY PX4_PUBLICATIONS
+ BRIEF_DOCS "PX4 publication topics"
+ FULL_DOCS "List of topics published by PX4 modules"
+ )
+define_property(GLOBAL PROPERTY PX4_SUBSCRIPTIONS
+ BRIEF_DOCS "PX4 subscription topics"
+ FULL_DOCS "List of topics subscribed by PX4 modules"
+ )
#=============================================================================
# configuration
#
-set(CONFIG "px4_sitl_default" CACHE STRING "desired configuration")
+# default to px4_ros2_default if building within a ROS2 colcon environment
+if((DEFINED ENV{COLCON_PREFIX_PATH}) AND (DEFINED ENV{ROS_VERSION}))
+ if("$ENV{ROS_VERSION}" MATCHES "2")
+ message(STATUS "ROS_VERSION: $ENV{ROS_VERSION}")
+ set(CONFIG "px4_ros2_default" CACHE STRING "desired configuration") # TODO
+ endif()
+endif()
+
+if(NOT CONFIG)
+ set(CONFIG "px4_sitl_default" CACHE STRING "desired configuration")
+endif()
include(px4_add_module)
set(config_module_list)
set(config_kernel_list)
# Find Python
-# If using catkin, Python 2 is found since it points
-# to the Python libs installed with the ROS distro
-if (NOT CATKIN_DEVEL_PREFIX)
- find_package(PythonInterp 3)
- # We have a custom error message to tell users how to install python3.
- if (NOT PYTHONINTERP_FOUND)
- message(FATAL_ERROR "Python 3 not found. Please install Python 3:\n"
- " Ubuntu: sudo apt install python3 python3-dev python3-pip\n"
- " macOS: brew install python")
- endif()
-else()
- find_package(PythonInterp REQUIRED)
+find_package(PythonInterp 3)
+# We have a custom error message to tell users how to install python3.
+if(NOT PYTHONINTERP_FOUND)
+ message(FATAL_ERROR "Python 3 not found. Please install Python 3:\n"
+ " Ubuntu: sudo apt install python3 python3-dev python3-pip\n"
+ " macOS: brew install python")
endif()
option(PYTHON_COVERAGE "Python code coverage" OFF)
@@ -197,10 +210,6 @@ set_property(GLOBAL PROPERTY PX4_MODULE_CONFIG_FILES)
include(platforms/${PX4_PLATFORM}/cmake/px4_impl_os.cmake)
list(APPEND CMAKE_MODULE_PATH ${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/cmake)
-if(EXISTS "${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/cmake/init.cmake")
- include(init)
-endif()
-
# CMake build type (Debug Release RelWithDebInfo MinSizeRel Coverage)
if(NOT CMAKE_BUILD_TYPE)
if(${PX4_PLATFORM} STREQUAL "nuttx")
@@ -236,20 +245,18 @@ project(px4 CXX C ASM)
set(package-contact "px4users@googlegroups.com")
-set(CMAKE_CXX_STANDARD 14)
+set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
-# For the catkin build process, unset build of dynamically-linked binaries
-# and do not change CMAKE_RUNTIME_OUTPUT_DIRECTORY
-if (NOT CATKIN_DEVEL_PREFIX)
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PX4_BINARY_DIR})
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PX4_BINARY_DIR})
- set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PX4_BINARY_DIR})
-else()
- SET(BUILD_SHARED_LIBS OFF)
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PX4_BINARY_DIR})
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_DEBUG ${PX4_BINARY_DIR})
+set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_RELEASE ${PX4_BINARY_DIR})
+
+if(EXISTS "${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/cmake/init.cmake")
+ include(init)
endif()
#=============================================================================
@@ -295,21 +302,6 @@ endif()
include(ccache)
-#=============================================================================
-# find programs and packages
-#
-
-# see if catkin was invoked to build this
-if (CATKIN_DEVEL_PREFIX)
- message(STATUS "catkin ENABLED")
- find_package(catkin REQUIRED)
- if (catkin_FOUND)
- catkin_package()
- else()
- message(FATAL_ERROR "catkin not found")
- endif()
-endif()
-
#=============================================================================
# get chip and chip manufacturer
#
@@ -321,13 +313,6 @@ if(NOT PX4_CHIP)
message(FATAL_ERROR "px4_os_determine_build_chip() needs to set PX4_CHIP")
endif()
-#=============================================================================
-# build flags
-#
-include(px4_add_common_flags)
-px4_add_common_flags()
-px4_os_add_flags()
-
#=============================================================================
# board cmake init (optional)
#
@@ -335,6 +320,13 @@ if(EXISTS ${PX4_BOARD_DIR}/cmake/init.cmake)
include(${PX4_BOARD_DIR}/cmake/init.cmake)
endif()
+#=============================================================================
+# build flags
+#
+include(px4_add_common_flags)
+px4_add_common_flags()
+px4_os_add_flags()
+
#=============================================================================
# message, and airframe generation
#
@@ -416,8 +408,13 @@ add_library(parameters_interface INTERFACE)
include(px4_add_library)
add_subdirectory(src/lib EXCLUDE_FROM_ALL)
-add_subdirectory(platforms/${PX4_PLATFORM}/src/px4)
-add_subdirectory(platforms EXCLUDE_FROM_ALL)
+add_subdirectory(platforms/${PX4_PLATFORM}/src/px4 EXCLUDE_FROM_ALL)
+
+if(${PX4_PLATFORM} MATCHES "ros2") # TODO: fix
+ add_subdirectory(platforms/common/work_queue EXCLUDE_FROM_ALL)
+else()
+ add_subdirectory(platforms EXCLUDE_FROM_ALL)
+endif()
if(EXISTS "${PX4_BOARD_DIR}/CMakeLists.txt")
add_subdirectory(${PX4_BOARD_DIR})
@@ -439,6 +436,126 @@ target_link_libraries(parameters_interface INTERFACE parameters)
# firmware added last to generate the builtin for included modules
add_subdirectory(platforms/${PX4_PLATFORM})
+
+set(PX4_ORB_TOPIC_COUNT 0)
+
+if(${PX4_PLATFORM} MATCHES "ros2") # TODO: fix
+
+ configure_file(${CMAKE_SOURCE_DIR}/build/px4_fmu-v5x_default/uORBTopics.cpp ${CMAKE_BINARY_DIR}/uORBTopics.cpp COPYONLY)
+ configure_file(${CMAKE_SOURCE_DIR}/build/px4_fmu-v5x_default/uORBTopics.hpp ${CMAKE_BINARY_DIR}/uORBTopics.hpp COPYONLY)
+
+ set(PX4_ORB_TOPIC_COUNT 1)
+
+else()
+
+ get_property(publications GLOBAL PROPERTY PX4_PUBLICATIONS)
+ get_property(subscriptions GLOBAL PROPERTY PX4_SUBSCRIPTIONS)
+
+ # TODO: for now combine subsriptions and publications for complete topic list
+ list(APPEND publications ${subscriptions})
+
+ list(SORT publications)
+ list(REMOVE_DUPLICATES publications)
+
+ set(pub_all_topics)
+ set(PX4_MSG_TYPE_ID)
+ set(PX4_MSG_TOPIC_ID)
+ set(PX4_MSG_TOPIC_ID_STRING)
+ set(PX4_MSG_TOPIC_ORB_ID)
+
+ set(PX4_ORB_DECLARE_STR)
+ set(PX4_ORB_DEFINE_STR)
+ set(PX4_ORB_HEADER_INCLUDE_STR)
+
+
+ foreach(pub ${publications})
+ #message(STATUS "pub: ${pub}")
+ string(REPLACE " /" ";" pub ${pub})
+
+ list(GET pub 0 pub_type)
+ list(GET pub 1 pub_topic)
+
+ string(REPLACE "::" ";" pub_type_split ${pub_type})
+ list(GET pub_type_split 2 pub_type_simple_lower)
+
+ # Pascal case to snake case (PubType -> pub_type)
+ string(REGEX REPLACE "(.)([A-Z][a-z]+)" "\\1_\\2" pub_type_simple_lower "${pub_type_simple_lower}")
+ string(REGEX REPLACE "([a-z0-9])([A-Z])" "\\1_\\2" pub_type_simple_lower "${pub_type_simple_lower}")
+ string(TOLOWER "${pub_type_simple_lower}" pub_type_simple_lower)
+
+ #message(STATUS "pub: Type: ${pub_type}, Topic: ${pub_topic} (${pub_type_simple_lower})")
+
+
+
+
+ # pub_type to include path (eg px4::msg::VehicleStatus => px4/msg/vehicle_status.hpp)
+ # temporary create px4/msg/vehicle_status.hpp which simply includes
+
+
+
+
+ list(APPEND pub_all_topics ${pub_topic})
+
+ list(APPEND PX4_MSG_TYPE_ID ${pub_type})
+
+ #list(APPEND PX4_MSG_TOPIC_ID ${pub_topic})
+ set(PX4_MSG_TOPIC_ID "${PX4_MSG_TOPIC_ID}\t${pub_topic},\n")
+ #set(PX4_MSG_TOPIC_ID_STRING "${PX4_MSG_TOPIC_ID_STRING}\t"case ORB_ID::${pub_topic}: return \"${pub_topic}\";"\n")
+ set(PX4_MSG_TOPIC_ORB_ID "${PX4_MSG_TOPIC_ORB_ID}\tORB_ID(${pub_topic}),\n")
+
+ list(APPEND PX4_MSG_TOPIC_ID_STRING
+ "case ORB_ID::${pub_topic}: return \"${pub_topic}\";\n"
+ )
+
+ # PX4_MSG_TYPE_ID
+ # PX4_MSG_TOPIC_ID
+
+ # .h ORB_DECLARE(actuator_controls_0);
+ # .c ORB_DEFINE(actuator_controls_0, struct actuator_controls_s, 48, __orb_actuator_controls_fields, static_cast(ORB_ID::actuator_controls_0));
+
+
+ set(PX4_ORB_DECLARE_STR
+ "${PX4_ORB_DECLARE_STR}ORB_DECLARE(${pub_topic});\n")
+
+ # ORB_DEFINE(actuator_armed, struct actuator_armed_s, 16, __orb_actuator_armed_fields, static_cast(ORB_ID::actuator_armed));
+ set(PX4_ORB_DEFINE_STR
+ "${PX4_ORB_DEFINE_STR}ORB_DEFINE(${pub_topic}, ${pub_type}, px4_embedded::${pub_type_simple_lower}_s::SIZE_NO_PADDING, px4_embedded::${pub_type_simple_lower}_s::FIELDS, static_cast(ORB_ID::${pub_topic}));\n")
+
+ set(PX4_ORB_HEADER_INCLUDE_STR
+ "${PX4_ORB_HEADER_INCLUDE_STR}#include \n")
+
+ math(EXPR PX4_ORB_TOPIC_COUNT "${PX4_ORB_TOPIC_COUNT}+1")
+
+ endforeach()
+ list(REMOVE_DUPLICATES PX4_MSG_TYPE_ID)
+ #list(REMOVE_DUPLICATES PX4_MSG_TOPIC_ID)
+
+ #message(STATUS "PX4_MSG_TYPE_ID: ${PX4_MSG_TYPE_ID}")
+ #message(STATUS "PX4_MSG_TOPIC_ID: ${PX4_MSG_TOPIC_ID}")
+
+ if(PX4_ORB_TOPIC_COUNT GREATER 0)
+ configure_file(uORBTopics.cpp.in ${CMAKE_BINARY_DIR}/uORBTopics.cpp)
+ configure_file(uORBTopics.hpp.in ${CMAKE_BINARY_DIR}/uORBTopics.hpp)
+ endif()
+
+ # .hpp enum ORB_ID
+ # .cpp struct orb_metadat ORB_ID() array
+
+ foreach(f ${msg_files})
+ #message(STATUS "MSG: ${f}")
+ endforeach()
+endif()
+
+if(PX4_ORB_TOPIC_COUNT GREATER 0)
+ add_library(uorb_msgs ${uorb_headers} ${CMAKE_BINARY_DIR}/uORBTopics.cpp ${CMAKE_BINARY_DIR}/uORBTopics.hpp)
+ add_dependencies(uorb_msgs prebuild_targets uorb_headers)
+endif()
+
+if(${PX4_PLATFORM} MATCHES "ros2") # TODO: fix
+ ament_target_dependencies(uorb_msgs rclcpp std_msgs)
+ rosidl_target_interfaces(uorb_msgs ${PROJECT_NAME} "rosidl_typesupport_cpp")
+endif()
+
#=============================================================================
# uORB graph generation: add a custom target 'uorb_graph'
#
@@ -466,17 +583,13 @@ include(doxygen)
include(metadata)
include(package)
-# print size
-add_custom_target(size
- COMMAND size $
- DEPENDS px4
- WORKING_DIRECTORY ${PX4_BINARY_DIR}
- USES_TERMINAL
- )
-
# install python requirements using configured python
add_custom_target(install_python_requirements
COMMAND ${PYTHON_EXECUTABLE} -m pip install --requirement ${PX4_SOURCE_DIR}/Tools/setup/requirements.txt
DEPENDS ${PX4_SOURCE_DIR}/Tools/setup/requirements.txt
USES_TERMINAL
)
+
+if(EXISTS "${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/cmake/finalize.cmake")
+ include(finalize)
+endif()
diff --git a/Documentation/Doxyfile.in b/Documentation/Doxyfile.in
index f6d12430c7..0874d152cf 100644
--- a/Documentation/Doxyfile.in
+++ b/Documentation/Doxyfile.in
@@ -829,7 +829,6 @@ RECURSIVE = YES
# run.
EXCLUDE = @CMAKE_SOURCE_DIR@/src/modules/uavcan/libuavcan \
- @CMAKE_SOURCE_DIR@/src/modules/micrortps_bridge/micro-CDR \
@CMAKE_SOURCE_DIR@/src/examples \
@CMAKE_SOURCE_DIR@/src/templates
diff --git a/Jenkinsfile b/Jenkinsfile
index 22d4702879..ee953e56ef 100644
--- a/Jenkinsfile
+++ b/Jenkinsfile
@@ -12,76 +12,6 @@ pipeline {
}
}
parallel {
- // stage('Catkin build on ROS workspace') {
- // agent {
- // docker {
- // image 'px4io/px4-dev-ros-melodic:2021-08-18'
- // args '-e CCACHE_BASEDIR=$WORKSPACE -v ${CCACHE_DIR}:${CCACHE_DIR}:rw -e HOME=$WORKSPACE'
- // }
- // }
- // steps {
- // sh 'ls -l'
- // sh '''#!/bin/bash -l
- // echo $0;
- // mkdir -p catkin_ws/src;
- // cd catkin_ws;
- // git -C ${WORKSPACE}/catkin_ws/src/Firmware submodule update --init --recursive --force Tools/sitl_gazebo
- // git clone --recursive ${WORKSPACE}/catkin_ws/src/Firmware/Tools/sitl_gazebo src/mavlink_sitl_gazebo;
- // git -C ${WORKSPACE}/catkin_ws/src/Firmware fetch --tags;
- // source /opt/ros/melodic/setup.bash;
- // export PYTHONPATH=/opt/ros/$ROS_DISTRO/lib/python2.7/dist-packages:/usr/lib/python2.7/dist-packages:/usr/local/lib/python2.7/dist-packages;
- // catkin init;
- // catkin build -j$(nproc) -l$(nproc);
- // '''
- // // test if the binary was correctly installed and runs using 'mavros_posix_silt.launch'
- // sh '''#!/bin/bash -l
- // echo $0;
- // source catkin_ws/devel/setup.bash;
- // rostest px4 pub_test.launch;
- // '''
- // }
- // post {
- // always {
- // sh 'rm -rf catkin_ws'
- // }
- // failure {
- // archiveArtifacts(allowEmptyArchive: false, artifacts: '.ros/**/*.xml, .ros/**/*.log')
- // }
- // }
- // options {
- // checkoutToSubdirectory('catkin_ws/src/Firmware')
- // }
- // }
-
- stage('Colcon build on ROS2 workspace') {
- agent {
- docker {
- image 'px4io/px4-dev-ros2-foxy:2021-08-18'
- args '-e CCACHE_BASEDIR=$WORKSPACE -v ${CCACHE_DIR}:${CCACHE_DIR}:rw -e HOME=$WORKSPACE'
- }
- }
- steps {
- sh 'ls -l'
- sh '''#!/bin/bash -l
- echo $0;
- unset ROS_DISTRO;
- mkdir -p colcon_ws/src;
- cd colcon_ws;
- git -C ${WORKSPACE}/colcon_ws/src/Firmware submodule update --init --recursive --force Tools/sitl_gazebo;
- git -C ${WORKSPACE}/colcon_ws/src/Firmware fetch --tags;
- source /opt/ros/foxy/setup.sh;
- colcon build --event-handlers console_direct+ --symlink-install;
- '''
- }
- post {
- always {
- sh 'rm -rf colcon_ws'
- }
- }
- options {
- checkoutToSubdirectory('colcon_ws/src/Firmware')
- }
- }
stage('Airframe') {
agent {
@@ -254,108 +184,6 @@ pipeline {
}
}
- stage('microRTPS agent') {
- agent {
- docker { image 'px4io/px4-dev-base-focal:2021-08-18' }
- }
- steps {
- sh('export')
- sh('git fetch --all --tags')
- sh('make distclean; git clean -ff -x -d .')
- sh('make px4_sitl_rtps')
- withCredentials([usernamePassword(credentialsId: 'px4buildbot_github_personal_token', passwordVariable: 'GIT_PASS', usernameVariable: 'GIT_USER')]) {
- sh("git clone https://${GIT_USER}:${GIT_PASS}@github.com/PX4/micrortps_agent.git -b ${BRANCH_NAME}")
- sh("rm -rf micrortps_agent/src micrortps_agent/idl")
- sh('cp -R build/px4_sitl_rtps/src/modules/micrortps_bridge/micrortps_agent/* micrortps_agent')
- sh('cd micrortps_agent; git status; git add src; git commit -a -m "Update microRTPS agent source code `date`" || true')
- sh('cd micrortps_agent; git push origin ${BRANCH_NAME} || true')
- sh('cd micrortps_agent; git status; git add idl; git commit -a -m "Update IDL definitions `date`" || true')
- sh('cd micrortps_agent; git push origin ${BRANCH_NAME} || true')
- sh('cd micrortps_agent; git status; git add CMakeLists.txt; git commit -a -m "Update CMakeLists.txt `date`" || true')
- sh('cd micrortps_agent; git push origin ${BRANCH_NAME} || true')
- sh('rm -rf micrortps_agent')
- }
- }
- when {
- anyOf {
- branch 'master'
- branch 'pr-jenkins' // for testing
- }
- }
- }
-
- stage('PX4 ROS msgs') {
- agent {
- docker { image 'px4io/px4-dev-base-focal:2021-08-18' }
- }
- steps {
- sh('export')
- sh('make distclean; git clean -ff -x -d .')
- withCredentials([usernamePassword(credentialsId: 'px4buildbot_github_personal_token', passwordVariable: 'GIT_PASS', usernameVariable: 'GIT_USER')]) {
- sh("git clone https://${GIT_USER}:${GIT_PASS}@github.com/PX4/px4_msgs.git")
- // 'master' branch
- sh('./msg/tools/uorb_to_ros_msgs.py msg/ px4_msgs/msg/')
- sh('cd px4_msgs; git status; git add .; git commit -a -m "Update message definitions `date`" || true')
- sh('cd px4_msgs; git push origin master || true')
- // 'ros1' branch
- sh('cd px4_msgs; git checkout ros1')
- sh('./msg/tools/uorb_to_ros_msgs.py msg/ px4_msgs/msg/')
- sh('cd px4_msgs; git status; git add .; git commit -a -m "Update message definitions `date`" || true')
- sh('cd px4_msgs; git push origin ros1 || true')
- sh('rm -rf px4_msgs')
- }
- }
- when {
- anyOf {
- branch 'master'
- branch 'pr-jenkins' // for testing
- }
- }
- }
-
- stage('PX4 ROS2 bridge') {
- agent {
- docker { image 'px4io/px4-dev-base-focal:2021-08-18' }
- }
- steps {
- sh('export')
- sh('make distclean; git clean -ff -x -d .')
- withCredentials([usernamePassword(credentialsId: 'px4buildbot_github_personal_token', passwordVariable: 'GIT_PASS', usernameVariable: 'GIT_USER')]) {
- sh("git clone https://${GIT_USER}:${GIT_PASS}@github.com/PX4/px4_ros_com.git -b ${BRANCH_NAME}")
- // deploy uORB RTPS ID map
- sh('./msg/tools/uorb_to_ros_urtps_topics.py -i msg/tools/urtps_bridge_topics.yaml -o px4_ros_com/templates/urtps_bridge_topics.yaml')
- sh('cd px4_ros_com; git status; git add .; git commit -a -m "Update uORB RTPS ID map `date`" || true')
- sh('cd px4_ros_com; git push origin ${BRANCH_NAME} || true')
- // deploy uORB RTPS required tools
- sh('cp msg/tools/uorb_rtps_classifier.py px4_ros_com/scripts/uorb_rtps_classifier.py')
- sh('cp msg/tools/generate_microRTPS_bridge.py px4_ros_com/scripts/generate_microRTPS_bridge.py')
- sh('cp msg/tools/px_generate_uorb_topic_files.py px4_ros_com/scripts/px_generate_uorb_topic_files.py')
- sh('cp msg/tools/px_generate_uorb_topic_helper.py px4_ros_com/scripts/px_generate_uorb_topic_helper.py')
- // deploy templates
- sh('cp msg/templates/urtps/microRTPS_agent.cpp.em px4_ros_com/templates/microRTPS_agent.cpp.em')
- sh('cp msg/templates/urtps/microRTPS_timesync.cpp.em px4_ros_com/templates/microRTPS_timesync.cpp.em')
- sh('cp msg/templates/urtps/microRTPS_timesync.h.em px4_ros_com/templates/microRTPS_timesync.h.em')
- sh('cp msg/templates/urtps/microRTPS_transport.cpp px4_ros_com/templates/microRTPS_transport.cpp')
- sh('cp msg/templates/urtps/microRTPS_transport.h px4_ros_com/templates/microRTPS_transport.h')
- sh('cp msg/templates/urtps/Publisher.cpp.em px4_ros_com/templates/Publisher.cpp.em')
- sh('cp msg/templates/urtps/Publisher.h.em px4_ros_com/templates/Publisher.h.em')
- sh('cp msg/templates/urtps/Subscriber.cpp.em px4_ros_com/templates/Subscriber.cpp.em')
- sh('cp msg/templates/urtps/Subscriber.h.em px4_ros_com/templates/Subscriber.h.em')
- sh('cp msg/templates/urtps/RtpsTopics.cpp.em px4_ros_com/templates/RtpsTopics.cpp.em')
- sh('cp msg/templates/urtps/RtpsTopics.h.em px4_ros_com/templates/RtpsTopics.h.em')
- sh('cd px4_ros_com; git status; git add .; git commit -a -m "Update uORB RTPS script tools `date`" || true')
- sh('cd px4_ros_com; git push origin ${BRANCH_NAME} || true')
- sh('rm -rf px4_msgs')
- }
- }
- when {
- anyOf {
- branch 'master'
- branch 'pr-jenkins' // for testing
- }
- }
- }
-
stage('S3') {
agent {
docker { image 'px4io/px4-dev-base-focal:2021-08-18' }
diff --git a/Kconfig b/Kconfig
index 425cf9fa82..7cbd36200a 100644
--- a/Kconfig
+++ b/Kconfig
@@ -17,6 +17,8 @@ menu "Toolchain"
bool "posix"
config PLATFORM_QURT
bool "qurt"
+ config PLATFORM_ROS2
+ bool "ros2"
endchoice
config BOARD_PLATFORM
@@ -24,6 +26,7 @@ menu "Toolchain"
default "nuttx" if PLATFORM_NUTTX
default "posix" if PLATFORM_POSIX
default "qurt" if PLATFORM_QURT
+ default "ros2" if PLATFORM_ROS2
config BOARD_LOCKSTEP
bool "Force enable lockstep"
diff --git a/Makefile b/Makefile
index 7f43b46b68..46ad216443 100644
--- a/Makefile
+++ b/Makefile
@@ -170,11 +170,6 @@ ifdef PYTHON_EXECUTABLE
CMAKE_ARGS += -DPYTHON_EXECUTABLE=${PYTHON_EXECUTABLE}
endif
-# Check if the microRTPS agent is to be built
-ifdef BUILD_MICRORTPS_AGENT
- CMAKE_ARGS += -DBUILD_MICRORTPS_AGENT=ON
-endif
-
# Functions
# --------------------------------------------------------------------
# describe how to build a cmake config
@@ -251,7 +246,7 @@ endef
# Other targets
# --------------------------------------------------------------------
-.PHONY: qgc_firmware px4fmu_firmware misc_qgc_extra_firmware check_rtps
+.PHONY: qgc_firmware px4fmu_firmware misc_qgc_extra_firmware
# QGroundControl flashable NuttX firmware
qgc_firmware: px4fmu_firmware misc_qgc_extra_firmware
@@ -276,15 +271,7 @@ misc_qgc_extra_firmware: \
check_airmind_mindpx-v2_default \
sizes
-# builds with RTPS
-check_rtps: \
- check_px4_fmu-v3_rtps \
- check_px4_fmu-v4_rtps \
- check_px4_fmu-v4pro_rtps \
- check_px4_sitl_rtps \
- sizes
-
-.PHONY: sizes check quick_check check_rtps uorb_graphs
+.PHONY: sizes check quick_check uorb_graphs
sizes:
@-find build -name *.elf -type f | xargs size 2> /dev/null || :
@@ -479,7 +466,7 @@ clang-tidy-quiet: px4_sitl_default-clang
# TODO: Fix cppcheck errors then try --enable=warning,performance,portability,style,unusedFunction or --enable=all
cppcheck: px4_sitl_default
@mkdir -p "$(SRC_DIR)"/build/cppcheck
- @cppcheck -i"$(SRC_DIR)"/src/examples --enable=performance --std=c++14 --std=c99 --std=posix --project="$(SRC_DIR)"/build/px4_sitl_default/compile_commands.json --xml-version=2 2> "$(SRC_DIR)"/build/cppcheck/cppcheck-result.xml > /dev/null
+ @cppcheck -i"$(SRC_DIR)"/src/examples --enable=performance --std=c++17 --std=c99 --std=posix --project="$(SRC_DIR)"/build/px4_sitl_default/compile_commands.json --xml-version=2 2> "$(SRC_DIR)"/build/cppcheck/cppcheck-result.xml > /dev/null
@cppcheck-htmlreport --source-encoding=ascii --file="$(SRC_DIR)"/build/cppcheck/cppcheck-result.xml --report-dir="$(SRC_DIR)"/build/cppcheck --source-dir="$(SRC_DIR)"/src/
shellcheck_all:
@@ -559,12 +546,3 @@ ifneq ($(ROS2_WS_DIR),)
else
ROS2_WS_DIR := ~/colcon_ws
endif
-
-update_ros2_bridge:
- @Tools/update_px4_ros2_bridge.sh --ws_dir ${ROS2_WS_DIR} --all
-
-update_px4_ros_com:
- @Tools/update_px4_ros2_bridge.sh --ws_dir ${ROS2_WS_DIR} --px4_ros_com
-
-update_px4_msgs:
- @Tools/update_px4_ros2_bridge.sh --ws_dir ${ROS2_WS_DIR} --px4_msgs
diff --git a/ROMFS/px4fmu_common/init.d-posix/CMakeLists.txt b/ROMFS/px4fmu_common/init.d-posix/CMakeLists.txt
index 419ed0ed18..1ba7ccde27 100644
--- a/ROMFS/px4fmu_common/init.d-posix/CMakeLists.txt
+++ b/ROMFS/px4fmu_common/init.d-posix/CMakeLists.txt
@@ -36,7 +36,6 @@ add_subdirectory(airframes)
px4_add_romfs_files(
px4-rc.mavlink
px4-rc.params
- px4-rc.rtps
px4-rc.simulator
rc.replay
rcS
diff --git a/ROMFS/px4fmu_common/init.d-posix/px4-rc.rtps b/ROMFS/px4fmu_common/init.d-posix/px4-rc.rtps
deleted file mode 100644
index d3cfa4f817..0000000000
--- a/ROMFS/px4fmu_common/init.d-posix/px4-rc.rtps
+++ /dev/null
@@ -1,4 +0,0 @@
-#!/bin/sh
-# shellcheck disable=SC2154
-
-micrortps_client start -t UDP -r $((2019+2*px4_instance)) -s $((2020+2*px4_instance))
diff --git a/ROMFS/px4fmu_common/init.d-posix/rcS b/ROMFS/px4fmu_common/init.d-posix/rcS
index 13ff820f4d..e45ec6bdaa 100644
--- a/ROMFS/px4fmu_common/init.d-posix/rcS
+++ b/ROMFS/px4fmu_common/init.d-posix/rcS
@@ -226,12 +226,6 @@ sensors start
commander start
navigator start
-# Try to start the micrortps_client with UDP transport if module exists
-if px4-micrortps_client status > /dev/null 2>&1
-then
- . px4-rc.rtps
-fi
-
if param greater -s MNT_MODE_IN -1
then
gimbal start
diff --git a/Tools/astyle/files_to_check_code_style.sh b/Tools/astyle/files_to_check_code_style.sh
index 963c8a51cf..834ed5a2ec 100755
--- a/Tools/astyle/files_to_check_code_style.sh
+++ b/Tools/astyle/files_to_check_code_style.sh
@@ -8,7 +8,6 @@ if [ $# -gt 0 ]; then
fi
exec find boards msg src platforms test \
- -path msg/templates/urtps -prune -o \
-path platforms/nuttx/NuttX -prune -o \
-path platforms/qurt/dspal -prune -o \
-path src/drivers/uavcan/libuavcan -prune -o \
@@ -21,8 +20,6 @@ exec find boards msg src platforms test \
-path src/modules/ekf2/EKF -prune -o \
-path src/modules/gyro_fft/CMSIS_5 -prune -o \
-path src/modules/mavlink/mavlink -prune -o \
- -path src/modules/micrortps_bridge/micro-CDR -prune -o \
- -path src/modules/micrortps_bridge/microRTPS_client -prune -o \
-path test/mavsdk_tests/catch2 -prune -o \
-path src/lib/crypto/monocypher -prune -o \
-path src/lib/crypto/libtomcrypt -prune -o \
diff --git a/Tools/build_micrortps_agent.sh b/Tools/build_micrortps_agent.sh
deleted file mode 100755
index 6d45eaeb41..0000000000
--- a/Tools/build_micrortps_agent.sh
+++ /dev/null
@@ -1,15 +0,0 @@
-#!/usr/bin/env bash
-set -e
-
-SCRIPT_DIR=$0
-if [[ ${SCRIPT_DIR:0:1} != '/' ]]; then
- SCRIPT_DIR=$(dirname $(realpath -s "$PWD/$0"))
-fi
-
-PX4_DIR=$(cd "$(dirname $(dirname $SCRIPT_DIR))" && pwd)
-
-if [ -d $PX4_DIR/build/*_rtps ]; then
- cd $PX4_DIR/build/*_rtps/src/modules/micrortps_bridge/micrortps_agent/
- cmake -Bbuild
- cmake --build build -j$(nproc --all)
-fi
diff --git a/Tools/kconfig/cmake_kconfig_lut.txt b/Tools/kconfig/cmake_kconfig_lut.txt
index b9298e75dc..c66646a4ef 100644
--- a/Tools/kconfig/cmake_kconfig_lut.txt
+++ b/Tools/kconfig/cmake_kconfig_lut.txt
@@ -93,7 +93,6 @@ pca9685_pwm_out,CONFIG_DRIVERS_PCA9685_PWM_OUT=y
power_monitor/ina226,CONFIG_DRIVERS_POWER_MONITOR_INA226=y
power_monitor/voxlpm,CONFIG_DRIVERS_POWER_MONITOR_VOXLPM=y
pps_capture,CONFIG_DRIVERS_PPS_CAPTURE=y
-protocol_splitter,CONFIG_DRIVERS_PROTOCOL_SPLITTER=y
pwm_input,CONFIG_DRIVERS_PWM_INPUT=y
pwm_out_sim,CONFIG_DRIVERS_PWM_OUT_SIM=y
pwm_out,CONFIG_DRIVERS_PWM_OUT=y
@@ -138,7 +137,6 @@ mc_att_control,CONFIG_MODULES_MC_ATT_CONTROL=y
mc_hover_thrust_estimator,CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y
mc_pos_control,CONFIG_MODULES_MC_POS_CONTROL=y
mc_rate_control,CONFIG_MODULES_MC_RATE_CONTROL=y
-micrortps_bridge,CONFIG_MODULES_MICRORTPS_BRIDGE=y
navigator,CONFIG_MODULES_NAVIGATOR=y
px4iofirmware,CONFIG_MODULES_PX4IOFIRMWARE=y
rc_update,CONFIG_MODULES_RC_UPDATE=y
diff --git a/Tools/px4_developer.mk.example b/Tools/px4_developer.mk.example
deleted file mode 100644
index 54c3024831..0000000000
--- a/Tools/px4_developer.mk.example
+++ /dev/null
@@ -1,5 +0,0 @@
-$(info px4_developer.mk inclded)
-ifeq ($(UAVCAN_BL_OVERRIDE),y)
-$(info ************************** UAVCAN BOOT LOADERS built for In place application Debugging ***************************************)
-export EXTRAFLAGS +=-DDEBUG_APPLICATION_INPLACE
-endif
\ No newline at end of file
diff --git a/Tools/setup/arch.sh b/Tools/setup/arch.sh
index 83bc225d49..f27d7e756f 100755
--- a/Tools/setup/arch.sh
+++ b/Tools/setup/arch.sh
@@ -9,8 +9,6 @@
## - jMAVSim simulator (omit with arg: --no-sim-tools)
## - Gazebo simulator (not by default, use --gazebo)
##
-## Not Installs:
-## - FastRTPS and FastCDR
INSTALL_NUTTX="true"
INSTALL_SIM="true"
@@ -122,7 +120,7 @@ if [[ $INSTALL_SIM == "true" ]]; then
echo
echo "Installing PX4 simulation dependencies"
- # java (jmavsim or fastrtps)
+ # java (jmavsim)
sudo pacman -S --noconfirm --needed \
ant \
jdk-openjdk \
diff --git a/Tools/setup/ubuntu.sh b/Tools/setup/ubuntu.sh
index 852f38c94c..abc6492724 100755
--- a/Tools/setup/ubuntu.sh
+++ b/Tools/setup/ubuntu.sh
@@ -10,8 +10,6 @@ set -e
## - NuttX toolchain (omit with arg: --no-nuttx)
## - jMAVSim and Gazebo9 simulator (omit with arg: --no-sim-tools)
##
-## Not Installs:
-## - FastRTPS and FastCDR
INSTALL_NUTTX="true"
INSTALL_SIM="true"
@@ -208,7 +206,7 @@ if [[ $INSTALL_SIM == "true" ]]; then
java_version=14
gazebo_version=11
fi
- # Java (jmavsim or fastrtps)
+ # Java (jmavsim)
sudo DEBIAN_FRONTEND=noninteractive apt-get -y --quiet --no-install-recommends install \
ant \
openjdk-$java_version-jre \
diff --git a/Tools/update_px4_ros2_bridge.sh b/Tools/update_px4_ros2_bridge.sh
deleted file mode 100755
index 58ebca5b7c..0000000000
--- a/Tools/update_px4_ros2_bridge.sh
+++ /dev/null
@@ -1,135 +0,0 @@
-#!/usr/bin/env bash
-set -e
-
-agent_template_files_updated=0
-code_generator_files_updated=0
-
-# parse help argument
-if [[ $1 == "-h" ]] || [[ $1 == "--help" ]]; then
- echo -e "Usage: update_px4_ros2_bridge.bash [options...] \t This script allows to update px4_ros_com and px4_msgs in a specified directory." >&2
- echo
- echo -e "\t--ws_dir \t\t Location of the ament/colcon workspace. Default: $HOME/colcon_ws."
- echo -e "\t--px4_ros_com \t\t Updates px4_ros_com microRTPS agent code generation and templates."
- echo -e "\t--px4_msgs \t\t Updates px4_msgs messages definition files."
- echo -e "\t--all \t\t Updates both px4_ros_com and px4_msgs."
- echo
- exit 0
-fi
-
-# parse the arguments
-while [ $# -gt 0 ]; do
- if [[ $1 == *"--"* ]]; then
- v="${1/--/}"
- if [ ! -z $2 ]; then
- declare $v="$2"
- else
- declare $v=1
- fi
- fi
- shift
-done
-
-# get script directory
-SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
-
-# get PX4-Autopilot directory
-PX4_DIR=$(cd "$(dirname "$SCRIPT_DIR")" && pwd)
-
-function compare_and_update () {
- cmp -s "$1" "$2"
- if [ $? -eq 1 ]; then
- cp "$1" "$2"
- return 0
- fi
-
- return 1;
-}
-
-# update microRTPS agent code generators / helpers
-function update_agent_code {
- declare -a templates=( \
- "microRTPS_agent.cpp.em" \
- "microRTPS_timesync.cpp.em" \
- "microRTPS_timesync.h.em" \
- "microRTPS_transport.cpp" \
- "microRTPS_transport.h" \
- "Publisher.cpp.em" \
- "Publisher.h.em" \
- "Subscriber.cpp.em" \
- "Subscriber.h.em" \
- "RtpsTopics.cpp.em" \
- "RtpsTopics.h.em" \
- )
-
- for file in ${templates[@]}; do
- compare_and_update "$PX4_DIR/msg/templates/urtps/$file" "$ws_dir/src/px4_ros_com/templates/$file" \
- && echo -e "--\t\t- '$ws_dir/src/px4_ros_com/templates/$file' updated" && ((agent_template_files_updated+=1))
- done
- if [ $agent_template_files_updated -eq 0 ]; then
- echo -e "--\t\t- No template files updated"
- elif [ $agent_template_files_updated -eq 1 ]; then
- echo -e "--\t\t - 1 template file updated"
- else
- echo -e "--\t\t - $agent_template_files_updated template files updated"
- fi
-}
-
-# update microRTPS agent code templates
-function update_agent_templates {
- declare -a code_generators=( \
- "uorb_rtps_classifier.py" \
- "generate_microRTPS_bridge.py" \
- "px_generate_uorb_topic_files.py" \
- )
- for file in ${code_generators[@]}; do
- compare_and_update "$PX4_DIR/msg/tools/$file $ws_dir/src/px4_ros_com/scripts/$file" \
- && echo -e "--\t\t- '$ws_dir/src/px4_ros_com/scripts/$file' updated" && ((code_generator_files_updated+=1))
- done
- if [ $code_generator_files_updated -eq 0 ]; then
- echo -e "--\t\t- No code generators / helpers files updated"
- elif [ $code_generator_files_updated -eq 1 ]; then
- echo -e "--\t\t - 1 code generator / helper file updated"
- else
- echo -e "--\t\t - $code_generator_files_updated code generator / helper files updated"
- fi
-}
-
-# update px4_ros_com files
-function update_px4_ros_com {
- python3 $PX4_DIR/msg/tools/uorb_to_ros_urtps_topics.py -i $PX4_DIR/msg/tools/urtps_bridge_topics.yaml -o $ws_dir/src/px4_ros_com/templates/urtps_bridge_topics.yaml
- echo -e "--------------- \033[1mmicroRTPS agent code generation and templates update\033[0m ----------------"
- echo "-------------------------------------------------------------------------------------------------------"
- update_agent_code
- update_agent_templates
- return 0
-}
-
-# function to update px4_msgs
-function update_px4_msgs {
- find "$ws_dir/src/px4_msgs/msg/" -maxdepth 1 -type f -delete
- python3 $PX4_DIR/msg/tools/uorb_to_ros_msgs.py $PX4_DIR/msg/ $ws_dir/src/px4_msgs/msg/
-}
-
-# decisor
-echo "-------------------------------------------------------------------------------------------------------"
-if [ -d "${ws_dir}" ]; then
- ws_dir=$(cd "$ws_dir" && pwd)
- if [ ! -z ${all} ]; then
- update_px4_ros_com
- echo "-------------------------------------------------------------------------------------------------------"
- update_px4_msgs
- elif [ ! -z ${px4_ros_com} ]; then
- update_px4_ros_com
- echo "-------------------------------------------------------------------------------------------------------"
- elif [ ! -z ${px4_msgs} ]; then
- update_px4_msgs
- fi
- echo -e "-------------------------------- \033[0;32mUpdate successful!\033[0m ---------------------------------"
- echo "-------------------------------------------------------------------------------------------------------"
- exit 0
-else
- echo -e "-- \033[0;31mWorkspace directory doesn't exist...\033[0m"
- echo -e "---------------------------------- \033[0;31mUpdate failed!\033[0m -----------------------------------"
- echo "-------------------------------------------------------------------------------------------------------"
- exit $ERRCODE
-fi
diff --git a/boards/bitcraze/crazyflie/syslink/CMakeLists.txt b/boards/bitcraze/crazyflie/syslink/CMakeLists.txt
index ebf6c04c08..f89269dbc8 100644
--- a/boards/bitcraze/crazyflie/syslink/CMakeLists.txt
+++ b/boards/bitcraze/crazyflie/syslink/CMakeLists.txt
@@ -44,4 +44,6 @@ px4_add_module(
syslink.c
DEPENDS
battery
+ SUBSCRIPTIONS
+ "px4::msg::BatteryStatus /battery_status"
)
diff --git a/boards/cuav/nora/extras/cuav_nora_bootloader.bin b/boards/cuav/nora/extras/cuav_nora_bootloader.bin
index 77449064c7..3ba1922daa 100755
Binary files a/boards/cuav/nora/extras/cuav_nora_bootloader.bin and b/boards/cuav/nora/extras/cuav_nora_bootloader.bin differ
diff --git a/boards/cuav/x7pro/extras/cuav_x7pro_bootloader.bin b/boards/cuav/x7pro/extras/cuav_x7pro_bootloader.bin
index a27ec0069f..ade6662095 100755
Binary files a/boards/cuav/x7pro/extras/cuav_x7pro_bootloader.bin and b/boards/cuav/x7pro/extras/cuav_x7pro_bootloader.bin differ
diff --git a/boards/cubepilot/cubeorange/extras/cubepilot_cubeorange_bootloader.bin b/boards/cubepilot/cubeorange/extras/cubepilot_cubeorange_bootloader.bin
index a6829bca73..9dcd207a23 100755
Binary files a/boards/cubepilot/cubeorange/extras/cubepilot_cubeorange_bootloader.bin and b/boards/cubepilot/cubeorange/extras/cubepilot_cubeorange_bootloader.bin differ
diff --git a/boards/cubepilot/cubeorange/extras/cubepilot_io-v2_default.bin b/boards/cubepilot/cubeorange/extras/cubepilot_io-v2_default.bin
index 0179a993e6..93a1e13448 100755
Binary files a/boards/cubepilot/cubeorange/extras/cubepilot_io-v2_default.bin and b/boards/cubepilot/cubeorange/extras/cubepilot_io-v2_default.bin differ
diff --git a/boards/cubepilot/cubeyellow/extras/cubepilot_io-v2_default.bin b/boards/cubepilot/cubeyellow/extras/cubepilot_io-v2_default.bin
index 0179a993e6..93a1e13448 100755
Binary files a/boards/cubepilot/cubeyellow/extras/cubepilot_io-v2_default.bin and b/boards/cubepilot/cubeyellow/extras/cubepilot_io-v2_default.bin differ
diff --git a/boards/freefly/can-rtk-gps/canbootloader.px4board b/boards/freefly/can-rtk-gps/canbootloader.px4board
index b0fd876605..cc9f7769c1 100644
--- a/boards/freefly/can-rtk-gps/canbootloader.px4board
+++ b/boards/freefly/can-rtk-gps/canbootloader.px4board
@@ -3,4 +3,3 @@ CONFIG_BOARD_ARCHITECTURE="cortex-m7"
CONFIG_BOARD_ROMFSROOT=""
CONFIG_BOARD_CONSTRAINED_MEMORY=y
CONFIG_DRIVERS_BOOTLOADERS=y
-CONFIG_DRIVERS_LIGHTS_RGBLED_NCP5623C=y
diff --git a/boards/freefly/can-rtk-gps/src/CMakeLists.txt b/boards/freefly/can-rtk-gps/src/CMakeLists.txt
index 246b51200a..19094576ea 100644
--- a/boards/freefly/can-rtk-gps/src/CMakeLists.txt
+++ b/boards/freefly/can-rtk-gps/src/CMakeLists.txt
@@ -44,6 +44,8 @@ if("${PX4_BOARD_LABEL}" STREQUAL "canbootloader")
nuttx_arch
nuttx_drivers
canbootloader
+ drivers__device
+ px4_platform
)
target_include_directories(drivers_board PRIVATE ${PX4_SOURCE_DIR}/platforms/nuttx/src/canbootloader)
diff --git a/boards/holybro/durandal-v1/extras/holybro_durandal-v1_bootloader.bin b/boards/holybro/durandal-v1/extras/holybro_durandal-v1_bootloader.bin
index 4f66190c07..59c147b807 100755
Binary files a/boards/holybro/durandal-v1/extras/holybro_durandal-v1_bootloader.bin and b/boards/holybro/durandal-v1/extras/holybro_durandal-v1_bootloader.bin differ
diff --git a/boards/holybro/durandal-v1/extras/px4_io-v2_default.bin b/boards/holybro/durandal-v1/extras/px4_io-v2_default.bin
index cef251c5f5..a91611df69 100755
Binary files a/boards/holybro/durandal-v1/extras/px4_io-v2_default.bin and b/boards/holybro/durandal-v1/extras/px4_io-v2_default.bin differ
diff --git a/boards/holybro/pix32v5/default.px4board b/boards/holybro/pix32v5/default.px4board
index 4d09a3a008..1b61c0351e 100644
--- a/boards/holybro/pix32v5/default.px4board
+++ b/boards/holybro/pix32v5/default.px4board
@@ -1,6 +1,5 @@
CONFIG_BOARD_TOOLCHAIN="arm-none-eabi"
CONFIG_BOARD_ARCHITECTURE="cortex-m7"
-CONFIG_BOARD_IO="px4_io-v2_default"
CONFIG_BOARD_SERIAL_GPS1="/dev/ttyS0"
CONFIG_BOARD_SERIAL_TEL1="/dev/ttyS1"
CONFIG_BOARD_SERIAL_TEL2="/dev/ttyS2"
@@ -47,6 +46,7 @@ CONFIG_MODULES_ATTITUDE_ESTIMATOR_Q=y
CONFIG_MODULES_BATTERY_STATUS=y
CONFIG_MODULES_CAMERA_FEEDBACK=y
CONFIG_MODULES_COMMANDER=y
+CONFIG_MODULES_CONTROL_ALLOCATOR=y
CONFIG_MODULES_DATAMAN=y
CONFIG_MODULES_EKF2=y
CONFIG_MODULES_ESC_BATTERY=y
@@ -55,6 +55,7 @@ CONFIG_MODULES_FLIGHT_MODE_MANAGER=y
CONFIG_MODULES_FW_ATT_CONTROL=y
CONFIG_MODULES_FW_AUTOTUNE_ATTITUDE_CONTROL=y
CONFIG_MODULES_FW_POS_CONTROL_L1=y
+CONFIG_MODULES_GIMBAL=y
CONFIG_MODULES_GYRO_CALIBRATION=y
CONFIG_MODULES_GYRO_FFT=y
CONFIG_MODULES_LAND_DETECTOR=y
@@ -70,7 +71,6 @@ CONFIG_MODULES_MC_AUTOTUNE_ATTITUDE_CONTROL=y
CONFIG_MODULES_MC_HOVER_THRUST_ESTIMATOR=y
CONFIG_MODULES_MC_POS_CONTROL=y
CONFIG_MODULES_MC_RATE_CONTROL=y
-CONFIG_MODULES_CONTROL_ALLOCATOR=y
CONFIG_MODULES_NAVIGATOR=y
CONFIG_MODULES_RC_UPDATE=y
CONFIG_MODULES_ROVER_POS_CONTROL=y
@@ -79,10 +79,9 @@ CONFIG_MODULES_SIH=y
CONFIG_MODULES_TEMPERATURE_COMPENSATION=y
CONFIG_MODULES_UUV_ATT_CONTROL=y
CONFIG_MODULES_UUV_POS_CONTROL=y
-CONFIG_MODULES_GIMBAL=y
CONFIG_MODULES_VTOL_ATT_CONTROL=y
-CONFIG_SYSTEMCMDS_BL_UPDATE=y
CONFIG_SYSTEMCMDS_ACTUATOR_TEST=y
+CONFIG_SYSTEMCMDS_BL_UPDATE=y
CONFIG_SYSTEMCMDS_DMESG=y
CONFIG_SYSTEMCMDS_DUMPFILE=y
CONFIG_SYSTEMCMDS_GPIO=y
diff --git a/boards/holybro/pix32v5/extras/px4_io-v2_default.bin b/boards/holybro/pix32v5/extras/px4_io-v2_default.bin
index cef251c5f5..a91611df69 100755
Binary files a/boards/holybro/pix32v5/extras/px4_io-v2_default.bin and b/boards/holybro/pix32v5/extras/px4_io-v2_default.bin differ
diff --git a/boards/matek/h743-slim/extras/matek_h743-slim_bootloader.bin b/boards/matek/h743-slim/extras/matek_h743-slim_bootloader.bin
index ae95aca31b..68ced22ee7 100755
Binary files a/boards/matek/h743-slim/extras/matek_h743-slim_bootloader.bin and b/boards/matek/h743-slim/extras/matek_h743-slim_bootloader.bin differ
diff --git a/boards/modalai/fc-v1/rtps.px4board b/boards/modalai/fc-v1/rtps.px4board
deleted file mode 100644
index 81e62c7825..0000000000
--- a/boards/modalai/fc-v1/rtps.px4board
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_MODULES_MICRORTPS_BRIDGE=y
diff --git a/boards/modalai/fc-v2/extras/modalai_fc-v2_bootloader.bin b/boards/modalai/fc-v2/extras/modalai_fc-v2_bootloader.bin
index 6608f5916d..21c40365e2 100755
Binary files a/boards/modalai/fc-v2/extras/modalai_fc-v2_bootloader.bin and b/boards/modalai/fc-v2/extras/modalai_fc-v2_bootloader.bin differ
diff --git a/boards/mro/ctrl-zero-h7-oem/extras/mro_ctrl-zero-h7-oem_bootloader.bin b/boards/mro/ctrl-zero-h7-oem/extras/mro_ctrl-zero-h7-oem_bootloader.bin
index 92343c05a9..e2b72c5561 100755
Binary files a/boards/mro/ctrl-zero-h7-oem/extras/mro_ctrl-zero-h7-oem_bootloader.bin and b/boards/mro/ctrl-zero-h7-oem/extras/mro_ctrl-zero-h7-oem_bootloader.bin differ
diff --git a/boards/mro/ctrl-zero-h7-oem/rtps.px4board b/boards/mro/ctrl-zero-h7-oem/rtps.px4board
deleted file mode 100644
index 81e62c7825..0000000000
--- a/boards/mro/ctrl-zero-h7-oem/rtps.px4board
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_MODULES_MICRORTPS_BRIDGE=y
diff --git a/boards/mro/ctrl-zero-h7/extras/mro_ctrl-zero-h7_bootloader.bin b/boards/mro/ctrl-zero-h7/extras/mro_ctrl-zero-h7_bootloader.bin
index fb0e87c74b..640eb260f6 100755
Binary files a/boards/mro/ctrl-zero-h7/extras/mro_ctrl-zero-h7_bootloader.bin and b/boards/mro/ctrl-zero-h7/extras/mro_ctrl-zero-h7_bootloader.bin differ
diff --git a/boards/mro/ctrl-zero-h7/rtps.px4board b/boards/mro/ctrl-zero-h7/rtps.px4board
deleted file mode 100644
index 81e62c7825..0000000000
--- a/boards/mro/ctrl-zero-h7/rtps.px4board
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_MODULES_MICRORTPS_BRIDGE=y
diff --git a/boards/mro/pixracerpro/extras/mro_pixracerpro_bootloader.bin b/boards/mro/pixracerpro/extras/mro_pixracerpro_bootloader.bin
index abac8184b3..a2d33fcba7 100755
Binary files a/boards/mro/pixracerpro/extras/mro_pixracerpro_bootloader.bin and b/boards/mro/pixracerpro/extras/mro_pixracerpro_bootloader.bin differ
diff --git a/boards/mro/pixracerpro/rtps.px4board b/boards/mro/pixracerpro/rtps.px4board
deleted file mode 100644
index 81e62c7825..0000000000
--- a/boards/mro/pixracerpro/rtps.px4board
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_MODULES_MICRORTPS_BRIDGE=y
diff --git a/boards/mro/x21-777/extras/px4_io-v2_default.bin b/boards/mro/x21-777/extras/px4_io-v2_default.bin
index cef251c5f5..a91611df69 100755
Binary files a/boards/mro/x21-777/extras/px4_io-v2_default.bin and b/boards/mro/x21-777/extras/px4_io-v2_default.bin differ
diff --git a/boards/nxp/fmuk66-e/rtps.px4board b/boards/nxp/fmuk66-e/rtps.px4board
deleted file mode 100644
index 81e62c7825..0000000000
--- a/boards/nxp/fmuk66-e/rtps.px4board
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_MODULES_MICRORTPS_BRIDGE=y
diff --git a/boards/nxp/fmuk66-v3/rtps.px4board b/boards/nxp/fmuk66-v3/rtps.px4board
deleted file mode 100644
index 81e62c7825..0000000000
--- a/boards/nxp/fmuk66-v3/rtps.px4board
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_MODULES_MICRORTPS_BRIDGE=y
diff --git a/boards/px4/fmu-v2/extras/px4_io-v2_default.bin b/boards/px4/fmu-v2/extras/px4_io-v2_default.bin
index cef251c5f5..a91611df69 100755
Binary files a/boards/px4/fmu-v2/extras/px4_io-v2_default.bin and b/boards/px4/fmu-v2/extras/px4_io-v2_default.bin differ
diff --git a/boards/px4/fmu-v3/extras/px4_io-v2_default.bin b/boards/px4/fmu-v3/extras/px4_io-v2_default.bin
index cef251c5f5..a91611df69 100755
Binary files a/boards/px4/fmu-v3/extras/px4_io-v2_default.bin and b/boards/px4/fmu-v3/extras/px4_io-v2_default.bin differ
diff --git a/boards/px4/fmu-v4pro/extras/px4_io-v2_default.bin b/boards/px4/fmu-v4pro/extras/px4_io-v2_default.bin
index cef251c5f5..a91611df69 100755
Binary files a/boards/px4/fmu-v4pro/extras/px4_io-v2_default.bin and b/boards/px4/fmu-v4pro/extras/px4_io-v2_default.bin differ
diff --git a/boards/px4/fmu-v5/default.px4board b/boards/px4/fmu-v5/default.px4board
index 86f3e739ce..208a1169f9 100644
--- a/boards/px4/fmu-v5/default.px4board
+++ b/boards/px4/fmu-v5/default.px4board
@@ -12,10 +12,10 @@ CONFIG_DRIVERS_CAMERA_CAPTURE=y
CONFIG_DRIVERS_CAMERA_TRIGGER=y
CONFIG_COMMON_DIFFERENTIAL_PRESSURE=y
CONFIG_COMMON_DISTANCE_SENSOR=y
-CONFIG_COMMON_HYGROMETERS=y
CONFIG_DRIVERS_DSHOT=y
CONFIG_DRIVERS_GPS=y
CONFIG_DRIVERS_HEATER=y
+CONFIG_COMMON_HYGROMETERS=y
CONFIG_DRIVERS_IMU_ANALOG_DEVICES_ADIS16448=y
CONFIG_DRIVERS_IMU_BOSCH_BMI055=y
CONFIG_DRIVERS_IMU_INVENSENSE_ICM20602=y
@@ -57,6 +57,7 @@ CONFIG_MODULES_FLIGHT_MODE_MANAGER=y
CONFIG_MODULES_FW_ATT_CONTROL=y
CONFIG_MODULES_FW_AUTOTUNE_ATTITUDE_CONTROL=y
CONFIG_MODULES_FW_POS_CONTROL_L1=y
+CONFIG_MODULES_GIMBAL=y
CONFIG_MODULES_GYRO_CALIBRATION=y
CONFIG_MODULES_GYRO_FFT=y
CONFIG_MODULES_LAND_DETECTOR=y
@@ -80,7 +81,6 @@ CONFIG_MODULES_SIH=y
CONFIG_MODULES_TEMPERATURE_COMPENSATION=y
CONFIG_MODULES_UUV_ATT_CONTROL=y
CONFIG_MODULES_UUV_POS_CONTROL=y
-CONFIG_MODULES_GIMBAL=y
CONFIG_MODULES_VTOL_ATT_CONTROL=y
CONFIG_SYSTEMCMDS_ACTUATOR_TEST=y
CONFIG_SYSTEMCMDS_BL_UPDATE=y
diff --git a/boards/px4/fmu-v5/extras/px4_io-v2_default.bin b/boards/px4/fmu-v5/extras/px4_io-v2_default.bin
index cef251c5f5..a91611df69 100755
Binary files a/boards/px4/fmu-v5/extras/px4_io-v2_default.bin and b/boards/px4/fmu-v5/extras/px4_io-v2_default.bin differ
diff --git a/boards/px4/fmu-v5/rtps.px4board b/boards/px4/fmu-v5/rtps.px4board
deleted file mode 100644
index e77de930f2..0000000000
--- a/boards/px4/fmu-v5/rtps.px4board
+++ /dev/null
@@ -1,3 +0,0 @@
-CONFIG_DRIVERS_HEATER=n
-CONFIG_DRIVERS_OSD=n
-CONFIG_MODULES_MICRORTPS_BRIDGE=y
diff --git a/boards/px4/fmu-v5/stackcheck.px4board b/boards/px4/fmu-v5/stackcheck.px4board
index 8b8db4bf0e..a97c81ddf2 100644
--- a/boards/px4/fmu-v5/stackcheck.px4board
+++ b/boards/px4/fmu-v5/stackcheck.px4board
@@ -23,6 +23,7 @@ CONFIG_EXAMPLES_FAKE_GPS=n
CONFIG_MODULES_ATTITUDE_ESTIMATOR_Q=n
CONFIG_MODULES_CAMERA_FEEDBACK=n
CONFIG_MODULES_ESC_BATTERY=n
+CONFIG_MODULES_EVENTS=n
CONFIG_MODULES_GIMBAL=n
CONFIG_MODULES_GYRO_CALIBRATION=n
CONFIG_MODULES_GYRO_FFT=n
@@ -31,6 +32,9 @@ CONFIG_MODULES_LOCAL_POSITION_ESTIMATOR=n
CONFIG_MODULES_ROVER_POS_CONTROL=n
CONFIG_MODULES_SIH=n
CONFIG_MODULES_TEMPERATURE_COMPENSATION=n
+CONFIG_SYSTEMCMDS_DUMPFILE=n
+CONFIG_SYSTEMCMDS_GPIO=n
+CONFIG_SYSTEMCMDS_REFLECT=n
CONFIG_SYSTEMCMDS_SERIAL_TEST=n
CONFIG_BOARD_CONSTRAINED_FLASH=y
CONFIG_BOARD_TESTING=y
diff --git a/boards/px4/fmu-v5x/extras/px4_io-v2_default.bin b/boards/px4/fmu-v5x/extras/px4_io-v2_default.bin
index cef251c5f5..a91611df69 100755
Binary files a/boards/px4/fmu-v5x/extras/px4_io-v2_default.bin and b/boards/px4/fmu-v5x/extras/px4_io-v2_default.bin differ
diff --git a/boards/px4/fmu-v5x/rtps.px4board b/boards/px4/fmu-v5x/rtps.px4board
deleted file mode 100644
index 81e62c7825..0000000000
--- a/boards/px4/fmu-v5x/rtps.px4board
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_MODULES_MICRORTPS_BRIDGE=y
diff --git a/boards/px4/fmu-v6u/extras/px4_fmu-v6u_bootloader.bin b/boards/px4/fmu-v6u/extras/px4_fmu-v6u_bootloader.bin
index 37aa34e121..5f7be8f7d7 100755
Binary files a/boards/px4/fmu-v6u/extras/px4_fmu-v6u_bootloader.bin and b/boards/px4/fmu-v6u/extras/px4_fmu-v6u_bootloader.bin differ
diff --git a/boards/px4/fmu-v6x/extras/px4_io-v2_default.bin b/boards/px4/fmu-v6x/extras/px4_io-v2_default.bin
index cef251c5f5..a91611df69 100755
Binary files a/boards/px4/fmu-v6x/extras/px4_io-v2_default.bin and b/boards/px4/fmu-v6x/extras/px4_io-v2_default.bin differ
diff --git a/boards/px4/ros2/default.px4board b/boards/px4/ros2/default.px4board
new file mode 100644
index 0000000000..a9c5b91a14
--- /dev/null
+++ b/boards/px4/ros2/default.px4board
@@ -0,0 +1 @@
+CONFIG_PLATFORM_ROS2=y
diff --git a/src/drivers/protocol_splitter/CMakeLists.txt b/boards/px4/ros2/src/CMakeLists.txt
similarity index 90%
rename from src/drivers/protocol_splitter/CMakeLists.txt
rename to boards/px4/ros2/src/CMakeLists.txt
index 8e09f1b106..22e202d4e4 100644
--- a/src/drivers/protocol_splitter/CMakeLists.txt
+++ b/boards/px4/ros2/src/CMakeLists.txt
@@ -1,6 +1,6 @@
############################################################################
#
-# Copyright (c) 2015 PX4 Development Team. All rights reserved.
+# Copyright (c) 2021 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
@@ -30,10 +30,7 @@
# POSSIBILITY OF SUCH DAMAGE.
#
############################################################################
-px4_add_module(
- MODULE drivers__protocol_splitter
- MAIN protocol_splitter
- SRCS
- protocol_splitter.cpp
- DEPENDS
- )
+
+add_library(drivers_board
+ init.cpp
+)
diff --git a/src/lib/systemlib/conversions.c b/boards/px4/ros2/src/board_config.h
similarity index 79%
rename from src/lib/systemlib/conversions.c
rename to boards/px4/ros2/src/board_config.h
index 94ff326e80..1f6b97375c 100644
--- a/src/lib/systemlib/conversions.c
+++ b/boards/px4/ros2/src/board_config.h
@@ -1,7 +1,6 @@
/****************************************************************************
*
- * Copyright (C) 2012 PX4 Development Team. All rights reserved.
- * Author: @author Lorenz Meier
+ * Copyright (c) 2021 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
@@ -33,25 +32,19 @@
****************************************************************************/
/**
- * @file conversions.c
- * Implementation of commonly used conversions.
+ * @file board_config.h
+ *
+ * SITL internal definitions
*/
-#include
-#include
+#pragma once
-#include "conversions.h"
+#define BOARD_OVERRIDE_UUID "SIMULATIONID0000" // must be of length 16
+#define PX4_SOC_ARCH_ID PX4_SOC_ARCH_ID_SITL
-int16_t
-int16_t_from_bytes(uint8_t bytes[])
-{
- union {
- uint8_t b[2];
- int16_t w;
- } u;
+#define BOARD_HAS_POWER_CONTROL 1
- u.b[1] = bytes[0];
- u.b[0] = bytes[1];
+#define BOARD_NUMBER_BRICKS 0
- return u.w;
-}
+#include
+#include
diff --git a/msg/tools/__init__.py b/boards/px4/ros2/src/init.cpp
similarity index 100%
rename from msg/tools/__init__.py
rename to boards/px4/ros2/src/init.cpp
diff --git a/boards/px4/sitl/rtps.px4board b/boards/px4/sitl/rtps.px4board
deleted file mode 100644
index 81e62c7825..0000000000
--- a/boards/px4/sitl/rtps.px4board
+++ /dev/null
@@ -1 +0,0 @@
-CONFIG_MODULES_MICRORTPS_BRIDGE=y
diff --git a/cmake/package.cmake b/cmake/package.cmake
index fd71343221..69d3ab7a06 100644
--- a/cmake/package.cmake
+++ b/cmake/package.cmake
@@ -57,4 +57,7 @@ else()
endif()
include(CPack)
-include(bloaty)
+
+if(${PX4_PLATFORM} MATCHES "nuttx")
+ include(bloaty)
+endif()
diff --git a/cmake/px4_add_common_flags.cmake b/cmake/px4_add_common_flags.cmake
index 71fbbf2657..cce78801f1 100644
--- a/cmake/px4_add_common_flags.cmake
+++ b/cmake/px4_add_common_flags.cmake
@@ -71,11 +71,11 @@ function(px4_add_common_flags)
-Werror
-Warray-bounds
- -Wcast-align
+ #-Wcast-align # TODO
-Wdisabled-optimization
-Wdouble-promotion
-Wfatal-errors
- -Wfloat-equal
+ #-Wfloat-equal
-Wformat-security
-Winit-self
-Wlogical-op
@@ -156,9 +156,6 @@ function(px4_add_common_flags)
# CXX only flags
set(cxx_flags)
list(APPEND cxx_flags
- -fno-exceptions
- -fno-threadsafe-statics
-
-Wreorder
# disabled warnings
@@ -175,16 +172,19 @@ function(px4_add_common_flags)
add_compile_options($<$:${flag}>)
endforeach()
+ if(NOT (${PX4_PLATFORM} MATCHES "ros2")) # TODO: fix
+ include_directories(
+ ${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/src/px4/${PX4_CHIP_MANUFACTURER}/${PX4_CHIP}/include
+ ${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/src/px4/common/include
+ ${PX4_SOURCE_DIR}/platforms/common
+ ${PX4_SOURCE_DIR}/platforms/common/include
+ )
+ endif()
include_directories(
${PX4_BINARY_DIR}
${PX4_BINARY_DIR}/src/lib
- ${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/src/px4/${PX4_CHIP_MANUFACTURER}/${PX4_CHIP}/include
- ${PX4_SOURCE_DIR}/platforms/${PX4_PLATFORM}/src/px4/common/include
- ${PX4_SOURCE_DIR}/platforms/common
- ${PX4_SOURCE_DIR}/platforms/common/include
-
${PX4_SOURCE_DIR}/src
${PX4_SOURCE_DIR}/src/include
${PX4_SOURCE_DIR}/src/lib
diff --git a/cmake/px4_add_library.cmake b/cmake/px4_add_library.cmake
index 7dc7b6cfd0..56c00263c6 100644
--- a/cmake/px4_add_library.cmake
+++ b/cmake/px4_add_library.cmake
@@ -39,7 +39,10 @@ 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}")
diff --git a/cmake/px4_add_module.cmake b/cmake/px4_add_module.cmake
index ff6e1e4075..3985cebba4 100644
--- a/cmake/px4_add_module.cmake
+++ b/cmake/px4_add_module.cmake
@@ -48,6 +48,7 @@ include(px4_list_make_absolute)
# [ DEPENDS ]
# [ SRCS ]
# [ MODULE_CONFIG ]
+# [ PUBLICATIONS ]
# [ EXTERNAL ]
# [ DYNAMIC ]
# )
@@ -64,6 +65,8 @@ include(px4_list_make_absolute)
# MODULE_CONFIG : yaml config file(s)
# INCLUDES : include directories
# DEPENDS : targets which this module depends on
+# PUBLICATIONS : List of publications from this module
+# SUBSCRIPTIONS : List of subsriptions used by this module
# EXTERNAL : flag to indicate that this module is out-of-tree
# DYNAMIC : don't compile into the px4 binary, but build a separate dynamically loadable module (posix)
# UNITY_BUILD : merge all source files and build this module as a single compilation unit
@@ -86,7 +89,7 @@ function(px4_add_module)
px4_parse_function_args(
NAME px4_add_module
ONE_VALUE MODULE MAIN STACK_MAIN STACK_MAX PRIORITY
- MULTI_VALUE COMPILE_FLAGS LINK_FLAGS SRCS INCLUDES DEPENDS MODULE_CONFIG
+ MULTI_VALUE COMPILE_FLAGS LINK_FLAGS SRCS INCLUDES DEPENDS MODULE_CONFIG PUBLICATIONS SUBSCRIPTIONS
OPTIONS EXTERNAL DYNAMIC UNITY_BUILD
REQUIRED MODULE MAIN
ARGN ${ARGN})
@@ -185,7 +188,7 @@ function(px4_add_module)
# set defaults if not set
set(MAIN_DEFAULT MAIN-NOTFOUND)
- set(STACK_MAIN_DEFAULT 2048)
+ set(STACK_MAIN_DEFAULT 4096)
set(PRIORITY_DEFAULT SCHED_PRIORITY_DEFAULT)
foreach(property MAIN STACK_MAIN PRIORITY)
@@ -238,7 +241,21 @@ function(px4_add_module)
endforeach()
endif()
- foreach (prop LINK_FLAGS STACK_MAIN MAIN PRIORITY)
+ if(PUBLICATIONS)
+ foreach(publication ${PUBLICATIONS})
+ #message(STATUS "${MODULE} PUBLICATION: ${publication}")
+ set_property(GLOBAL APPEND PROPERTY PX4_PUBLICATIONS ${publication})
+ endforeach()
+ endif()
+
+ if(SUBSCRIPTIONS)
+ foreach(subscription ${SUBSCRIPTIONS})
+ #message(STATUS "${MODULE} SUBSCRIPTION: ${subscription}")
+ set_property(GLOBAL APPEND PROPERTY PX4_SUBSCRIPTIONS ${subscription})
+ endforeach()
+ endif()
+
+ foreach(prop LINK_FLAGS STACK_MAIN MAIN PRIORITY)
if (${prop})
set_target_properties(${MODULE} PROPERTIES ${prop} ${${prop}})
endif()
diff --git a/cmake/px4_config.cmake b/cmake/px4_config.cmake
index 41ea7b8c07..3c8ca6eee7 100644
--- a/cmake/px4_config.cmake
+++ b/cmake/px4_config.cmake
@@ -63,9 +63,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,9 +76,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()
endif()
diff --git a/integrationtests/python_src/px4_it/mavros/mission_test.py b/integrationtests/python_src/px4_it/mavros/mission_test.py
index fac011eb7d..d3900ae063 100755
--- a/integrationtests/python_src/px4_it/mavros/mission_test.py
+++ b/integrationtests/python_src/px4_it/mavros/mission_test.py
@@ -47,7 +47,6 @@ import glob
import json
import math
import os
-from px4tools import ulog
import sys
from mavros import mavlink
from mavros_msgs.msg import Mavlink, Waypoint, WaypointReached
@@ -295,17 +294,6 @@ class MavrosMissionTest(MavrosTestCommon):
rospy.loginfo("mission done, calculating performance metrics")
last_log = get_last_log()
rospy.loginfo("log file {0}".format(last_log))
- data = ulog.read_ulog(last_log).concat(dt=0.1)
- data = ulog.compute_data(data)
- res = ulog.estimator_analysis(data, False)
-
- # enforce performance
- self.assertTrue(abs(res['roll_error_mean']) < 5.0, str(res))
- self.assertTrue(abs(res['pitch_error_mean']) < 5.0, str(res))
- self.assertTrue(abs(res['yaw_error_mean']) < 5.0, str(res))
- self.assertTrue(res['roll_error_std'] < 5.0, str(res))
- self.assertTrue(res['pitch_error_std'] < 5.0, str(res))
- self.assertTrue(res['yaw_error_std'] < 5.0, str(res))
if __name__ == '__main__':
diff --git a/msg/action_request.msg b/msg/ActionRequest.msg
similarity index 100%
rename from msg/action_request.msg
rename to msg/ActionRequest.msg
diff --git a/msg/actuator_armed.msg b/msg/ActuatorArmed.msg
similarity index 100%
rename from msg/actuator_armed.msg
rename to msg/ActuatorArmed.msg
diff --git a/msg/actuator_controls.msg b/msg/ActuatorControls.msg
similarity index 79%
rename from msg/actuator_controls.msg
rename to msg/ActuatorControls.msg
index 25ff45f432..0e9eb98dd5 100644
--- a/msg/actuator_controls.msg
+++ b/msg/ActuatorControls.msg
@@ -20,6 +20,3 @@ uint8 GROUP_INDEX_PAYLOAD = 6
uint64 timestamp_sample # the timestamp the data this control response is based on was sampled
float32[8] control
-
-# TOPICS actuator_controls actuator_controls_0 actuator_controls_1 actuator_controls_2 actuator_controls_3
-# TOPICS actuator_controls_virtual_fw actuator_controls_virtual_mc
diff --git a/msg/actuator_controls_status.msg b/msg/ActuatorControlsStatus.msg
similarity index 66%
rename from msg/actuator_controls_status.msg
rename to msg/ActuatorControlsStatus.msg
index 4e3bf83450..98364042ac 100644
--- a/msg/actuator_controls_status.msg
+++ b/msg/ActuatorControlsStatus.msg
@@ -6,5 +6,3 @@ uint8 INDEX_YAW = 2
uint8 INDEX_THROTTLE = 3
float32[4] control_power
-
-# TOPICS actuator_controls_status actuator_controls_status_0 actuator_controls_status_1
diff --git a/msg/actuator_motors.msg b/msg/ActuatorMotors.msg
similarity index 100%
rename from msg/actuator_motors.msg
rename to msg/ActuatorMotors.msg
diff --git a/msg/actuator_outputs.msg b/msg/ActuatorOutputs.msg
similarity index 65%
rename from msg/actuator_outputs.msg
rename to msg/ActuatorOutputs.msg
index c16b73b5d7..ff546948d8 100644
--- a/msg/actuator_outputs.msg
+++ b/msg/ActuatorOutputs.msg
@@ -3,6 +3,3 @@ uint8 NUM_ACTUATOR_OUTPUTS = 16
uint8 NUM_ACTUATOR_OUTPUT_GROUPS = 4 # for sanity checking
uint32 noutputs # valid outputs
float32[16] output # output data, in natural output units
-
-# actuator_outputs_sim is used for SITL, HITL & SIH (with an output range of [-1, 1])
-# TOPICS actuator_outputs actuator_outputs_sim
diff --git a/msg/actuator_servos.msg b/msg/ActuatorServos.msg
similarity index 100%
rename from msg/actuator_servos.msg
rename to msg/ActuatorServos.msg
diff --git a/msg/actuator_servos_trim.msg b/msg/ActuatorServosTrim.msg
similarity index 100%
rename from msg/actuator_servos_trim.msg
rename to msg/ActuatorServosTrim.msg
diff --git a/msg/actuator_test.msg b/msg/ActuatorTest.msg
similarity index 100%
rename from msg/actuator_test.msg
rename to msg/ActuatorTest.msg
diff --git a/msg/adc_report.msg b/msg/AdcReport.msg
similarity index 100%
rename from msg/adc_report.msg
rename to msg/AdcReport.msg
diff --git a/msg/airspeed.msg b/msg/Airspeed.msg
similarity index 100%
rename from msg/airspeed.msg
rename to msg/Airspeed.msg
diff --git a/msg/airspeed_validated.msg b/msg/AirspeedValidated.msg
similarity index 100%
rename from msg/airspeed_validated.msg
rename to msg/AirspeedValidated.msg
diff --git a/msg/airspeed_wind.msg b/msg/AirspeedWind.msg
similarity index 100%
rename from msg/airspeed_wind.msg
rename to msg/AirspeedWind.msg
diff --git a/msg/autotune_attitude_control_status.msg b/msg/AutotuneAttitudeControlStatus.msg
similarity index 100%
rename from msg/autotune_attitude_control_status.msg
rename to msg/AutotuneAttitudeControlStatus.msg
diff --git a/msg/battery_status.msg b/msg/BatteryStatus.msg
similarity index 100%
rename from msg/battery_status.msg
rename to msg/BatteryStatus.msg
diff --git a/msg/CMakeLists.txt b/msg/CMakeLists.txt
index 433c36b08f..b698a7718a 100644
--- a/msg/CMakeLists.txt
+++ b/msg/CMakeLists.txt
@@ -1,6 +1,6 @@
############################################################################
#
-# Copyright (c) 2016 PX4 Development Team. All rights reserved.
+# Copyright (c) 2016-2022 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
@@ -37,213 +37,179 @@ cmake_policy(SET CMP0057 NEW)
include(px4_list_make_absolute)
set(msg_files
- action_request.msg
- actuator_armed.msg
- actuator_controls.msg
- actuator_controls_status.msg
- actuator_motors.msg
- actuator_outputs.msg
- actuator_servos.msg
- actuator_servos_trim.msg
- actuator_test.msg
- adc_report.msg
- airspeed.msg
- airspeed_validated.msg
- airspeed_wind.msg
- autotune_attitude_control_status.msg
- battery_status.msg
- camera_capture.msg
- camera_status.msg
- camera_trigger.msg
- cellular_status.msg
- collision_constraints.msg
- collision_report.msg
- commander_state.msg
- control_allocator_status.msg
- cpuload.msg
- differential_pressure.msg
- distance_sensor.msg
- ekf2_timestamps.msg
- estimator_gps_status.msg
- esc_report.msg
- esc_status.msg
- estimator_baro_bias.msg
- estimator_event_flags.msg
- estimator_innovations.msg
- estimator_optical_flow_vel.msg
- estimator_selector_status.msg
- estimator_sensor_bias.msg
- estimator_states.msg
- estimator_status.msg
- estimator_status_flags.msg
- event.msg
- follow_target.msg
- failure_detector_status.msg
- generator_status.msg
- geofence_result.msg
- gimbal_device_attitude_status.msg
- gimbal_device_information.msg
- gimbal_device_set_attitude.msg
- gimbal_manager_information.msg
- gimbal_manager_set_attitude.msg
- gimbal_manager_set_manual_control.msg
- gimbal_manager_status.msg
- gps_dump.msg
- gps_inject_data.msg
- heater_status.msg
- home_position.msg
- hover_thrust_estimate.msg
- internal_combustion_engine_status.msg
- input_rc.msg
- iridiumsbd_status.msg
- irlock_report.msg
- landing_gear.msg
- landing_target_innovations.msg
- landing_target_pose.msg
- led_control.msg
- log_message.msg
- logger_status.msg
- mag_worker_data.msg
- magnetometer_bias_estimate.msg
- manual_control_setpoint.msg
- manual_control_switches.msg
- mavlink_log.msg
- mavlink_tunnel.msg
- mission.msg
- mission_result.msg
- mount_orientation.msg
- navigator_mission_item.msg
- npfg_status.msg
- obstacle_distance.msg
- offboard_control_mode.msg
- onboard_computer_status.msg
- optical_flow.msg
- orbit_status.msg
- parameter_update.msg
- ping.msg
- pps_capture.msg
- position_controller_landing_status.msg
- position_controller_status.msg
- position_setpoint.msg
- position_setpoint_triplet.msg
- power_button_state.msg
- power_monitor.msg
- pwm_input.msg
- px4io_status.msg
- radio_status.msg
- rate_ctrl_status.msg
- rc_channels.msg
- rc_parameter_map.msg
- rpm.msg
- rtl_time_estimate.msg
- safety.msg
- satellite_info.msg
- sensor_accel.msg
- sensor_accel_fifo.msg
- sensor_baro.msg
- sensor_combined.msg
- sensor_correction.msg
- sensor_gps.msg
- sensor_gyro.msg
- sensor_gyro_fft.msg
- sensor_gyro_fifo.msg
- sensor_hygrometer.msg
- sensor_mag.msg
- sensor_preflight_mag.msg
- sensor_selection.msg
- sensors_status_imu.msg
- system_power.msg
- takeoff_status.msg
- task_stack_info.msg
- tecs_status.msg
- telemetry_status.msg
- test_motor.msg
- timesync.msg
- timesync_status.msg
- trajectory_bezier.msg
- trajectory_waypoint.msg
- transponder_report.msg
- tune_control.msg
- uavcan_parameter_request.msg
- uavcan_parameter_value.msg
- ulog_stream.msg
- ulog_stream_ack.msg
- vehicle_acceleration.msg
- vehicle_air_data.msg
- vehicle_angular_acceleration.msg
- vehicle_angular_acceleration_setpoint.msg
- vehicle_angular_velocity.msg
- vehicle_attitude.msg
- vehicle_attitude_setpoint.msg
- vehicle_command.msg
- vehicle_command_ack.msg
- vehicle_constraints.msg
- vehicle_control_mode.msg
- vehicle_global_position.msg
- vehicle_gps_position.msg
- vehicle_imu.msg
- vehicle_imu_status.msg
- vehicle_land_detected.msg
- vehicle_local_position.msg
- vehicle_local_position_setpoint.msg
- vehicle_magnetometer.msg
- vehicle_odometry.msg
- vehicle_rates_setpoint.msg
- vehicle_roi.msg
- vehicle_status.msg
- vehicle_status_flags.msg
- vehicle_thrust_setpoint.msg
- vehicle_torque_setpoint.msg
- vehicle_trajectory_bezier.msg
- vehicle_trajectory_waypoint.msg
- vtol_vehicle_status.msg
- wheel_encoders.msg
- wind.msg
- yaw_estimator_status.msg
+ ActionRequest.msg
+ ActuatorArmed.msg
+ ActuatorControls.msg
+ ActuatorControlsStatus.msg
+ ActuatorMotors.msg
+ ActuatorOutputs.msg
+ ActuatorServos.msg
+ ActuatorServosTrim.msg
+ ActuatorTest.msg
+ AdcReport.msg
+ Airspeed.msg
+ AirspeedValidated.msg
+ AirspeedWind.msg
+ AutotuneAttitudeControlStatus.msg
+ BatteryStatus.msg
+ CameraCapture.msg
+ CameraStatus.msg
+ CameraTrigger.msg
+ CellularStatus.msg
+ CollisionConstraints.msg
+ CollisionReport.msg
+ CommanderState.msg
+ ControlAllocatorStatus.msg
+ Cpuload.msg
+ DebugArray.msg
+ DebugKeyValue.msg
+ DebugValue.msg
+ DebugVect.msg
+ DifferentialPressure.msg
+ DistanceSensor.msg
+ Ekf2Timestamps.msg
+ EscReport.msg
+ EscStatus.msg
+ EstimatorBaroBias.msg
+ EstimatorEventFlags.msg
+ EstimatorGpsStatus.msg
+ EstimatorInnovations.msg
+ EstimatorOpticalFlowVel.msg
+ EstimatorSelectorStatus.msg
+ EstimatorSensorBias.msg
+ EstimatorStates.msg
+ EstimatorStatus.msg
+ EstimatorStatusFlags.msg
+ Event.msg
+ FailureDetectorStatus.msg
+ FollowTarget.msg
+ GeneratorStatus.msg
+ GeofenceResult.msg
+ GimbalDeviceAttitudeStatus.msg
+ GimbalDeviceInformation.msg
+ GimbalDeviceSetAttitude.msg
+ GimbalManagerInformation.msg
+ GimbalManagerSetAttitude.msg
+ GimbalManagerSetManualControl.msg
+ GimbalManagerStatus.msg
+ GpsDump.msg
+ GpsInjectData.msg
+ HeaterStatus.msg
+ HomePosition.msg
+ HoverThrustEstimate.msg
+ InputRc.msg
+ InternalCombustionEngineStatus.msg
+ IridiumsbdStatus.msg
+ IrlockReport.msg
+ LandingGear.msg
+ LandingTargetInnovations.msg
+ LandingTargetPose.msg
+ LedControl.msg
+ LoggerStatus.msg
+ LogMessage.msg
+ MagnetometerBiasEstimate.msg
+ MagWorkerData.msg
+ ManualControlSetpoint.msg
+ ManualControlSwitches.msg
+ MavlinkLog.msg
+ MavlinkTunnel.msg
+ Mission.msg
+ MissionResult.msg
+ MountOrientation.msg
+ NavigatorMissionItem.msg
+ NpfgStatus.msg
+ ObstacleDistance.msg
+ OffboardControlMode.msg
+ OnboardComputerStatus.msg
+ OpticalFlow.msg
+ OrbitStatus.msg
+ OrbTest.msg
+ OrbTestLarge.msg
+ OrbTestMedium.msg
+ ParameterUpdate.msg
+ Ping.msg
+ PositionControllerLandingStatus.msg
+ PositionControllerStatus.msg
+ PositionSetpoint.msg
+ PositionSetpointTriplet.msg
+ PowerButtonState.msg
+ PowerMonitor.msg
+ PpsCapture.msg
+ PwmInput.msg
+ Px4ioStatus.msg
+ RadioStatus.msg
+ RateCtrlStatus.msg
+ RcChannels.msg
+ RcParameterMap.msg
+ Rpm.msg
+ RtlTimeEstimate.msg
+ Safety.msg
+ SatelliteInfo.msg
+ SensorAccel.msg
+ SensorAccelFifo.msg
+ SensorBaro.msg
+ SensorCombined.msg
+ SensorCorrection.msg
+ SensorGps.msg
+ SensorGyro.msg
+ SensorGyroFft.msg
+ SensorGyroFifo.msg
+ SensorHygrometer.msg
+ SensorMag.msg
+ SensorPreflightMag.msg
+ SensorSelection.msg
+ SensorsStatusImu.msg
+ SystemPower.msg
+ TakeoffStatus.msg
+ TaskStackInfo.msg
+ TecsStatus.msg
+ TelemetryStatus.msg
+ TestMotor.msg
+ Timesync.msg
+ TimesyncStatus.msg
+ TrajectoryBezier.msg
+ TrajectoryWaypoint.msg
+ TransponderReport.msg
+ TuneControl.msg
+ UavcanParameterRequest.msg
+ UavcanParameterValue.msg
+ UlogStream.msg
+ UlogStreamAck.msg
+ VehicleAcceleration.msg
+ VehicleAirData.msg
+ VehicleAngularAcceleration.msg
+ VehicleAngularAccelerationSetpoint.msg
+ VehicleAngularVelocity.msg
+ VehicleAttitude.msg
+ VehicleAttitudeSetpoint.msg
+ VehicleCommand.msg
+ VehicleCommandAck.msg
+ VehicleConstraints.msg
+ VehicleControlMode.msg
+ VehicleGlobalPosition.msg
+ VehicleGpsPosition.msg
+ VehicleImu.msg
+ VehicleImuStatus.msg
+ VehicleLandDetected.msg
+ VehicleLocalPosition.msg
+ VehicleLocalPositionSetpoint.msg
+ VehicleMagnetometer.msg
+ VehicleOdometry.msg
+ VehicleRatesSetpoint.msg
+ VehicleRoi.msg
+ VehicleStatus.msg
+ VehicleStatusFlags.msg
+ VehicleThrustSetpoint.msg
+ VehicleTorqueSetpoint.msg
+ VehicleTrajectoryBezier.msg
+ VehicleTrajectoryWaypoint.msg
+ VtolVehicleStatus.msg
+ WheelEncoders.msg
+ Wind.msg
+ YawEstimatorStatus.msg
)
-
-if(NOT px4_constrained_flash_build)
- list(APPEND msg_files
- debug_array.msg
- debug_key_value.msg
- debug_value.msg
- debug_vect.msg
- )
-endif()
-
-if(PX4_TESTING)
- list(APPEND msg_files
- orb_test.msg
- orb_test_large.msg
- orb_test_medium.msg
- )
-endif()
-
list(SORT msg_files)
-set(deprecated_msgs
- ekf2_innovations.msg # 2019-11-22, Updated estimator interface and logging; replaced by 'estimator_innovations'.
- )
-
-foreach(msg IN LISTS deprecated_msgs)
- if(msg IN_LIST msg_files)
- get_filename_component(msg_we ${msg} NAME_WE)
- list(APPEND invalid_msgs ${msg_we})
- endif()
-endforeach()
-if(invalid_msgs)
- list(LENGTH invalid_msgs invalid_msgs_size)
- if(${invalid_msgs_size} GREATER 1)
- foreach(msg IN LISTS invalid_msgs)
- string(CONCAT invalid_msgs_cs ${invalid_msgs_cs} "'${msg}', ")
- endforeach()
- STRING(REGEX REPLACE ", +$" "" invalid_msgs_cs ${invalid_msgs_cs})
- message(FATAL_ERROR "${invalid_msgs_cs} are listed as deprecated. Please use different names for the messages.")
- else()
- message(FATAL_ERROR "'${invalid_msgs}' is listed as deprecated. Please use a different name for the message.")
- endif()
-endif()
-
px4_list_make_absolute(msg_files ${CMAKE_CURRENT_SOURCE_DIR} ${msg_files})
if(NOT EXTERNAL_MODULES_LOCATION STREQUAL "")
@@ -258,40 +224,40 @@ if(NOT EXTERNAL_MODULES_LOCATION STREQUAL "")
endif()
endif()
+# set parent scope msg_files for other modules to consume (eg topic_listener)
+set(msg_files ${msg_files} PARENT_SCOPE)
+
# headers
set(msg_out_path ${PX4_BINARY_DIR}/uORB/topics)
set(msg_source_out_path ${CMAKE_CURRENT_BINARY_DIR}/topics_sources)
-set(uorb_headers ${msg_out_path}/uORBTopics.hpp)
-set(uorb_sources ${msg_source_out_path}/uORBTopics.cpp)
+set(uorb_headers)
foreach(msg_file ${msg_files})
get_filename_component(msg ${msg_file} NAME_WE)
+
+ # Pascal case to snake case (MsgFile -> msg_file)
+ string(REGEX REPLACE "(.)([A-Z][a-z]+)" "\\1_\\2" msg "${msg}")
+ string(REGEX REPLACE "([a-z0-9])([A-Z])" "\\1_\\2" msg "${msg}")
+ string(TOLOWER "${msg}" msg)
+
list(APPEND uorb_headers ${msg_out_path}/${msg}.h)
- list(APPEND uorb_sources ${msg_source_out_path}/${msg}.cpp)
endforeach()
-if (px4_constrained_flash_build)
+if(px4_constrained_flash_build)
set(added_arguments --constrained-flash)
endif()
-# set parent scope msg_files for other modules to consume (eg topic_listener)
-set(msg_files ${msg_files} 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
${added_arguments}
DEPENDS
${msg_files}
templates/uorb/msg.h.em
- templates/uorb/uORBTopics.hpp.em
tools/px_generate_uorb_topic_files.py
tools/px_generate_uorb_topic_helper.py
COMMENT "Generating uORB topic headers"
@@ -299,28 +265,3 @@ add_custom_command(OUTPUT ${uorb_headers}
VERBATIM
)
add_custom_target(uorb_headers DEPENDS ${uorb_headers})
-
-# 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
- ${added_arguments}
- DEPENDS
- ${msg_files}
- templates/uorb/msg.cpp.em
- templates/uorb/uORBTopics.cpp.em
- tools/px_generate_uorb_topic_files.py
- tools/px_generate_uorb_topic_helper.py
- COMMENT "Generating uORB topic sources"
- WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
- VERBATIM
- )
-
-add_library(uorb_msgs ${uorb_sources})
-add_dependencies(uorb_msgs prebuild_targets uorb_headers)
diff --git a/msg/camera_capture.msg b/msg/CameraCapture.msg
similarity index 100%
rename from msg/camera_capture.msg
rename to msg/CameraCapture.msg
diff --git a/msg/camera_status.msg b/msg/CameraStatus.msg
similarity index 100%
rename from msg/camera_status.msg
rename to msg/CameraStatus.msg
diff --git a/msg/camera_trigger.msg b/msg/CameraTrigger.msg
similarity index 89%
rename from msg/camera_trigger.msg
rename to msg/CameraTrigger.msg
index 0da1dd109d..abfdac6dda 100644
--- a/msg/camera_trigger.msg
+++ b/msg/CameraTrigger.msg
@@ -5,5 +5,3 @@ uint32 seq # Image sequence number
bool feedback # Trigger feedback from camera
uint32 ORB_QUEUE_LENGTH = 2
-
-# TOPICS camera_trigger
\ No newline at end of file
diff --git a/msg/cellular_status.msg b/msg/CellularStatus.msg
similarity index 100%
rename from msg/cellular_status.msg
rename to msg/CellularStatus.msg
diff --git a/msg/collision_constraints.msg b/msg/CollisionConstraints.msg
similarity index 100%
rename from msg/collision_constraints.msg
rename to msg/CollisionConstraints.msg
diff --git a/msg/collision_report.msg b/msg/CollisionReport.msg
similarity index 100%
rename from msg/collision_report.msg
rename to msg/CollisionReport.msg
diff --git a/msg/commander_state.msg b/msg/CommanderState.msg
similarity index 100%
rename from msg/commander_state.msg
rename to msg/CommanderState.msg
diff --git a/msg/control_allocator_status.msg b/msg/ControlAllocatorStatus.msg
similarity index 100%
rename from msg/control_allocator_status.msg
rename to msg/ControlAllocatorStatus.msg
diff --git a/msg/cpuload.msg b/msg/Cpuload.msg
similarity index 100%
rename from msg/cpuload.msg
rename to msg/Cpuload.msg
diff --git a/msg/debug_array.msg b/msg/DebugArray.msg
similarity index 100%
rename from msg/debug_array.msg
rename to msg/DebugArray.msg
diff --git a/msg/debug_key_value.msg b/msg/DebugKeyValue.msg
similarity index 100%
rename from msg/debug_key_value.msg
rename to msg/DebugKeyValue.msg
diff --git a/msg/debug_value.msg b/msg/DebugValue.msg
similarity index 100%
rename from msg/debug_value.msg
rename to msg/DebugValue.msg
diff --git a/msg/debug_vect.msg b/msg/DebugVect.msg
similarity index 100%
rename from msg/debug_vect.msg
rename to msg/DebugVect.msg
diff --git a/msg/differential_pressure.msg b/msg/DifferentialPressure.msg
similarity index 100%
rename from msg/differential_pressure.msg
rename to msg/DifferentialPressure.msg
diff --git a/msg/distance_sensor.msg b/msg/DistanceSensor.msg
similarity index 100%
rename from msg/distance_sensor.msg
rename to msg/DistanceSensor.msg
diff --git a/msg/ekf2_timestamps.msg b/msg/Ekf2Timestamps.msg
similarity index 100%
rename from msg/ekf2_timestamps.msg
rename to msg/Ekf2Timestamps.msg
diff --git a/msg/esc_report.msg b/msg/EscReport.msg
similarity index 100%
rename from msg/esc_report.msg
rename to msg/EscReport.msg
diff --git a/msg/esc_status.msg b/msg/EscStatus.msg
similarity index 98%
rename from msg/esc_status.msg
rename to msg/EscStatus.msg
index f786f6d351..491e8c35de 100644
--- a/msg/esc_status.msg
+++ b/msg/EscStatus.msg
@@ -25,4 +25,4 @@ uint8 esc_online_flags # Bitmask indicating which ESC is online/offline
uint8 esc_armed_flags # Bitmask indicating which ESC is armed. For ESC's where the arming state is not known (returned by the ESC), the arming bits should always be set.
-esc_report[8] esc
+px4/EscReport[8] esc
diff --git a/msg/estimator_baro_bias.msg b/msg/EstimatorBaroBias.msg
similarity index 100%
rename from msg/estimator_baro_bias.msg
rename to msg/EstimatorBaroBias.msg
diff --git a/msg/estimator_event_flags.msg b/msg/EstimatorEventFlags.msg
similarity index 100%
rename from msg/estimator_event_flags.msg
rename to msg/EstimatorEventFlags.msg
diff --git a/msg/estimator_gps_status.msg b/msg/EstimatorGpsStatus.msg
similarity index 100%
rename from msg/estimator_gps_status.msg
rename to msg/EstimatorGpsStatus.msg
diff --git a/msg/estimator_innovations.msg b/msg/EstimatorInnovations.msg
similarity index 95%
rename from msg/estimator_innovations.msg
rename to msg/EstimatorInnovations.msg
index cb3e85a1c4..82c4d1a1aa 100644
--- a/msg/estimator_innovations.msg
+++ b/msg/EstimatorInnovations.msg
@@ -34,5 +34,3 @@ float32 hagl # height of ground innovation (m) and innovation variance (m**2)
# The innovation test ratios are scalar values. In case the field is a vector,
# the test ratio will be put in the first component of the vector.
-
-# TOPICS estimator_innovations estimator_innovation_variances estimator_innovation_test_ratios
diff --git a/msg/estimator_optical_flow_vel.msg b/msg/EstimatorOpticalFlowVel.msg
similarity index 100%
rename from msg/estimator_optical_flow_vel.msg
rename to msg/EstimatorOpticalFlowVel.msg
diff --git a/msg/estimator_selector_status.msg b/msg/EstimatorSelectorStatus.msg
similarity index 100%
rename from msg/estimator_selector_status.msg
rename to msg/EstimatorSelectorStatus.msg
diff --git a/msg/estimator_sensor_bias.msg b/msg/EstimatorSensorBias.msg
similarity index 100%
rename from msg/estimator_sensor_bias.msg
rename to msg/EstimatorSensorBias.msg
diff --git a/msg/estimator_states.msg b/msg/EstimatorStates.msg
similarity index 100%
rename from msg/estimator_states.msg
rename to msg/EstimatorStates.msg
diff --git a/msg/estimator_status.msg b/msg/EstimatorStatus.msg
similarity index 100%
rename from msg/estimator_status.msg
rename to msg/EstimatorStatus.msg
diff --git a/msg/estimator_status_flags.msg b/msg/EstimatorStatusFlags.msg
similarity index 100%
rename from msg/estimator_status_flags.msg
rename to msg/EstimatorStatusFlags.msg
diff --git a/msg/event.msg b/msg/Event.msg
similarity index 100%
rename from msg/event.msg
rename to msg/Event.msg
diff --git a/msg/failure_detector_status.msg b/msg/FailureDetectorStatus.msg
similarity index 100%
rename from msg/failure_detector_status.msg
rename to msg/FailureDetectorStatus.msg
diff --git a/msg/follow_target.msg b/msg/FollowTarget.msg
similarity index 75%
rename from msg/follow_target.msg
rename to msg/FollowTarget.msg
index f0afe3f4b8..5999f87453 100644
--- a/msg/follow_target.msg
+++ b/msg/FollowTarget.msg
@@ -1,8 +1,8 @@
uint64 timestamp # time since system start (microseconds)
float64 lat # target position (deg * 1e7)
-float64 lon # target position (deg * 1e7)
+float64 lon # target position (deg * 1e7)
float32 alt # target position
float32 vy # target vel in y
float32 vx # target vel in x
-float32 vz # target vel in z
+float32 vz # target vel in z
uint8 est_cap # target reporting capabilities
diff --git a/msg/generator_status.msg b/msg/GeneratorStatus.msg
similarity index 100%
rename from msg/generator_status.msg
rename to msg/GeneratorStatus.msg
diff --git a/msg/geofence_result.msg b/msg/GeofenceResult.msg
similarity index 100%
rename from msg/geofence_result.msg
rename to msg/GeofenceResult.msg
diff --git a/msg/gimbal_device_attitude_status.msg b/msg/GimbalDeviceAttitudeStatus.msg
similarity index 100%
rename from msg/gimbal_device_attitude_status.msg
rename to msg/GimbalDeviceAttitudeStatus.msg
diff --git a/msg/gimbal_device_information.msg b/msg/GimbalDeviceInformation.msg
similarity index 100%
rename from msg/gimbal_device_information.msg
rename to msg/GimbalDeviceInformation.msg
diff --git a/msg/gimbal_device_set_attitude.msg b/msg/GimbalDeviceSetAttitude.msg
similarity index 100%
rename from msg/gimbal_device_set_attitude.msg
rename to msg/GimbalDeviceSetAttitude.msg
diff --git a/msg/gimbal_manager_information.msg b/msg/GimbalManagerInformation.msg
similarity index 100%
rename from msg/gimbal_manager_information.msg
rename to msg/GimbalManagerInformation.msg
diff --git a/msg/gimbal_manager_set_attitude.msg b/msg/GimbalManagerSetAttitude.msg
similarity index 100%
rename from msg/gimbal_manager_set_attitude.msg
rename to msg/GimbalManagerSetAttitude.msg
diff --git a/msg/gimbal_manager_set_manual_control.msg b/msg/GimbalManagerSetManualControl.msg
similarity index 100%
rename from msg/gimbal_manager_set_manual_control.msg
rename to msg/GimbalManagerSetManualControl.msg
diff --git a/msg/gimbal_manager_status.msg b/msg/GimbalManagerStatus.msg
similarity index 100%
rename from msg/gimbal_manager_status.msg
rename to msg/GimbalManagerStatus.msg
diff --git a/msg/gps_dump.msg b/msg/GpsDump.msg
similarity index 100%
rename from msg/gps_dump.msg
rename to msg/GpsDump.msg
diff --git a/msg/gps_inject_data.msg b/msg/GpsInjectData.msg
similarity index 100%
rename from msg/gps_inject_data.msg
rename to msg/GpsInjectData.msg
diff --git a/msg/heater_status.msg b/msg/HeaterStatus.msg
similarity index 100%
rename from msg/heater_status.msg
rename to msg/HeaterStatus.msg
diff --git a/msg/home_position.msg b/msg/HomePosition.msg
similarity index 100%
rename from msg/home_position.msg
rename to msg/HomePosition.msg
diff --git a/msg/hover_thrust_estimate.msg b/msg/HoverThrustEstimate.msg
similarity index 100%
rename from msg/hover_thrust_estimate.msg
rename to msg/HoverThrustEstimate.msg
diff --git a/msg/input_rc.msg b/msg/InputRc.msg
similarity index 100%
rename from msg/input_rc.msg
rename to msg/InputRc.msg
diff --git a/msg/internal_combustion_engine_status.msg b/msg/InternalCombustionEngineStatus.msg
similarity index 100%
rename from msg/internal_combustion_engine_status.msg
rename to msg/InternalCombustionEngineStatus.msg
diff --git a/msg/iridiumsbd_status.msg b/msg/IridiumsbdStatus.msg
similarity index 100%
rename from msg/iridiumsbd_status.msg
rename to msg/IridiumsbdStatus.msg
diff --git a/msg/irlock_report.msg b/msg/IrlockReport.msg
similarity index 100%
rename from msg/irlock_report.msg
rename to msg/IrlockReport.msg
diff --git a/msg/landing_gear.msg b/msg/LandingGear.msg
similarity index 100%
rename from msg/landing_gear.msg
rename to msg/LandingGear.msg
diff --git a/msg/landing_target_innovations.msg b/msg/LandingTargetInnovations.msg
similarity index 100%
rename from msg/landing_target_innovations.msg
rename to msg/LandingTargetInnovations.msg
diff --git a/msg/landing_target_pose.msg b/msg/LandingTargetPose.msg
similarity index 100%
rename from msg/landing_target_pose.msg
rename to msg/LandingTargetPose.msg
diff --git a/msg/led_control.msg b/msg/LedControl.msg
similarity index 100%
rename from msg/led_control.msg
rename to msg/LedControl.msg
diff --git a/msg/log_message.msg b/msg/LogMessage.msg
similarity index 100%
rename from msg/log_message.msg
rename to msg/LogMessage.msg
diff --git a/msg/logger_status.msg b/msg/LoggerStatus.msg
similarity index 100%
rename from msg/logger_status.msg
rename to msg/LoggerStatus.msg
diff --git a/msg/mag_worker_data.msg b/msg/MagWorkerData.msg
similarity index 100%
rename from msg/mag_worker_data.msg
rename to msg/MagWorkerData.msg
diff --git a/msg/magnetometer_bias_estimate.msg b/msg/MagnetometerBiasEstimate.msg
similarity index 100%
rename from msg/magnetometer_bias_estimate.msg
rename to msg/MagnetometerBiasEstimate.msg
diff --git a/msg/manual_control_setpoint.msg b/msg/ManualControlSetpoint.msg
similarity index 97%
rename from msg/manual_control_setpoint.msg
rename to msg/ManualControlSetpoint.msg
index bbbdd0bc66..68232b087c 100644
--- a/msg/manual_control_setpoint.msg
+++ b/msg/ManualControlSetpoint.msg
@@ -52,5 +52,3 @@ float32 aux5
float32 aux6
bool sticks_moving
-
-# TOPICS manual_control_setpoint manual_control_input
diff --git a/msg/manual_control_switches.msg b/msg/ManualControlSwitches.msg
similarity index 100%
rename from msg/manual_control_switches.msg
rename to msg/ManualControlSwitches.msg
diff --git a/msg/mavlink_log.msg b/msg/MavlinkLog.msg
similarity index 100%
rename from msg/mavlink_log.msg
rename to msg/MavlinkLog.msg
diff --git a/msg/mavlink_tunnel.msg b/msg/MavlinkTunnel.msg
similarity index 100%
rename from msg/mavlink_tunnel.msg
rename to msg/MavlinkTunnel.msg
diff --git a/msg/mission.msg b/msg/Mission.msg
similarity index 100%
rename from msg/mission.msg
rename to msg/Mission.msg
diff --git a/msg/mission_result.msg b/msg/MissionResult.msg
similarity index 100%
rename from msg/mission_result.msg
rename to msg/MissionResult.msg
diff --git a/msg/mount_orientation.msg b/msg/MountOrientation.msg
similarity index 100%
rename from msg/mount_orientation.msg
rename to msg/MountOrientation.msg
diff --git a/msg/navigator_mission_item.msg b/msg/NavigatorMissionItem.msg
similarity index 100%
rename from msg/navigator_mission_item.msg
rename to msg/NavigatorMissionItem.msg
diff --git a/msg/npfg_status.msg b/msg/NpfgStatus.msg
similarity index 100%
rename from msg/npfg_status.msg
rename to msg/NpfgStatus.msg
diff --git a/msg/obstacle_distance.msg b/msg/ObstacleDistance.msg
similarity index 96%
rename from msg/obstacle_distance.msg
rename to msg/ObstacleDistance.msg
index e3c4963ab2..2bd8800d44 100644
--- a/msg/obstacle_distance.msg
+++ b/msg/ObstacleDistance.msg
@@ -20,5 +20,3 @@ uint16 min_distance # Minimum distance the sensor can measure in centimeters.
uint16 max_distance # Maximum distance the sensor can measure in centimeters.
float32 angle_offset # Relative angle offset of the 0-index element in the distances array. Value of 0 corresponds to forward. Positive values are offsets to the right.
-
-# TOPICS obstacle_distance obstacle_distance_fused
diff --git a/msg/offboard_control_mode.msg b/msg/OffboardControlMode.msg
similarity index 100%
rename from msg/offboard_control_mode.msg
rename to msg/OffboardControlMode.msg
diff --git a/msg/onboard_computer_status.msg b/msg/OnboardComputerStatus.msg
similarity index 100%
rename from msg/onboard_computer_status.msg
rename to msg/OnboardComputerStatus.msg
diff --git a/msg/optical_flow.msg b/msg/OpticalFlow.msg
similarity index 100%
rename from msg/optical_flow.msg
rename to msg/OpticalFlow.msg
diff --git a/msg/OrbTest.msg b/msg/OrbTest.msg
new file mode 100644
index 0000000000..77fcca6e5b
--- /dev/null
+++ b/msg/OrbTest.msg
@@ -0,0 +1,3 @@
+uint64 timestamp # time since system start (microseconds)
+
+int32 val
diff --git a/msg/orb_test_large.msg b/msg/OrbTestLarge.msg
similarity index 100%
rename from msg/orb_test_large.msg
rename to msg/OrbTestLarge.msg
diff --git a/msg/orb_test.msg b/msg/OrbTestMedium.msg
similarity index 68%
rename from msg/orb_test.msg
rename to msg/OrbTestMedium.msg
index bbbca412fd..fe6f989313 100644
--- a/msg/orb_test.msg
+++ b/msg/OrbTestMedium.msg
@@ -2,4 +2,4 @@ uint64 timestamp # time since system start (microseconds)
int32 val
-# TOPICS orb_test orb_multitest
+uint8[64] junk
diff --git a/msg/orbit_status.msg b/msg/OrbitStatus.msg
similarity index 100%
rename from msg/orbit_status.msg
rename to msg/OrbitStatus.msg
diff --git a/msg/parameter_update.msg b/msg/ParameterUpdate.msg
similarity index 100%
rename from msg/parameter_update.msg
rename to msg/ParameterUpdate.msg
diff --git a/msg/ping.msg b/msg/Ping.msg
similarity index 100%
rename from msg/ping.msg
rename to msg/Ping.msg
diff --git a/msg/position_controller_landing_status.msg b/msg/PositionControllerLandingStatus.msg
similarity index 100%
rename from msg/position_controller_landing_status.msg
rename to msg/PositionControllerLandingStatus.msg
diff --git a/msg/position_controller_status.msg b/msg/PositionControllerStatus.msg
similarity index 100%
rename from msg/position_controller_status.msg
rename to msg/PositionControllerStatus.msg
diff --git a/msg/position_setpoint.msg b/msg/PositionSetpoint.msg
similarity index 100%
rename from msg/position_setpoint.msg
rename to msg/PositionSetpoint.msg
diff --git a/msg/position_setpoint_triplet.msg b/msg/PositionSetpointTriplet.msg
similarity index 67%
rename from msg/position_setpoint_triplet.msg
rename to msg/PositionSetpointTriplet.msg
index 7c9a2ca78b..e76bc3e9db 100644
--- a/msg/position_setpoint_triplet.msg
+++ b/msg/PositionSetpointTriplet.msg
@@ -3,6 +3,6 @@
uint64 timestamp # time since system start (microseconds)
-px4/position_setpoint previous
-px4/position_setpoint current
-px4/position_setpoint next
+px4/PositionSetpoint previous
+px4/PositionSetpoint current
+px4/PositionSetpoint next
diff --git a/msg/power_button_state.msg b/msg/PowerButtonState.msg
similarity index 100%
rename from msg/power_button_state.msg
rename to msg/PowerButtonState.msg
diff --git a/msg/power_monitor.msg b/msg/PowerMonitor.msg
similarity index 100%
rename from msg/power_monitor.msg
rename to msg/PowerMonitor.msg
diff --git a/msg/pps_capture.msg b/msg/PpsCapture.msg
similarity index 100%
rename from msg/pps_capture.msg
rename to msg/PpsCapture.msg
diff --git a/msg/pwm_input.msg b/msg/PwmInput.msg
similarity index 100%
rename from msg/pwm_input.msg
rename to msg/PwmInput.msg
diff --git a/msg/px4io_status.msg b/msg/Px4ioStatus.msg
similarity index 100%
rename from msg/px4io_status.msg
rename to msg/Px4ioStatus.msg
diff --git a/msg/radio_status.msg b/msg/RadioStatus.msg
similarity index 100%
rename from msg/radio_status.msg
rename to msg/RadioStatus.msg
diff --git a/msg/rate_ctrl_status.msg b/msg/RateCtrlStatus.msg
similarity index 100%
rename from msg/rate_ctrl_status.msg
rename to msg/RateCtrlStatus.msg
diff --git a/msg/rc_channels.msg b/msg/RcChannels.msg
similarity index 100%
rename from msg/rc_channels.msg
rename to msg/RcChannels.msg
diff --git a/msg/rc_parameter_map.msg b/msg/RcParameterMap.msg
similarity index 100%
rename from msg/rc_parameter_map.msg
rename to msg/RcParameterMap.msg
diff --git a/msg/rpm.msg b/msg/Rpm.msg
similarity index 100%
rename from msg/rpm.msg
rename to msg/Rpm.msg
diff --git a/msg/rtl_time_estimate.msg b/msg/RtlTimeEstimate.msg
similarity index 100%
rename from msg/rtl_time_estimate.msg
rename to msg/RtlTimeEstimate.msg
diff --git a/msg/safety.msg b/msg/Safety.msg
similarity index 100%
rename from msg/safety.msg
rename to msg/Safety.msg
diff --git a/msg/satellite_info.msg b/msg/SatelliteInfo.msg
similarity index 100%
rename from msg/satellite_info.msg
rename to msg/SatelliteInfo.msg
diff --git a/msg/sensor_accel.msg b/msg/SensorAccel.msg
similarity index 100%
rename from msg/sensor_accel.msg
rename to msg/SensorAccel.msg
diff --git a/msg/sensor_accel_fifo.msg b/msg/SensorAccelFifo.msg
similarity index 100%
rename from msg/sensor_accel_fifo.msg
rename to msg/SensorAccelFifo.msg
diff --git a/msg/sensor_baro.msg b/msg/SensorBaro.msg
similarity index 100%
rename from msg/sensor_baro.msg
rename to msg/SensorBaro.msg
diff --git a/msg/sensor_combined.msg b/msg/SensorCombined.msg
similarity index 100%
rename from msg/sensor_combined.msg
rename to msg/SensorCombined.msg
diff --git a/msg/sensor_correction.msg b/msg/SensorCorrection.msg
similarity index 100%
rename from msg/sensor_correction.msg
rename to msg/SensorCorrection.msg
diff --git a/msg/sensor_gps.msg b/msg/SensorGps.msg
similarity index 100%
rename from msg/sensor_gps.msg
rename to msg/SensorGps.msg
diff --git a/msg/sensor_gyro.msg b/msg/SensorGyro.msg
similarity index 100%
rename from msg/sensor_gyro.msg
rename to msg/SensorGyro.msg
diff --git a/msg/sensor_gyro_fft.msg b/msg/SensorGyroFft.msg
similarity index 100%
rename from msg/sensor_gyro_fft.msg
rename to msg/SensorGyroFft.msg
diff --git a/msg/sensor_gyro_fifo.msg b/msg/SensorGyroFifo.msg
similarity index 100%
rename from msg/sensor_gyro_fifo.msg
rename to msg/SensorGyroFifo.msg
diff --git a/msg/sensor_hygrometer.msg b/msg/SensorHygrometer.msg
old mode 100755
new mode 100644
similarity index 100%
rename from msg/sensor_hygrometer.msg
rename to msg/SensorHygrometer.msg
diff --git a/msg/sensor_mag.msg b/msg/SensorMag.msg
similarity index 100%
rename from msg/sensor_mag.msg
rename to msg/SensorMag.msg
diff --git a/msg/sensor_preflight_mag.msg b/msg/SensorPreflightMag.msg
similarity index 100%
rename from msg/sensor_preflight_mag.msg
rename to msg/SensorPreflightMag.msg
diff --git a/msg/sensor_selection.msg b/msg/SensorSelection.msg
similarity index 100%
rename from msg/sensor_selection.msg
rename to msg/SensorSelection.msg
diff --git a/msg/sensors_status_imu.msg b/msg/SensorsStatusImu.msg
similarity index 100%
rename from msg/sensors_status_imu.msg
rename to msg/SensorsStatusImu.msg
diff --git a/msg/system_power.msg b/msg/SystemPower.msg
similarity index 100%
rename from msg/system_power.msg
rename to msg/SystemPower.msg
diff --git a/msg/takeoff_status.msg b/msg/TakeoffStatus.msg
similarity index 100%
rename from msg/takeoff_status.msg
rename to msg/TakeoffStatus.msg
diff --git a/msg/task_stack_info.msg b/msg/TaskStackInfo.msg
similarity index 100%
rename from msg/task_stack_info.msg
rename to msg/TaskStackInfo.msg
diff --git a/msg/tecs_status.msg b/msg/TecsStatus.msg
similarity index 100%
rename from msg/tecs_status.msg
rename to msg/TecsStatus.msg
diff --git a/msg/telemetry_status.msg b/msg/TelemetryStatus.msg
similarity index 100%
rename from msg/telemetry_status.msg
rename to msg/TelemetryStatus.msg
diff --git a/msg/test_motor.msg b/msg/TestMotor.msg
similarity index 100%
rename from msg/test_motor.msg
rename to msg/TestMotor.msg
diff --git a/msg/timesync.msg b/msg/Timesync.msg
similarity index 100%
rename from msg/timesync.msg
rename to msg/Timesync.msg
diff --git a/msg/timesync_status.msg b/msg/TimesyncStatus.msg
similarity index 100%
rename from msg/timesync_status.msg
rename to msg/TimesyncStatus.msg
diff --git a/msg/trajectory_bezier.msg b/msg/TrajectoryBezier.msg
similarity index 100%
rename from msg/trajectory_bezier.msg
rename to msg/TrajectoryBezier.msg
diff --git a/msg/trajectory_waypoint.msg b/msg/TrajectoryWaypoint.msg
similarity index 100%
rename from msg/trajectory_waypoint.msg
rename to msg/TrajectoryWaypoint.msg
diff --git a/msg/transponder_report.msg b/msg/TransponderReport.msg
similarity index 100%
rename from msg/transponder_report.msg
rename to msg/TransponderReport.msg
diff --git a/msg/tune_control.msg b/msg/TuneControl.msg
similarity index 100%
rename from msg/tune_control.msg
rename to msg/TuneControl.msg
diff --git a/msg/uavcan_parameter_request.msg b/msg/UavcanParameterRequest.msg
similarity index 100%
rename from msg/uavcan_parameter_request.msg
rename to msg/UavcanParameterRequest.msg
diff --git a/msg/uavcan_parameter_value.msg b/msg/UavcanParameterValue.msg
similarity index 100%
rename from msg/uavcan_parameter_value.msg
rename to msg/UavcanParameterValue.msg
diff --git a/msg/ulog_stream.msg b/msg/UlogStream.msg
similarity index 100%
rename from msg/ulog_stream.msg
rename to msg/UlogStream.msg
diff --git a/msg/ulog_stream_ack.msg b/msg/UlogStreamAck.msg
similarity index 100%
rename from msg/ulog_stream_ack.msg
rename to msg/UlogStreamAck.msg
diff --git a/msg/vehicle_acceleration.msg b/msg/VehicleAcceleration.msg
similarity index 100%
rename from msg/vehicle_acceleration.msg
rename to msg/VehicleAcceleration.msg
diff --git a/msg/vehicle_air_data.msg b/msg/VehicleAirData.msg
similarity index 100%
rename from msg/vehicle_air_data.msg
rename to msg/VehicleAirData.msg
diff --git a/msg/vehicle_angular_acceleration.msg b/msg/VehicleAngularAcceleration.msg
similarity index 100%
rename from msg/vehicle_angular_acceleration.msg
rename to msg/VehicleAngularAcceleration.msg
diff --git a/msg/vehicle_angular_acceleration_setpoint.msg b/msg/VehicleAngularAccelerationSetpoint.msg
similarity index 100%
rename from msg/vehicle_angular_acceleration_setpoint.msg
rename to msg/VehicleAngularAccelerationSetpoint.msg
diff --git a/msg/vehicle_angular_velocity.msg b/msg/VehicleAngularVelocity.msg
similarity index 78%
rename from msg/vehicle_angular_velocity.msg
rename to msg/VehicleAngularVelocity.msg
index a8748772b7..547e124790 100644
--- a/msg/vehicle_angular_velocity.msg
+++ b/msg/VehicleAngularVelocity.msg
@@ -3,5 +3,3 @@ uint64 timestamp # time since system start (microseconds)
uint64 timestamp_sample # timestamp of the data sample on which this message is based (microseconds)
float32[3] xyz # Bias corrected angular velocity about the FRD body frame XYZ-axis in rad/s
-
-# TOPICS vehicle_angular_velocity vehicle_angular_velocity_groundtruth
diff --git a/msg/vehicle_attitude.msg b/msg/VehicleAttitude.msg
similarity index 80%
rename from msg/vehicle_attitude.msg
rename to msg/VehicleAttitude.msg
index a57b7c5058..e60fb354ae 100644
--- a/msg/vehicle_attitude.msg
+++ b/msg/VehicleAttitude.msg
@@ -7,6 +7,3 @@ uint64 timestamp_sample # the timestamp of the raw data (microseconds)
float32[4] q # Quaternion rotation from the FRD body frame to the NED earth frame
float32[4] delta_q_reset # Amount by which quaternion has changed during last reset
uint8 quat_reset_counter # Quaternion reset counter
-
-# TOPICS vehicle_attitude vehicle_attitude_groundtruth vehicle_vision_attitude
-# TOPICS estimator_attitude
diff --git a/msg/vehicle_attitude_setpoint.msg b/msg/VehicleAttitudeSetpoint.msg
similarity index 92%
rename from msg/vehicle_attitude_setpoint.msg
rename to msg/VehicleAttitudeSetpoint.msg
index 065fa12314..db79c9d17a 100644
--- a/msg/vehicle_attitude_setpoint.msg
+++ b/msg/VehicleAttitudeSetpoint.msg
@@ -23,5 +23,3 @@ uint8 apply_flaps # flap config specifier
uint8 FLAPS_OFF = 0 # no flaps
uint8 FLAPS_LAND = 1 # landing config flaps
uint8 FLAPS_TAKEOFF = 2 # take-off config flaps
-
-# TOPICS vehicle_attitude_setpoint mc_virtual_attitude_setpoint fw_virtual_attitude_setpoint
diff --git a/msg/vehicle_command.msg b/msg/VehicleCommand.msg
similarity index 99%
rename from msg/vehicle_command.msg
rename to msg/VehicleCommand.msg
index 9ddaad2a92..1979b9f9db 100644
--- a/msg/vehicle_command.msg
+++ b/msg/VehicleCommand.msg
@@ -175,5 +175,3 @@ uint8 source_system # System sending the command
uint8 source_component # Component sending the command
uint8 confirmation # 0: First transmission of this command. 1-255: Confirmation transmissions (e.g. for kill command)
bool from_external
-
-# TOPICS vehicle_command gimbal_v1_command
diff --git a/msg/vehicle_command_ack.msg b/msg/VehicleCommandAck.msg
similarity index 100%
rename from msg/vehicle_command_ack.msg
rename to msg/VehicleCommandAck.msg
diff --git a/msg/vehicle_constraints.msg b/msg/VehicleConstraints.msg
similarity index 100%
rename from msg/vehicle_constraints.msg
rename to msg/VehicleConstraints.msg
diff --git a/msg/vehicle_control_mode.msg b/msg/VehicleControlMode.msg
similarity index 100%
rename from msg/vehicle_control_mode.msg
rename to msg/VehicleControlMode.msg
diff --git a/msg/vehicle_global_position.msg b/msg/VehicleGlobalPosition.msg
similarity index 92%
rename from msg/vehicle_global_position.msg
rename to msg/VehicleGlobalPosition.msg
index ce16daecc8..49002ae796 100644
--- a/msg/vehicle_global_position.msg
+++ b/msg/VehicleGlobalPosition.msg
@@ -24,6 +24,3 @@ float32 terrain_alt # Terrain altitude WGS84, (metres)
bool terrain_alt_valid # Terrain altitude estimate is valid
bool dead_reckoning # True if this position is estimated through dead-reckoning
-
-# TOPICS vehicle_global_position vehicle_global_position_groundtruth
-# TOPICS estimator_global_position
diff --git a/msg/vehicle_gps_position.msg b/msg/VehicleGpsPosition.msg
similarity index 100%
rename from msg/vehicle_gps_position.msg
rename to msg/VehicleGpsPosition.msg
diff --git a/msg/vehicle_imu.msg b/msg/VehicleImu.msg
similarity index 100%
rename from msg/vehicle_imu.msg
rename to msg/VehicleImu.msg
diff --git a/msg/vehicle_imu_status.msg b/msg/VehicleImuStatus.msg
similarity index 100%
rename from msg/vehicle_imu_status.msg
rename to msg/VehicleImuStatus.msg
diff --git a/msg/vehicle_land_detected.msg b/msg/VehicleLandDetected.msg
similarity index 100%
rename from msg/vehicle_land_detected.msg
rename to msg/VehicleLandDetected.msg
diff --git a/msg/vehicle_local_position.msg b/msg/VehicleLocalPosition.msg
similarity index 97%
rename from msg/vehicle_local_position.msg
rename to msg/VehicleLocalPosition.msg
index 981fec4ba8..a0a23ce260 100644
--- a/msg/vehicle_local_position.msg
+++ b/msg/VehicleLocalPosition.msg
@@ -69,6 +69,3 @@ float32 vxy_max # maximum horizontal speed - set to 0 when limiting not requi
float32 vz_max # maximum vertical speed - set to 0 when limiting not required (meters/sec)
float32 hagl_min # minimum height above ground level - set to 0 when limiting not required (meters)
float32 hagl_max # maximum height above ground level - set to 0 when limiting not required (meters)
-
-# TOPICS vehicle_local_position vehicle_local_position_groundtruth
-# TOPICS estimator_local_position
diff --git a/msg/vehicle_local_position_setpoint.msg b/msg/VehicleLocalPositionSetpoint.msg
similarity index 89%
rename from msg/vehicle_local_position_setpoint.msg
rename to msg/VehicleLocalPositionSetpoint.msg
index 418cf5052b..1dfe4ec6c9 100644
--- a/msg/vehicle_local_position_setpoint.msg
+++ b/msg/VehicleLocalPositionSetpoint.msg
@@ -14,5 +14,3 @@ float32 vz # in meters/sec
float32[3] acceleration # in meters/sec^2
float32[3] jerk # in meters/sec^3
float32[3] thrust # normalized thrust vector in NED
-
-# TOPICS vehicle_local_position_setpoint trajectory_setpoint
diff --git a/msg/vehicle_magnetometer.msg b/msg/VehicleMagnetometer.msg
similarity index 100%
rename from msg/vehicle_magnetometer.msg
rename to msg/VehicleMagnetometer.msg
diff --git a/msg/vehicle_odometry.msg b/msg/VehicleOdometry.msg
similarity index 95%
rename from msg/vehicle_odometry.msg
rename to msg/VehicleOdometry.msg
index 5f597f4d96..f3104a6664 100644
--- a/msg/vehicle_odometry.msg
+++ b/msg/VehicleOdometry.msg
@@ -63,6 +63,3 @@ float32 yawspeed # Angular velocity about Z body axis
float32[21] velocity_covariance
uint8 reset_counter
-
-# TOPICS vehicle_odometry vehicle_mocap_odometry vehicle_visual_odometry
-# TOPICS estimator_odometry estimator_visual_odometry_aligned
diff --git a/msg/vehicle_rates_setpoint.msg b/msg/VehicleRatesSetpoint.msg
similarity index 100%
rename from msg/vehicle_rates_setpoint.msg
rename to msg/VehicleRatesSetpoint.msg
diff --git a/msg/vehicle_roi.msg b/msg/VehicleRoi.msg
similarity index 100%
rename from msg/vehicle_roi.msg
rename to msg/VehicleRoi.msg
diff --git a/msg/vehicle_status.msg b/msg/VehicleStatus.msg
similarity index 100%
rename from msg/vehicle_status.msg
rename to msg/VehicleStatus.msg
diff --git a/msg/vehicle_status_flags.msg b/msg/VehicleStatusFlags.msg
similarity index 100%
rename from msg/vehicle_status_flags.msg
rename to msg/VehicleStatusFlags.msg
diff --git a/msg/vehicle_thrust_setpoint.msg b/msg/VehicleThrustSetpoint.msg
similarity index 100%
rename from msg/vehicle_thrust_setpoint.msg
rename to msg/VehicleThrustSetpoint.msg
diff --git a/msg/vehicle_torque_setpoint.msg b/msg/VehicleTorqueSetpoint.msg
similarity index 100%
rename from msg/vehicle_torque_setpoint.msg
rename to msg/VehicleTorqueSetpoint.msg
diff --git a/msg/vehicle_trajectory_bezier.msg b/msg/VehicleTrajectoryBezier.msg
similarity index 86%
rename from msg/vehicle_trajectory_bezier.msg
rename to msg/VehicleTrajectoryBezier.msg
index 421ff1a015..ae6274733e 100644
--- a/msg/vehicle_trajectory_bezier.msg
+++ b/msg/VehicleTrajectoryBezier.msg
@@ -12,7 +12,5 @@ uint8 POINT_4 = 4
uint8 NUMBER_POINTS = 5
-trajectory_bezier[5] control_points
+px4/TrajectoryBezier[5] control_points
uint8 bezier_order
-
-# TOPICS vehicle_trajectory_bezier
diff --git a/msg/vehicle_trajectory_waypoint.msg b/msg/VehicleTrajectoryWaypoint.msg
similarity index 86%
rename from msg/vehicle_trajectory_waypoint.msg
rename to msg/VehicleTrajectoryWaypoint.msg
index 182f548d23..017f039183 100644
--- a/msg/vehicle_trajectory_waypoint.msg
+++ b/msg/VehicleTrajectoryWaypoint.msg
@@ -16,6 +16,4 @@ uint8 POINT_4 = 4
uint8 NUMBER_POINTS = 5
-trajectory_waypoint[5] waypoints
-
-# TOPICS vehicle_trajectory_waypoint vehicle_trajectory_waypoint_desired
+px4/TrajectoryWaypoint[5] waypoints
diff --git a/msg/vtol_vehicle_status.msg b/msg/VtolVehicleStatus.msg
similarity index 100%
rename from msg/vtol_vehicle_status.msg
rename to msg/VtolVehicleStatus.msg
diff --git a/msg/wheel_encoders.msg b/msg/WheelEncoders.msg
similarity index 100%
rename from msg/wheel_encoders.msg
rename to msg/WheelEncoders.msg
diff --git a/msg/wind.msg b/msg/Wind.msg
similarity index 96%
rename from msg/wind.msg
rename to msg/Wind.msg
index ff8b6f4535..7791159d6e 100644
--- a/msg/wind.msg
+++ b/msg/Wind.msg
@@ -12,5 +12,3 @@ float32 tas_innov_var # True airspeed innovation variance
float32 beta_innov # Sideslip measurement innovation
float32 beta_innov_var # Sideslip measurement innovation variance
-
-# TOPICS wind estimator_wind
diff --git a/msg/yaw_estimator_status.msg b/msg/YawEstimatorStatus.msg
similarity index 100%
rename from msg/yaw_estimator_status.msg
rename to msg/YawEstimatorStatus.msg
diff --git a/msg/orb_test_medium.msg b/msg/orb_test_medium.msg
deleted file mode 100644
index b25ae1c851..0000000000
--- a/msg/orb_test_medium.msg
+++ /dev/null
@@ -1,7 +0,0 @@
-uint64 timestamp # time since system start (microseconds)
-
-int32 val
-
-uint8[64] junk
-
-# TOPICS orb_test_medium orb_test_medium_multi orb_test_medium_wrap_around orb_test_medium_queue orb_test_medium_queue_poll
diff --git a/msg/templates/uorb/msg.cpp.em b/msg/templates/uorb/msg.cpp.em
deleted file mode 100644
index 03776549f5..0000000000
--- a/msg/templates/uorb/msg.cpp.em
+++ /dev/null
@@ -1,92 +0,0 @@
-@###############################################
-@#
-@# PX4 ROS compatible message source code
-@# generation for C++
-@#
-@# EmPy template for generating .h files
-@# Based on the original template for ROS
-@#
-@###############################################
-@# Start of Template
-@#
-@# Context:
-@# - file_name_in (String) Source file
-@# - spec (msggen.MsgSpec) Parsed specification of the .msg file
-@# - search_path (dict) search paths for genmsg
-@# - topics (List of String) multi-topic names
-@# - constrained_flash set to true if flash is constrained
-@###############################################
-/****************************************************************************
- *
- * Copyright (C) 2013-2021 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.
- *
- ****************************************************************************/
-
-/* Auto-generated by genmsg_cpp from file @file_name_in */
-
-@{
-import genmsg.msgs
-
-from px_generate_uorb_topic_helper import * # this is in Tools/
-
-uorb_struct = '%s_s'%spec.short_name
-topic_name = spec.short_name
-
-sorted_fields = sorted(spec.parsed_fields(), key=sizeof_field_type, reverse=True)
-struct_size, padding_end_size = add_padding_bytes(sorted_fields, search_path)
-topic_fields = ["%s %s" % (convert_type(field.type, True), field.name) for field in sorted_fields]
-}@
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-@# join all msg files in one line e.g: "float[3] position;float[3] velocity;bool armed"
-@# This is used for the logger
-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, static_cast(ORB_ID::@multi_topic));
-@[end for]
-
-void print_message(const orb_metadata *meta, const @uorb_struct& message)
-{
- if (sizeof(message) != meta->o_size) {
- printf("unexpected message size for %s: %zu != %i\n", meta->o_name, sizeof(message), meta->o_size);
- return;
- }
- orb_print_message_internal(meta, &message, true);
-}
diff --git a/msg/templates/uorb/msg.h.em b/msg/templates/uorb/msg.h.em
index 9854e1eaef..4bd9622a50 100644
--- a/msg/templates/uorb/msg.h.em
+++ b/msg/templates/uorb/msg.h.em
@@ -13,7 +13,7 @@
@# - file_name_in (String) Source file
@# - spec (msggen.MsgSpec) Parsed specification of the .msg file
@# - search_path (dict) search paths for genmsg
-@# - topics (List of String) multi-topic names
+@# - topics (List of String) topic names
@###############################################
/****************************************************************************
*
@@ -52,12 +52,17 @@
@{
import genmsg.msgs
+import re
from px_generate_uorb_topic_helper import * # this is in Tools/
-uorb_struct = '%s_s'%spec.short_name
-uorb_struct_upper = spec.short_name.upper()
-topic_name = spec.short_name
+px4_struct = '%s'%name_snake_case
+uorb_struct = '%s_s'%name_snake_case
+uorb_struct_upper = name_snake_case.upper()
+
+sorted_fields = sorted(spec.parsed_fields(), key=sizeof_field_type, reverse=True)
+struct_size, padding_end_size = add_padding_bytes(sorted_fields, search_path)
+topic_fields = ["%s %s" % (convert_type(field.type, True), field.name) for field in sorted_fields]
}@
#pragma once
@@ -67,6 +72,7 @@ topic_name = spec.short_name
@##############################
#include
+#include
@##############################
@# Includes for dependencies
@@ -77,9 +83,16 @@ for field in spec.parsed_fields():
if (not field.is_header):
(package, name) = genmsg.names.package_resource_name(field.base_type)
package = package or spec.package # convert '' to package
+
+ name = re.sub(r'(?'%(name))
}@
+
+#ifdef __PX4_ROS2
+namespace px4_embedded {
+#endif // __PX4_ROS2
+
@# Constants c style
#ifndef __cplusplus
@[for constant in spec.constants]@
@@ -124,14 +137,70 @@ for constant in spec.constants:
print('\tstatic constexpr %s %s = %s;'%(type_px4, constant.name, int(constant.val)))
}
+
+ static constexpr char FIELDS[] = "@( ";".join(topic_fields) );";
+ static constexpr size_t SIZE_NO_PADDING = @(struct_size-padding_end_size);
+
#endif
};
-/* register this as object request broker structure */
-@[for multi_topic in topics]@
-ORB_DECLARE(@multi_topic);
-@[end for]
+
+#if defined(__PX4_ROS2)
+} // namespace px4_embedded
+
+#include "px4/msg/@(px4_struct).hpp"
+using @(uorb_struct) = px4::msg::@(spec.short_name);
+
+inline px4::msg::@(spec.short_name) px4_embedded_to_ros2(const px4_embedded::@(uorb_struct)& msg_in)
+{
+ px4::msg::@(spec.short_name) msg_out;
+@{
+for field in spec.parsed_fields():
+
+ #print(field, field.is_builtin, field.base_type, field.is_array, field.array_len)
+
+ if field.is_builtin and not field.is_array:
+ print(" msg_out.%s = msg_in.%s;" % (field.name, field.name))
+ elif field.is_builtin and field.is_array:
+ print(" std::copy(std::begin(msg_in.%s), std::end(msg_in.%s), msg_out.%s.begin());" % (field.name, field.name, field.name))
+ elif not field.is_builtin:
+ #print(" msg_out.%s = px4_embedded_to_ros2(msg_in.%s);" % (field.name, field.name))
+ print(" // %s.%s not printed" % (name_snake_case, field.name))
+ else:
+ print(" #error %s.%s not printed" % (name_snake_case, field.name))
+
+}@
+
+ return msg_out;
+}
+
+
+#else
+
+# ifdef __cplusplus
+namespace px4 {
+ namespace msg {
+ using @(spec.short_name) = @(uorb_struct);
+ } // namespace msg
+} // namespace px4
+
+namespace px4_embedded {
+ using @(uorb_struct) = @(uorb_struct);
+}
+
+# endif
+
+#endif // PX4_ROS2
#ifdef __cplusplus
-void print_message(const orb_metadata *meta, const @uorb_struct& message);
+
+inline void print_message(const orb_metadata *meta, const @uorb_struct& message)
+{
+ if (sizeof(message) != meta->o_size) {
+ printf("unexpected message size for %s: %zu != %i\n", meta->o_name, sizeof(message), meta->o_size);
+ return;
+ }
+ orb_print_message_internal(meta, &message, true);
+}
+
#endif
diff --git a/msg/templates/uorb/uORBTopics.cpp.em b/msg/templates/uorb/uORBTopics.cpp.em
index b08950bb19..bca3139eb0 100644
--- a/msg/templates/uorb/uORBTopics.cpp.em
+++ b/msg/templates/uorb/uORBTopics.cpp.em
@@ -1,18 +1,6 @@
-@###############################################
-@#
-@# EmPy template for generating uORBTopics.cpp file
-@# for logging purposes
-@#
-@###############################################
-@# Start of Template
-@#
-@# Context:
-@# - msgs (List) list of all msg files
-@# - multi_topics (List) list of all multi-topic names
-@###############################################
/****************************************************************************
*
- * Copyright (C) 2013-2021 PX4 Development Team. All rights reserved.
+ * Copyright (C) 2021 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
@@ -43,23 +31,23 @@
*
****************************************************************************/
-#include
#include
-@{
-msg_names = [mn.replace(".msg", "") for mn in msgs]
-msgs_count = len(msg_names)
-msg_names_all = list(set(msg_names + multi_topics)) # set() filters duplicates
-msg_names_all.sort()
-msgs_count_all = len(msg_names_all)
-}@
-@[for msg_name in msg_names]@
-#include
-@[end for]
+
+#include "uORBTopics.hpp"
+
+// ORB_DEFINE(action_request, px4::msg::ActionRequest, px4_embedded::action_request_s::SIZE_NO_PADDING, px4_embedded::action_request_s::FIELDS, static_cast(ORB_ID::action_request));
+// ORB_DEFINE(actuator_armed, px4::msg::ActuatorArmed, px4_embedded::actuator_armed_s::SIZE_NO_PADDING, px4_embedded::actuator_armed_s::FIELDS, static_cast(ORB_ID::actuator_armed));
+
+//const constexpr struct orb_metadata *const uorb_topics_list[ORB_TOPICS_COUNT] = {
+// ORB_ID(action_request),
+// ORB_ID(actuator_armed),
+
+
+
+@PX4_ORB_DEFINE_STR@
const constexpr struct orb_metadata *const uorb_topics_list[ORB_TOPICS_COUNT] = {
-@[for idx, msg_name in enumerate(msg_names_all, 1)]@
- ORB_ID(@(msg_name))@[if idx != msgs_count_all], @[end if]
-@[end for]
+@PX4_MSG_TOPIC_ORB_ID@
};
const struct orb_metadata *const *orb_get_topics()
diff --git a/msg/templates/uorb/uORBTopics.hpp.em b/msg/templates/uorb/uORBTopics.hpp.em
index d278f06398..49267105c6 100644
--- a/msg/templates/uorb/uORBTopics.hpp.em
+++ b/msg/templates/uorb/uORBTopics.hpp.em
@@ -57,14 +57,32 @@ msgs_count_all = len(msg_names_all)
#include
-static constexpr size_t ORB_TOPICS_COUNT{@(msgs_count_all)};
+// TODO: ros2 friendly include paths
+//#include
+//#include
+
+
+@PX4_ORB_HEADER_INCLUDE_STR@
+
+static constexpr size_t ORB_TOPICS_COUNT{@PX4_ORB_TOPIC_COUNT@};
static constexpr size_t orb_topics_count() { return ORB_TOPICS_COUNT; }
+
+// ORB_DECLARE(action_request);
+// ORB_DECLARE(actuator_armed);
+
+@PX4_ORB_DECLARE_STR@
+
/*
* Returns array of topics metadata
*/
extern const struct orb_metadata *const *orb_get_topics() __EXPORT;
+
+// enum class ORB_ID : uint8_t {
+// action_request,
+// actuator_armed,
+
enum class ORB_ID : uint8_t {
@[for idx, msg_name in enumerate(msg_names_all)]@
@(msg_name) = @(idx),
@@ -73,3 +91,18 @@ enum class ORB_ID : uint8_t {
};
const struct orb_metadata *get_orb_meta(ORB_ID id);
+
+
+static constexpr const char *get_topic_string(ORB_ID orb_id)
+{
+ switch (orb_id) {
+ //case ORB_ID::action_request: return "action_request";
+ //case ORB_ID::actuator_armed: return "actuator_armed";
+
+@[for idx, msg_name in enumerate(msg_names_all)]@
+ case @(msg_name): return "@(msg_name)";
+@[end for]
+ }
+
+ return nullptr;
+}
diff --git a/msg/templates/uorb_microcdr/microRTPS_client.cpp.em b/msg/templates/uorb_microcdr/microRTPS_client.cpp.em
deleted file mode 100644
index 941073b17f..0000000000
--- a/msg/templates/uorb_microcdr/microRTPS_client.cpp.em
+++ /dev/null
@@ -1,306 +0,0 @@
-@###############################################
-@#
-@# EmPy template for generating microRTPS_client.cpp file
-@#
-@###############################################
-@# Start of Template
-@#
-@# Context:
-@# - msgs (List) list of all RTPS messages
-@# - multi_topics (List) list of all multi-topic names
-@# - spec (msggen.MsgSpec) Parsed specification of the .msg file
-@###############################################
-@{
-import os
-
-import genmsg.msgs
-
-from px_generate_uorb_topic_files import MsgScope # this is in Tools/
-
-topic_names = [s.short_name for s in spec]
-send_topics = [(alias[idx] if alias[idx] else s.short_name) for idx, s in enumerate(spec) if scope[idx] == MsgScope.SEND]
-send_base_types = [s.short_name for idx, s in enumerate(spec) if scope[idx] == MsgScope.SEND]
-recv_topics = [(alias[idx] if alias[idx] else s.short_name) for idx, s in enumerate(spec) if scope[idx] == MsgScope.RECEIVE]
-receive_base_types = [s.short_name for idx, s in enumerate(spec) if scope[idx] == MsgScope.RECEIVE]
-}@
-/****************************************************************************
- *
- * Copyright (c) 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
- * Copyright (c) 2018-2021 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 of the copyright holder 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 HOLDER 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.
- *
- ****************************************************************************/
-
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-
-#include
-#include
-@[for topic in list(set(topic_names))]@
-#include
-#include
-@[end for]@
-
-using namespace time_literals;
-
-@[if recv_topics]@
-// Publishers for received messages
-struct RcvTopicsPubs {
-@[ for idx, topic in enumerate(recv_topics)]@
- uORB::Publication <@(receive_base_types[idx])_s> @(topic)_pub{ORB_ID(@(topic))};
-@[ end for]@
-};
-@[end if]@
-
-@[if send_topics]@
-// Subscribers for messages to send
-struct SendTopicsSubs {
-@[ for idx, topic in enumerate(send_topics)]@
- uORB::Subscription @(topic)_sub{ORB_ID(@(topic))};
-@[ end for]@
-};
-
-struct SendThreadArgs {
- const uint32_t &datarate;
- uint64_t &total_sent;
- uint64_t &sent_last_sec;
- uint64_t &sent;
- int &sent_loop;
- SendThreadArgs(const uint32_t &datarate_, uint64_t &total_sent_,
- uint64_t &sent_last_sec_, uint64_t &sent_, int &sent_loop_)
- : datarate(datarate_),
- total_sent(total_sent_),
- sent_last_sec(sent_last_sec_),
- sent(sent_),
- sent_loop(sent_loop_) {}
-};
-
-void *send(void *args)
-{
- char data_buffer[BUFFER_SIZE]{};
- int read{0};
- uint32_t length{0};
- size_t header_length{0};
- uint8_t last_msg_seq{0};
- uint8_t last_remote_msg_seq{0};
-
- struct SendThreadArgs *data = reinterpret_cast(args);
- SendTopicsSubs *subs = new SendTopicsSubs();
-
- float bandwidth_mult{0};
- float tx_interval{1.f};
- uint64_t tx_last_sec_read{0};
- hrt_abstime last_stats_update{0};
-
- // ucdrBuffer to serialize using the user defined buffer
- ucdrBuffer writer;
- header_length = transport_node->get_header_length();
- ucdr_init_buffer(&writer, reinterpret_cast(&data_buffer[header_length]), BUFFER_SIZE - header_length);
-
- while (!_should_exit_task) {
-@[ for idx, topic in enumerate(send_topics)]@
- {
- @(send_base_types[idx])_s @(topic)_data;
-
- if (subs->@(topic)_sub.update(&@(topic)_data))
- {
-@[ if topic == 'Timesync' or topic == 'timesync']@
- if (@(topic)_data.seq != last_remote_msg_seq && @(topic)_data.tc1 == 0) {
- last_remote_msg_seq = @(topic)_data.seq;
-
- @(topic)_data.timestamp = hrt_absolute_time();
- @(topic)_data.seq = last_msg_seq;
- @(topic)_data.tc1 = hrt_absolute_time() * 1000ULL;
- @(topic)_data.ts1 = @(topic)_data.ts1;
-
- last_msg_seq++;
-@[ end if]@
- // copy raw data into local buffer. Payload is shifted by header length to make room for header
- serialize_@(send_base_types[idx])(&writer, &@(topic)_data, &data_buffer[header_length], &length);
-
- if (0 < (read = transport_node->write(static_cast(@(msgs[0].index(topic) + 1)), data_buffer, length))) {
- data->total_sent += read;
- tx_last_sec_read += read;
- ++data->sent;
- }
-
-@[ if topic == 'Timesync' or topic == 'timesync']@
- }
-
-@[ end if]@
- }
- }
-@[ end for]@
-
- if (hrt_absolute_time() - last_stats_update >= 1_s) {
- data->sent_last_sec = tx_last_sec_read;
- if (data->datarate > 0) {
- bandwidth_mult = static_cast(data->datarate) / static_cast(tx_last_sec_read);
- // Apply a low-pass filter to determine the new TX interval
- tx_interval += 0.5f * (tx_interval / bandwidth_mult - tx_interval);
- // Clamp the interval between 1 and 1000 ms
- tx_interval = math::constrain(tx_interval, MIN_TX_INTERVAL_US, MAX_TX_INTERVAL_US);
- }
- tx_last_sec_read = 0;
- last_stats_update = hrt_absolute_time();
- }
-
- px4_usleep(tx_interval);
-
- ++data->sent_loop;
- }
-
- delete(data);
- delete(subs);
-
- return nullptr;
-}
-
-static int launch_send_thread(pthread_t &sender_thread, struct SendThreadArgs &args)
-{
- pthread_attr_t sender_thread_attr;
- pthread_attr_init(&sender_thread_attr);
- pthread_attr_setstacksize(&sender_thread_attr, PX4_STACK_ADJUSTED(2250));
- struct sched_param param;
- (void)pthread_attr_getschedparam(&sender_thread_attr, ¶m);
- param.sched_priority = SCHED_PRIORITY_DEFAULT;
- (void)pthread_attr_setschedparam(&sender_thread_attr, ¶m);
- int rc = pthread_create(&sender_thread, &sender_thread_attr, &send, (void *)&args);
- if (rc != 0) {
- errno = rc;
- PX4_ERR("Could not create send thread (%d)", errno);
- return -1;
- }
- rc = pthread_setname_np(sender_thread, "urtpsclient_snd");
- if (pthread_setname_np(sender_thread, "urtpsclient_snd")) {
- errno = rc;
- PX4_ERR("Could not set pthread name for the send thread (%d)", errno);
- }
- pthread_attr_destroy(&sender_thread_attr);
-
- return 0;
-}
-@[end if]@
-
-void micrortps_start_topics(const uint32_t &datarate, struct timespec &begin, uint64_t &total_rcvd,
- uint64_t &total_sent, uint64_t &sent_last_sec,
- uint64_t &rcvd_last_sec, uint64_t &received, uint64_t &sent, int &rcvd_loop, int &sent_loop)
-{
- px4_clock_gettime(CLOCK_REALTIME, &begin);
- _should_exit_task = false;
-
-@[if recv_topics]@
- char data_buffer[BUFFER_SIZE]{};
- int read{0};
- uint8_t topic_ID{255};
-
- uint64_t rx_last_sec_read{0};
- hrt_abstime last_stats_update{0};
-
- RcvTopicsPubs *pubs = new RcvTopicsPubs();
-
- // Set the main task name to 'urtpsclient_rcv' in case there is
- // data to receive
- px4_prctl(PR_SET_NAME, "urtpsclient_rcv", px4_getpid());
-
- // ucdrBuffer to deserialize using the user defined buffer
- ucdrBuffer reader;
- ucdr_init_buffer(&reader, reinterpret_cast(data_buffer), BUFFER_SIZE);
-@[end if]@
-
-@[if send_topics]@
- // var struct to be updated on the thread
- SendThreadArgs *sender_thread_args = new SendThreadArgs(datarate, total_sent, sent_last_sec, sent, sent_loop);
-
- // create a thread for sending data
- pthread_t sender_thread;
- launch_send_thread(sender_thread, (*sender_thread_args));
-@[end if]@
-
- while (!_should_exit_task) {
-@[if recv_topics]@
- while (0 < (read = transport_node->read(&topic_ID, data_buffer, BUFFER_SIZE))) {
- total_rcvd += read;
- rx_last_sec_read += read;
-
- uint64_t read_time = hrt_absolute_time();
-
- switch (topic_ID) {
-@[ for idx, topic in enumerate(recv_topics)]@
- case @(msgs[0].index(topic) + 1): {
- @(receive_base_types[idx])_s @(topic)_data;
- deserialize_@(receive_base_types[idx])(&reader, &@(topic)_data, data_buffer);
-
- if (@(topic)_data.timestamp > read_time) {
- // don't allow timestamps from the future
- @(topic)_data.timestamp = read_time;
- }
-
- pubs->@(topic)_pub.publish(@(topic)_data);
- ++received;
- }
- break;
-@[ end for]@
- default:
- PX4_WARN("Unexpected topic ID '%hhu' to getMsg. Please make sure the client is capable of parsing the message associated to the topic ID '%hhu'",
- topic_ID, topic_ID);
- break;
- }
- }
-@[end if]@
-
- if (hrt_absolute_time() - last_stats_update >= 1_s) {
- rcvd_last_sec = rx_last_sec_read;
- rx_last_sec_read = 0;
- last_stats_update = hrt_absolute_time();
- }
-
- // loop forever if informed loop number is negative
- if (_options.loops >= 0 && rcvd_loop >= _options.loops) { break; }
-
- px4_usleep(_options.sleep_us);
- ++rcvd_loop;
- }
-
-@[if send_topics]@
- _should_exit_task = true;
- pthread_join(sender_thread, nullptr);
-@[end if]@
-@[if recv_topics]@
- delete(pubs);
-@[end if]@
-}
diff --git a/msg/templates/uorb_microcdr/msg.cpp.em b/msg/templates/uorb_microcdr/msg.cpp.em
deleted file mode 100644
index 458f455f49..0000000000
--- a/msg/templates/uorb_microcdr/msg.cpp.em
+++ /dev/null
@@ -1,156 +0,0 @@
-@###############################################
-@#
-@# PX4 ROS compatible message source code
-@# generation for C++
-@#
-@# EmPy template for generating .h files
-@# Based on the original template for ROS
-@#
-@###############################################
-@# Start of Template
-@#
-@# Context:
-@# - file_name_in (String) Source file
-@# - spec (msggen.MsgSpec) Parsed specification of the .msg file
-@# - search_path (dict) search paths for genmsg
-@###############################################
-/****************************************************************************
- *
- * Copyright (C) 2013-2021 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.
- *
- ****************************************************************************/
-
-/* Auto-generated by genmsg_cpp from file @file_name_in */
-
-@{
-import genmsg.msgs
-
-from px_generate_uorb_topic_helper import * # this is in Tools/
-
-uorb_struct = '%s_s'%spec.short_name
-topic_name = spec.short_name
-}@
-
-#include
-#include
-#include
-#include
-
-@#################################################
-@# Searching for serialize function per each field
-@#################################################
-@{
-
-def print_info(field):
- print("type: ", field.type, "name: ", field.name, "base_type: ", \
- field.base_type, "field.is_array:", ('0', '1')[field.is_array], " array_len: ", field.array_len, \
- "is_builtin:", ('0', '1')[field.is_builtin], "is_header:", ('0', '1')[field.is_header])
-
-def print_level_info(fields):
- for field in fields:
- print_info(field)
- if (not field.is_builtin):
- print("\n")
- children_fields = get_children_fields(field.base_type, search_path)
- print_level_info(children_fields)
- print("\n")
-
-def walk_through_parsed_fields():
- print_level_info(spec.parsed_fields())
-
-def get_serialization_type_name(type_name):
- if type_name in type_serialize_map:
- return type_serialize_map[type_name]
- else:
- raise Exception("Type {0} not supported, add to type_serialize_map!".format(type_name))
-
-def add_serialize_functions(fields, scope_name):
- for field in fields:
- if (not field.is_header):
- if (field.is_builtin):
- if (not field.is_array):
- print(" ucdr_serialize_" + str(get_serialization_type_name(field.type)) + "(writer, input->" + scope_name+str(field.name) + ");")
- else:
- print(" ucdr_serialize_array_" + str(get_serialization_type_name(field.base_type)) + "(writer, input->" + scope_name+str(field.name) + ", " + str(field.array_len) + ");")
- else:
- name = field.name
- children_fields = get_children_fields(field.base_type, search_path)
- if (scope_name): name = scope_name + name
- if (not field.is_array):
- add_serialize_functions(children_fields, name + '.')
- else:
- for i in range(field.array_len):
- add_serialize_functions(children_fields, name + ('[%d].' %i))
-
-def add_deserialize_functions(fields, scope_name):
- for field in fields:
- if (not field.is_header):
- if (field.is_builtin):
- if (not field.is_array):
- print(" ucdr_deserialize_" + str(get_serialization_type_name(field.type)) + "(reader, &output->" + scope_name+str(field.name) + ");")
- else:
- print(" ucdr_deserialize_array_" + str(get_serialization_type_name(field.base_type)) + "(reader, output->" + scope_name+str(field.name) + ", " + str(field.array_len) + ");")
- else:
- name = field.name
- children_fields = get_children_fields(field.base_type, search_path)
- if (scope_name): name = scope_name + name
- if (not field.is_array):
- add_deserialize_functions(children_fields, name + '.')
- else:
- for i in range(field.array_len):
- add_deserialize_functions(children_fields, name + ('[%d].' %i))
-
-def add_code_to_serialize():
- add_serialize_functions(spec.parsed_fields(), "")
-
-def add_code_to_deserialize():
- add_deserialize_functions(spec.parsed_fields(), "")
-}@
-
-void serialize_@(topic_name)(ucdrBuffer *writer, const struct @(uorb_struct) *input, char *output, uint32_t *length)
-{
- if (nullptr == writer || nullptr == input || nullptr == output || nullptr == length)
- return;
-
- ucdr_reset_buffer(writer);
-
-@add_code_to_serialize()
- (*length) = ucdr_buffer_length(writer);
-}
-
-void deserialize_@(topic_name)(ucdrBuffer *reader, struct @(uorb_struct) *output, const char *input)
-{
- if (nullptr == reader || nullptr == output || nullptr == input)
- return;
-
- ucdr_reset_buffer(reader);
-
-@add_code_to_deserialize()
-}
diff --git a/msg/templates/urtps/Publisher.cpp.em b/msg/templates/urtps/Publisher.cpp.em
deleted file mode 100644
index 86687f06a1..0000000000
--- a/msg/templates/urtps/Publisher.cpp.em
+++ /dev/null
@@ -1,219 +0,0 @@
-@###############################################
-@#
-@# EmPy template for generating _uRTPS_UART.cpp file
-@#
-@###############################################
-@# Start of Template
-@#
-@# Context:
-@# - fastrtps_version (str) FastRTPS version installed on the system
-@# - ros2_distro (str) ROS2 distro name
-@# - spec (msggen.MsgSpec) Parsed specification of the .msg file
-@###############################################
-@{
-import genmsg.msgs
-from packaging import version
-import re
-
-topic = alias if alias else spec.short_name
-
-try:
- ros2_distro = ros2_distro.decode("utf-8")
-except AttributeError:
- pass
-
-topic_name = topic
-
-# For ROS, use the topic pattern convention defined in
-# http://wiki.ros.org/ROS/Patterns/Conventions
-if ros2_distro:
- topic_name_split = re.sub( r"([A-Z])", r" \1", topic).split()
- topic_name = topic_name_split[0]
- for w in topic_name_split[1:]:
- topic_name += "_" + w
- topic_name = topic_name.lower()
-}@
-/****************************************************************************
- *
- * Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
- * Copyright (c) 2018-2021 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 of the copyright holder 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 HOLDER 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.
- *
- ****************************************************************************/
-
-/*!
- * @@file @(topic)_Publisher.cpp
- * This file contains the implementation of the publisher functions.
- *
- * This file was adapted from the fastrtpsgen tool.
- */
-
-#include "@(topic)_Publisher.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-@[if version.parse(fastrtps_version) >= version.parse('2.0')]@
-#include
-
-using SharedMemTransportDescriptor = eprosima::fastdds::rtps::SharedMemTransportDescriptor;
-@[end if]@
-
-
-@(topic)_Publisher::@(topic)_Publisher()
- : mp_participant(nullptr),
- mp_publisher(nullptr)
-{ }
-
-@(topic)_Publisher::~@(topic)_Publisher()
-{
- Domain::removeParticipant(mp_participant);
-}
-
-bool @(topic)_Publisher::init(const std::string &ns, std::string topic_name)
-{
- // Create RTPSParticipant
- ParticipantAttributes PParam;
-@[if version.parse(fastrtps_version) < version.parse('2.0')]@
- PParam.rtps.builtin.domainId = 0;
-@[else]@
- PParam.domainId = 0;
-@[end if]@
-@[if version.parse(fastrtps_version) <= version.parse('1.8.4')]@
- PParam.rtps.builtin.leaseDuration = c_TimeInfinite;
-@[else]@
- PParam.rtps.builtin.discovery_config.leaseDuration = c_TimeInfinite;
-@[end if]@
-@[if ros2_distro]@
- // ROS2 default memory management policy
- PParam.rtps.builtin.writerHistoryMemoryPolicy = PREALLOCATED_WITH_REALLOC_MEMORY_MODE;
-@[end if]@
- std::string nodeName = ns;
- nodeName.append("@(topic)_publisher");
- PParam.rtps.setName(nodeName.c_str());
-
-@[if ros2_distro]@
- // Check if ROS_LOCALHOST_ONLY is set. This means that one wants to use only
- // the localhost network for data sharing. If FastRTPS/DDS >= 2.0 and
- // RMW_IMPLEMENTATION is FastDDS then the Shared Memory transport is used
- const char* localhost_only = std::getenv("ROS_LOCALHOST_ONLY");
- const char* rmw_implementation = std::getenv("RMW_IMPLEMENTATION");
- const char* ros_distro = std::getenv("ROS_DISTRO");
- if (localhost_only && strcmp(localhost_only, "1") == 0
- && ((rmw_implementation && ((strcmp(rmw_implementation, "rmw_fastrtps_cpp") == 0)
- || (strcmp(rmw_implementation, "rmw_fastrtps_dynamic_cpp") == 0)))
- || (!rmw_implementation && ros_distro && strcmp(ros_distro, "foxy") == 0))) {
- // Create a custom network UDPv4 transport descriptor
- // to whitelist the localhost
- auto localhostUdpTransport = std::make_shared();
- localhostUdpTransport->interfaceWhiteList.emplace_back("127.0.0.1");
-
- // Disable the built-in Transport Layer
- PParam.rtps.useBuiltinTransports = false;
-
- // Add the descriptor as a custom user transport
- PParam.rtps.userTransports.push_back(localhostUdpTransport);
-
-@[ if version.parse(fastrtps_version) >= version.parse('2.0')]@
- // Add shared memory transport when available
- auto shmTransport = std::make_shared();
- PParam.rtps.userTransports.push_back(shmTransport);
-@[ end if]@
- }
-@[end if]@
-
- mp_participant = Domain::createParticipant(PParam);
-
- if (mp_participant == nullptr) {
- return false;
- }
-
- // Register the type
- Domain::registerType(mp_participant, static_cast(&@(topic)DataType));
-
- // Create Publisher
- PublisherAttributes Wparam;
- Wparam.topic.topicKind = NO_KEY;
- Wparam.topic.topicDataType = @(topic)DataType.getName();
-@[if ros2_distro]@
-@[ if ros2_distro == "ardent"]@
- Wparam.qos.m_partition.push_back("rt");
- std::string topicName = ns;
-@[ else]@
- std::string topicName = "rt/";
- topicName.append(ns);
-@[ end if]@
- // ROS2 default publish mode QoS policy
- Wparam.qos.m_publishMode.kind = ASYNCHRONOUS_PUBLISH_MODE;
-@[else]@
- std::string topicName = ns;
-@[end if]@
- topic_name.empty() ? topicName.append("fmu/@(topic_name)/out") : topicName.append(topic_name);
- Wparam.topic.topicName = topicName;
- mp_publisher = Domain::createPublisher(mp_participant, Wparam, static_cast(&m_listener));
-
- if (mp_publisher == nullptr) {
- return false;
- }
-
- return true;
-}
-
-void @(topic)_Publisher::PubListener::onPublicationMatched(Publisher *pub, MatchingInfo &info)
-{
- // The first 6 values of the ID guidPrefix of an entity in a DDS-RTPS Domain
- // are the same for all its subcomponents (publishers, subscribers)
- bool is_different_endpoint = false;
-
- for (size_t i = 0; i < 6; i++) {
- if (pub->getGuid().guidPrefix.value[i] != info.remoteEndpointGuid.guidPrefix.value[i]) {
- is_different_endpoint = true;
- break;
- }
- }
-
- // If the matching happens for the same entity, do not make a match
- if (is_different_endpoint) {
- if (info.status == MATCHED_MATCHING) {
- n_matched++;
- std::cout << "\033[0;37m[ micrortps_agent ]\t@(topic) publisher matched\033[0m" << std::endl;
-
- } else {
- n_matched--;
- std::cout << "\033[0;37m[ micrortps_agent ]\t@(topic) publisher unmatched\033[0m" << std::endl;
- }
- }
-}
-
-void @(topic)_Publisher::publish(@(topic)_msg_t *st)
-{
- mp_publisher->write(st);
-}
diff --git a/msg/templates/urtps/Publisher.h.em b/msg/templates/urtps/Publisher.h.em
deleted file mode 100644
index 6851497d2a..0000000000
--- a/msg/templates/urtps/Publisher.h.em
+++ /dev/null
@@ -1,120 +0,0 @@
-@###############################################
-@#
-@# EmPy template for generating _uRTPS_UART.cpp file
-@#
-@###############################################
-@# Start of Template
-@#
-@# Context:
-@# - ros2_distro (str) ROS2 distro name
-@# - spec (msggen.MsgSpec) Parsed specification of the .msg file
-@###############################################
-@{
-import genmsg.msgs
-from packaging import version
-import re
-
-topic = alias if alias else spec.short_name
-try:
- ros2_distro = ros2_distro.decode("utf-8")
-except AttributeError:
- pass
-}@
-/****************************************************************************
- *
- * Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
- * Copyright (c) 2018-2021 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 of the copyright holder 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 HOLDER 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.
- *
- ****************************************************************************/
-
-/*!
- * @@file @(topic)_Publisher.h
- * This header file contains the declaration of the publisher functions.
- *
- * This file was adapted from the fastrtpsgen tool.
- */
-
-
-#ifndef _@(topic)__PUBLISHER_H_
-#define _@(topic)__PUBLISHER_H_
-
-#include
-#include
-
-@[if version.parse(fastrtps_version) <= version.parse('1.7.2')]@
-#include "@(topic)_PubSubTypes.h"
-@[else]@
-#include "@(topic)PubSubTypes.h"
-@[end if]@
-
-using namespace eprosima::fastrtps;
-using namespace eprosima::fastrtps::rtps;
-
-@[if version.parse(fastrtps_version) <= version.parse('1.7.2')]@
-@[ if ros2_distro]@
-using @(topic)_msg_t = @(package)::msg::dds_::@(topic)_;
-using @(topic)_msg_datatype = @(package)::msg::dds_::@(topic)_PubSubType;
-@[ else]@
-using @(topic)_msg_t = @(topic)_;
-using @(topic)_msg_datatype = @(topic)_PubSubType;
-@[ end if]@
-@[else]@
-@[ if ros2_distro]@
-using @(topic)_msg_t = @(package)::msg::@(topic);
-using @(topic)_msg_datatype = @(package)::msg::@(topic)PubSubType;
-@[ else]@
-using @(topic)_msg_t = @(topic);
-using @(topic)_msg_datatype = @(topic)PubSubType;
-@[ end if]@
-@[end if]@
-
-class @(topic)_Publisher
-{
-public:
- @(topic)_Publisher();
- virtual ~@(topic)_Publisher();
- bool init(const std::string &ns, std::string topic_name = "");
- void run();
- void publish(@(topic)_msg_t *st);
-private:
- Participant *mp_participant;
- Publisher *mp_publisher;
-
- class PubListener : public PublisherListener
- {
- public:
- PubListener() : n_matched(0) {};
- ~PubListener() {};
- void onPublicationMatched(Publisher *pub, MatchingInfo &info);
- int n_matched;
- } m_listener;
- @(topic)_msg_datatype @(topic)DataType;
-};
-
-#endif // _@(topic)__PUBLISHER_H_
diff --git a/msg/templates/urtps/RtpsTopics.cpp.em b/msg/templates/urtps/RtpsTopics.cpp.em
deleted file mode 100644
index be1d8d2045..0000000000
--- a/msg/templates/urtps/RtpsTopics.cpp.em
+++ /dev/null
@@ -1,187 +0,0 @@
-@###############################################
-@#
-@# EmPy template for generating RtpsTopics.cpp file
-@#
-@###############################################
-@# Start of Template
-@#
-@# Context:
-@# - spec (msggen.MsgSpec) Parsed specification of the .msg file
-@###############################################
-@{
-import genmsg.msgs
-import os
-from px_generate_uorb_topic_files import MsgScope # this is in Tools/
-
-send_topics = [(alias[idx] if alias[idx] else s.short_name) for idx, s in enumerate(spec) if scope[idx] == MsgScope.SEND]
-recv_topics = [(alias[idx] if alias[idx] else s.short_name) for idx, s in enumerate(spec) if scope[idx] == MsgScope.RECEIVE]
-}@
-/****************************************************************************
- *
- * Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
- * Copyright (c) 2018-2021 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 of the copyright holder 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 HOLDER 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.
- *
- ****************************************************************************/
-
-#include "RtpsTopics.h"
-
-bool RtpsTopics::init(std::condition_variable *t_send_queue_cv, std::mutex *t_send_queue_mutex,
- std::queue *t_send_queue, const std::string &ns)
-{
-@[if recv_topics]@
- // Initialise subscribers
- std::cout << "\033[0;36m--- Subscribers ---\033[0m" << std::endl;
-@[for topic in recv_topics]@
-
- if (_@(topic)_sub.init(@(msgs[0].index(topic) + 1), t_send_queue_cv, t_send_queue_mutex, t_send_queue, ns)) {
- std::cout << "- @(topic) subscriber started" << std::endl;
-
- } else {
- std::cerr << "Failed starting @(topic) subscriber" << std::endl;
- return false;
- }
-
-@[end for]@
- std::cout << "\033[0;36m-----------------------\033[0m" << std::endl << std::endl;
-@[end if]@
-@[if send_topics]@
-
- // Initialise publishers
- std::cout << "\033[0;36m---- Publishers ----\033[0m" << std::endl;
-@[for topic in send_topics]@
-
-@[ if topic == 'Timesync' or topic == 'timesync']@
- if (_@(topic)_pub.init(ns)) {
- if (_@(topic)_fmu_in_pub.init(ns, std::string("fmu/timesync/in"))) {
- _timesync->start(&_@(topic)_fmu_in_pub);
- std::cout << "- @(topic) publishers started" << std::endl;
- }
-@[ elif topic == 'TimesyncStatus' or topic == 'timesync_status']@
- if (_@(topic)_pub.init(ns, std::string("timesync_status"))) {
- _timesync->init_status_pub(&_@(topic)_pub);
- std::cout << "- @(topic) publisher started" << std::endl;
-@[ else]@
- if (_@(topic)_pub.init(ns)) {
- std::cout << "- @(topic) publisher started" << std::endl;
-@[ end if]@
-
- } else {
- std::cerr << "ERROR starting @(topic) publisher" << std::endl;
- return false;
- }
-
-@[end for]@
- std::cout << "\033[0;36m-----------------------\033[0m" << std::endl;
-@[end if]@
- return true;
-}
-
-@[if send_topics]@
-template
-void RtpsTopics::sync_timestamp_of_incoming_data(T &msg) {
- uint64_t timestamp = getMsgTimestamp(&msg);
- uint64_t timestamp_sample = getMsgTimestampSample(&msg);
- _timesync->subtractOffset(timestamp);
- setMsgTimestamp(&msg, timestamp);
- _timesync->subtractOffset(timestamp_sample);
- setMsgTimestampSample(&msg, timestamp_sample);
-}
-
-void RtpsTopics::publish(const uint8_t topic_ID, char data_buffer[], size_t len)
-{
- switch (topic_ID) {
-@[for topic in send_topics]@
-
- case @(msgs[0].index(topic) + 1): { // @(topic) publisher
- @(topic)_msg_t st;
- eprosima::fastcdr::FastBuffer cdrbuffer(data_buffer, len);
- eprosima::fastcdr::Cdr cdr_des(cdrbuffer);
- st.deserialize(cdr_des);
-@[ if topic == 'Timesync' or topic == 'timesync']@
- _timesync->processTimesyncMsg(&st, &_@(topic)_pub);
-@[ end if]@
-
- // apply timestamp offset
- sync_timestamp_of_incoming_data(st);
-
- _@(topic)_pub.publish(&st);
- }
- break;
-@[end for]@
-
- default:
- printf("\033[1;33m[ micrortps_agent ]\tUnexpected topic ID '%hhu' to publish. Please make sure the agent is capable of parsing the message associated to the topic ID '%hhu'\033[0m\n",
- topic_ID, topic_ID);
- break;
- }
-}
-@[end if]@
-@[if recv_topics]@
-template
-void RtpsTopics::sync_timestamp_of_outgoing_data(T &msg) {
- uint64_t timestamp = getMsgTimestamp(&msg);
- uint64_t timestamp_sample = getMsgTimestampSample(&msg);
- _timesync->addOffset(timestamp);
- setMsgTimestamp(&msg, timestamp);
- _timesync->addOffset(timestamp_sample);
- setMsgTimestampSample(&msg, timestamp_sample);
-}
-
-bool RtpsTopics::getMsg(const uint8_t topic_ID, eprosima::fastcdr::Cdr &scdr)
-{
- bool ret = false;
-
- switch (topic_ID) {
-@[for topic in recv_topics]@
-
- case @(msgs[0].index(topic) + 1): // @(topic) subscriber
- if (_@(topic)_sub.hasMsg()) {
- @(topic)_msg_t msg = _@(topic)_sub.getMsg();
-
- // apply timestamp offset
- sync_timestamp_of_outgoing_data(msg);
-
- msg.serialize(scdr);
- ret = true;
-
- _@(topic)_sub.unlockMsg();
- }
-
- break;
-@[end for]@
-
- default:
- printf("\033[1;33m[ micrortps_agent ]\tUnexpected topic ID '%hhu' to getMsg. Please make sure the agent is capable of parsing the message associated to the topic ID '%hhu'\033[0m\n",
- topic_ID, topic_ID);
- break;
- }
-
- return ret;
-}
-@[end if]@
diff --git a/msg/templates/urtps/RtpsTopics.h.em b/msg/templates/urtps/RtpsTopics.h.em
deleted file mode 100644
index b82c7b20c8..0000000000
--- a/msg/templates/urtps/RtpsTopics.h.em
+++ /dev/null
@@ -1,220 +0,0 @@
-@###############################################
-@#
-@# EmPy template for generating RtpsTopics.h file
-@#
-@###############################################
-@# Start of Template
-@#
-@# Context:
-@# - fastrtps_version (List[str]) FastRTPS version installed on the system
-@# - package (List[str]) messages package name. Defaulted to 'px4'
-@# - ros2_distro (List[str]) ROS2 distro name
-@# - spec (msggen.MsgSpec) Parsed specification of the .msg file
-@###############################################
-@{
-import genmsg.msgs
-import os
-from packaging import version
-from px_generate_uorb_topic_files import MsgScope # this is in Tools/
-
-send_topics = [(alias[idx] if alias[idx] else s.short_name) for idx, s in enumerate(spec) if scope[idx] == MsgScope.SEND]
-recv_topics = [(alias[idx] if alias[idx] else s.short_name) for idx, s in enumerate(spec) if scope[idx] == MsgScope.RECEIVE]
-package = package[0]
-fastrtps_version = fastrtps_version[0]
-try:
- ros2_distro = ros2_distro[0].decode("utf-8")
-except AttributeError:
- ros2_distro = ros2_distro[0]
-}@
-/****************************************************************************
- *
- * Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
- * Copyright (c) 2018-2021 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 of the copyright holder 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 HOLDER 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.
- *
- ****************************************************************************/
-
-#include
-#include
-#include
-#include
-
-#include "microRTPS_timesync.h"
-
-@[for topic in send_topics]@
-#include "@(topic)_Publisher.h"
-@[end for]@
-@[for topic in recv_topics]@
-#include "@(topic)_Subscriber.h"
-@[end for]@
-
-
-@[for topic in (recv_topics + send_topics)]@
-@[ if version.parse(fastrtps_version) <= version.parse('1.7.2')]@
-@[ if ros2_distro]@
-using @(topic)_msg_t = @(package)::msg::dds_::@(topic)_;
-@[ else]@
-using @(topic)_msg_t = @(topic)_;
-@[ end if]@
-@[ else]@
-@[ if ros2_distro]@
-using @(topic)_msg_t = @(package)::msg::@(topic);
-@[ else]@
-using @(topic)_msg_t = @(topic);
-@[ end if]@
-@[ end if]@
-@[end for]@
-
-class RtpsTopics
-{
-public:
- bool init(std::condition_variable *t_send_queue_cv, std::mutex *t_send_queue_mutex, std::queue *t_send_queue,
- const std::string &ns);
- void set_timesync(const std::shared_ptr ×ync) { _timesync = timesync; };
-@[if send_topics]@
- template
- void sync_timestamp_of_incoming_data(T &msg);
- void publish(const uint8_t topic_ID, char data_buffer[], size_t len);
-@[end if]@
-@[if recv_topics]@
- template
- void sync_timestamp_of_outgoing_data(T &msg);
- bool getMsg(const uint8_t topic_ID, eprosima::fastcdr::Cdr &scdr);
-@[end if]@
-
-private:
-@[if send_topics]@
- /** Publishers **/
-@[for topic in send_topics]@
-@[ if topic == 'Timesync' or topic == 'timesync']@
- @(topic)_Publisher _@(topic)_pub;
- @(topic)_Publisher _@(topic)_fmu_in_pub;
-@[ else]@
- @(topic)_Publisher _@(topic)_pub;
-@[ end if]@
-@[end for]@
-@[end if]@
-
-@[if recv_topics]@
- /** Subscribers **/
-@[for topic in recv_topics]@
- @(topic)_Subscriber _@(topic)_sub;
-@[end for]@
-@[end if]@
-
- // SFINAE
- template struct hasTimestampSample{
- private:
- template().timestamp_sample(int64_t()))>
- static std::true_type detect(int);
- template
- static std::false_type detect(...);
- public:
- static constexpr bool value = decltype(detect(0))::value;
- };
-
- template
- inline typename std::enable_if < !hasTimestampSample::value, uint64_t >::type
- getMsgTimestampSample_impl(const T *) { return 0; }
-
- /** Msg metada Getters **/
-@[if version.parse(fastrtps_version) <= version.parse('1.7.2') or not ros2_distro]@
- template
- inline uint64_t getMsgTimestamp(const T *msg) { return msg->timestamp_(); }
-
- template
- inline typename std::enable_if::value, uint64_t>::type
- getMsgTimestampSample_impl(const T *msg) { return msg->timestamp_sample_(); }
-
- template
- inline uint8_t getMsgSysID(const T *msg) { return msg->sys_id_(); }
-
- template
- inline uint8_t getMsgSeq(const T *msg) { return msg->seq_(); }
-@[elif ros2_distro]@
- template
- inline uint64_t getMsgTimestamp(const T *msg) { return msg->timestamp(); }
-
- template
- inline typename std::enable_if::value, uint64_t>::type
- getMsgTimestampSample_impl(const T *msg) { return msg->timestamp_sample(); }
-
- template
- inline uint8_t getMsgSysID(const T *msg) { return msg->sys_id(); }
-
- template
- inline uint8_t getMsgSeq(const T *msg) { return msg->seq(); }
-@[end if]@
-
- template
- inline uint64_t getMsgTimestampSample(const T *msg) { return getMsgTimestampSample_impl(msg); }
-
- template
- inline typename std::enable_if ::value, void>::type
- setMsgTimestampSample_impl(T *, const uint64_t &) {}
-
- /** Msg metadata Setters **/
-@[if version.parse(fastrtps_version) <= version.parse('1.7.2') or not ros2_distro]@
- template
- inline void setMsgTimestamp(T *msg, const uint64_t ×tamp) { msg->timestamp_() = timestamp; }
-
- template
- inline typename std::enable_if::value, void>::type
- setMsgTimestampSample_impl(T *msg, const uint64_t ×tamp_sample) { msg->timestamp_sample_() = timestamp_sample; }
-
- template
- inline void setMsgSysID(T *msg, const uint8_t &sys_id) { msg->sys_id_() = sys_id; }
-
- template
- inline void setMsgSeq(T *msg, const uint8_t &seq) { msg->seq_() = seq; }
-@[elif ros2_distro]@
- template
- inline void setMsgTimestamp(T *msg, const uint64_t ×tamp) { msg->timestamp() = timestamp; }
-
- template
- inline typename std::enable_if::value, void>::type
- setMsgTimestampSample_impl(T *msg, const uint64_t ×tamp_sample) { msg->timestamp_sample() = timestamp_sample; }
-
- template
- inline void setMsgSysID(T *msg, const uint8_t &sys_id) { msg->sys_id() = sys_id; }
-
- template
- inline void setMsgSeq(T *msg, const uint8_t &seq) { msg->seq() = seq; }
-@[end if]@
-
- template
- inline void setMsgTimestampSample(T *msg, const uint64_t ×tamp_sample) { setMsgTimestampSample_impl(msg, timestamp_sample); }
-
- /**
- * @@brief Timesync object ptr.
- * This object is used to compuyte and apply the time offsets to the
- * messages timestamps.
- */
- std::shared_ptr _timesync;
-};
diff --git a/msg/templates/urtps/Subscriber.cpp.em b/msg/templates/urtps/Subscriber.cpp.em
deleted file mode 100644
index ab0c5f2d82..0000000000
--- a/msg/templates/urtps/Subscriber.cpp.em
+++ /dev/null
@@ -1,284 +0,0 @@
-@###############################################
-@#
-@# EmPy template for generating _uRTPS_UART.cpp file
-@#
-@###############################################
-@# Start of Template
-@#
-@# Context:
-@# - fastrtps_version (str) FastRTPS version installed on the system
-@# - ros2_distro (str) ROS2 distro name
-@# - spec (msggen.MsgSpec) Parsed specification of the .msg file
-@###############################################
-@{
-import genmsg.msgs
-from packaging import version
-import re
-
-topic = alias if alias else spec.short_name
-try:
- ros2_distro = ros2_distro.decode("utf-8")
-except AttributeError:
- pass
-
-topic_name = topic
-
-# For ROS, use the topic pattern convention defined in
-# http://wiki.ros.org/ROS/Patterns/Conventions
-if ros2_distro:
- topic_name_split = re.sub( r"([A-Z])", r" \1", topic).split()
- topic_name = topic_name_split[0]
- for w in topic_name_split[1:]:
- topic_name += "_" + w
- topic_name = topic_name.lower()
-}@
-/****************************************************************************
- *
- * Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
- * Copyright (c) 2018-2021 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 of the copyright holder 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 HOLDER 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.
- *
- ****************************************************************************/
-
-/*!
- * @@file @(topic)_Subscriber.cpp
- * This file contains the implementation of the subscriber functions.
- *
- * This file was adapted from the fastrtpsgen tool.
- */
-
-#include "@(topic)_Subscriber.h"
-
-#include
-#include
-#include
-#include
-#include
-#include
-@[if version.parse(fastrtps_version) >= version.parse('2.0')]@
-#include
-
-using SharedMemTransportDescriptor = eprosima::fastdds::rtps::SharedMemTransportDescriptor;
-@[end if]@
-
-
-@(topic)_Subscriber::@(topic)_Subscriber()
- : mp_participant(nullptr),
- mp_subscriber(nullptr)
-{ }
-
-@(topic)_Subscriber::~@(topic)_Subscriber()
-{
- Domain::removeParticipant(mp_participant);
-}
-
-bool @(topic)_Subscriber::init(uint8_t topic_ID, std::condition_variable *t_send_queue_cv,
- std::mutex *t_send_queue_mutex, std::queue *t_send_queue, const std::string &ns,
- std::string topic_name)
-{
- m_listener.topic_ID = topic_ID;
- m_listener.t_send_queue_cv = t_send_queue_cv;
- m_listener.t_send_queue_mutex = t_send_queue_mutex;
- m_listener.t_send_queue = t_send_queue;
-
- // Create RTPSParticipant
- ParticipantAttributes PParam;
-@[if version.parse(fastrtps_version) < version.parse('2.0')]@
- PParam.rtps.builtin.domainId = 0;
-@[else]@
- PParam.domainId = 0;
-@[end if]@
-@[if version.parse(fastrtps_version) <= version.parse('1.8.4')]@
- PParam.rtps.builtin.leaseDuration = c_TimeInfinite;
-@[else]@
- PParam.rtps.builtin.discovery_config.leaseDuration = c_TimeInfinite;
-@[end if]@
-@[if ros2_distro]@
- // ROS2 default memory management policy
- PParam.rtps.builtin.writerHistoryMemoryPolicy = PREALLOCATED_WITH_REALLOC_MEMORY_MODE;
-@[end if]@
- std::string nodeName = ns;
- nodeName.append("@(topic)_subscriber");
- PParam.rtps.setName(nodeName.c_str());
-
-@[if ros2_distro]@
- // Check if ROS_LOCALHOST_ONLY is set. This means that one wants to use only
- // the localhost network for data sharing. If FastRTPS/DDS >= 2.0 and
- // RMW_IMPLEMENTATION is FastDDS then the Shared Memory transport is used
- const char* localhost_only = std::getenv("ROS_LOCALHOST_ONLY");
- const char* rmw_implementation = std::getenv("RMW_IMPLEMENTATION");
- const char* ros_distro = std::getenv("ROS_DISTRO");
- if (localhost_only && strcmp(localhost_only, "1") == 0
- && ((rmw_implementation && ((strcmp(rmw_implementation, "rmw_fastrtps_cpp") == 0)
- || (strcmp(rmw_implementation, "rmw_fastrtps_dynamic_cpp") == 0)))
- || (!rmw_implementation && ros_distro && strcmp(ros_distro, "foxy") == 0))) {
- // Create a custom network UDPv4 transport descriptor
- // to whitelist the localhost
- auto localhostUdpTransport = std::make_shared();
- localhostUdpTransport->interfaceWhiteList.emplace_back("127.0.0.1");
-
- // Disable the built-in Transport Layer
- PParam.rtps.useBuiltinTransports = false;
-
- // Add the descriptor as a custom user transport
- PParam.rtps.userTransports.push_back(localhostUdpTransport);
-
-@[ if version.parse(fastrtps_version) >= version.parse('2.0')]@
- // Add shared memory transport when available
- auto shmTransport = std::make_shared();
- PParam.rtps.userTransports.push_back(shmTransport);
-@[ end if]@
- }
-@[end if]@
-
- mp_participant = Domain::createParticipant(PParam);
-
- if (mp_participant == nullptr) {
- return false;
- }
-
- // Register the type
- Domain::registerType(mp_participant, static_cast(&@(topic)DataType));
-
- // Create Subscriber
- SubscriberAttributes Rparam;
- Rparam.topic.topicKind = NO_KEY;
- Rparam.topic.topicDataType = @(topic)DataType.getName();
-@[if ros2_distro]@
-@[ if ros2_distro == "ardent"]@
- Rparam.qos.m_partition.push_back("rt");
- std::string topicName = ns;
-@[ else]@
- std::string topicName = "rt/";
- topicName.append(ns);
-@[ end if]@
-@[else]@
- std::string topicName = ns;
-@[end if]@
- topic_name.empty() ? topicName.append("fmu/@(topic_name)/in") : topicName.append(topic_name);
- Rparam.topic.topicName = topicName;
- mp_subscriber = Domain::createSubscriber(mp_participant, Rparam, static_cast(&m_listener));
-
- if (mp_subscriber == nullptr) {
- return false;
- }
-
- return true;
-}
-
-void @(topic)_Subscriber::SubListener::onSubscriptionMatched(Subscriber *sub, MatchingInfo &info)
-{
-@# Since the time sync runs on the bridge itself, it is required that there is a
-@# match between two topics of the same entity
-@[if topic != 'Timesync' and topic != 'timesync' and topic != 'TimesyncStatus' and topic != 'timesync_status']@
- // The first 6 values of the ID guidPrefix of an entity in a DDS-RTPS Domain
- // are the same for all its subcomponents (publishers, subscribers)
- bool is_different_endpoint = false;
-
- for (size_t i = 0; i < 6; i++) {
- if (sub->getGuid().guidPrefix.value[i] != info.remoteEndpointGuid.guidPrefix.value[i]) {
- is_different_endpoint = true;
- break;
- }
- }
-
- // If the matching happens for the same entity, do not make a match
- if (is_different_endpoint) {
- if (info.status == MATCHED_MATCHING) {
- n_matched++;
- std::cout << "\033[0;37m[ micrortps_agent ]\t@(topic) subscriber matched\033[0m" << std::endl;
-
- } else {
- n_matched--;
- std::cout << "\033[0;37m[ micrortps_agent ]\t@(topic) subscriber unmatched\033[0m" << std::endl;
- }
- }
-
-@[else]@
- (void)sub;
-
- if (info.status == MATCHED_MATCHING) {
- n_matched++;
-
- } else {
- n_matched--;
- }
-@[end if]@
-}
-
-void @(topic)_Subscriber::SubListener::onNewDataMessage(Subscriber *sub)
-{
- if (n_matched > 0) {
- std::unique_lock has_msg_lock(has_msg_mutex);
-
- if (has_msg.load() == true) { // Check if msg has been fetched
- has_msg_cv.wait(has_msg_lock); // Wait till msg has been fetched
- }
-
- has_msg_lock.unlock();
-
- // Take data
- if (sub->takeNextData(&msg, &m_info)) {
- if (m_info.sampleKind == ALIVE) {
- std::unique_lock lk(*t_send_queue_mutex);
-
- ++n_msg;
- has_msg = true;
-
- t_send_queue->push(topic_ID);
- lk.unlock();
- t_send_queue_cv->notify_one();
-
- }
- }
- }
-}
-
-bool @(topic)_Subscriber::hasMsg()
-{
- if (m_listener.n_matched > 0) {
- return m_listener.has_msg.load();
- }
-
- return false;
-}
-
-@(topic)_msg_t @(topic)_Subscriber::getMsg()
-{
- return m_listener.msg;
-}
-
-void @(topic)_Subscriber::unlockMsg()
-{
- if (m_listener.n_matched > 0) {
- std::unique_lock has_msg_lock(m_listener.has_msg_mutex);
- m_listener.has_msg = false;
- has_msg_lock.unlock();
- m_listener.has_msg_cv.notify_one();
- }
-}
diff --git a/msg/templates/urtps/Subscriber.h.em b/msg/templates/urtps/Subscriber.h.em
deleted file mode 100644
index 703112bef3..0000000000
--- a/msg/templates/urtps/Subscriber.h.em
+++ /dev/null
@@ -1,140 +0,0 @@
-@###############################################
-@#
-@# EmPy template for generating _uRTPS_UART.cpp file
-@#
-@###############################################
-@# Start of Template
-@#
-@# Context:
-@# - ros2_distro (str) ROS2 distro name
-@# - spec (msggen.MsgSpec) Parsed specification of the .msg file
-@###############################################
-@{
-import genmsg.msgs
-from packaging import version
-import re
-
-topic = alias if alias else spec.short_name
-try:
- ros2_distro = ros2_distro.decode("utf-8")
-except AttributeError:
- pass
-}@
-/****************************************************************************
- *
- * Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
- * Copyright (c) 2018-2021 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 of the copyright holder 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 HOLDER 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.
- *
- ****************************************************************************/
-
-/*!
- * @@file @(topic)_Subscriber.h
- * This header file contains the declaration of the subscriber functions.
- *
- * This file was adapted from the fastrtpsgen tool.
- */
-
-
-#ifndef _@(topic)__SUBSCRIBER_H_
-#define _@(topic)__SUBSCRIBER_H_
-
-#include
-#include
-#include
-@[if version.parse(fastrtps_version) <= version.parse('1.7.2')]@
-#include "@(topic)_PubSubTypes.h"
-@[else]@
-#include "@(topic)PubSubTypes.h"
-@[end if]@
-
-#include
-#include
-#include
-
-using namespace eprosima::fastrtps;
-using namespace eprosima::fastrtps::rtps;
-
-@[if version.parse(fastrtps_version) <= version.parse('1.7.2')]@
-@[ if ros2_distro]@
-using @(topic)_msg_t = @(package)::msg::dds_::@(topic)_;
-using @(topic)_msg_datatype = @(package)::msg::dds_::@(topic)_PubSubType;
-@[ else]@
-using @(topic)_msg_t = @(topic)_;
-using @(topic)_msg_datatype = @(topic)_PubSubType;
-@[ end if]@
-@[else]@
-@[ if ros2_distro]@
-using @(topic)_msg_t = @(package)::msg::@(topic);
-using @(topic)_msg_datatype = @(package)::msg::@(topic)PubSubType;
-@[ else]@
-using @(topic)_msg_t = @(topic);
-using @(topic)_msg_datatype = @(topic)PubSubType;
-@[ end if]@
-@[end if]@
-
-class @(topic)_Subscriber
-{
-public:
- @(topic)_Subscriber();
- virtual ~@(topic)_Subscriber();
- bool init(uint8_t topic_ID, std::condition_variable *t_send_queue_cv, std::mutex *t_send_queue_mutex,
- std::queue *t_send_queue, const std::string &ns, std::string topic_name = "");
- void run();
- bool hasMsg();
- @(topic)_msg_t getMsg();
- void unlockMsg();
-
-private:
- Participant *mp_participant;
- Subscriber *mp_subscriber;
-
- class SubListener : public SubscriberListener
- {
- public:
- SubListener() : n_matched(0), n_msg(0), has_msg(false) {};
- ~SubListener() {};
- void onSubscriptionMatched(Subscriber *sub, MatchingInfo &info);
- void onNewDataMessage(Subscriber *sub);
- SampleInfo_t m_info;
- int n_matched;
- int n_msg;
- @(topic)_msg_t msg;
- std::atomic_bool has_msg;
- uint8_t topic_ID;
- std::condition_variable *t_send_queue_cv;
- std::mutex *t_send_queue_mutex;
- std::queue *t_send_queue;
- std::condition_variable has_msg_cv;
- std::mutex has_msg_mutex;
-
- } m_listener;
- @(topic)_msg_datatype @(topic)DataType;
-};
-
-#endif // _@(topic)__SUBSCRIBER_H_
diff --git a/msg/templates/urtps/microRTPS_agent.cpp.em b/msg/templates/urtps/microRTPS_agent.cpp.em
deleted file mode 100644
index 07510f9174..0000000000
--- a/msg/templates/urtps/microRTPS_agent.cpp.em
+++ /dev/null
@@ -1,404 +0,0 @@
-@###############################################
-@#
-@# EmPy template for generating microRTPS_agent.cpp file
-@#
-@###############################################
-@# Start of Template
-@#
-@# Context:
-@# - spec (msggen.MsgSpec) Parsed specification of the .msg file
-@# - ros2_distro (List[str]) ROS2 distro name
-@###############################################
-@{
-import genmsg.msgs
-from px_generate_uorb_topic_files import MsgScope # this is in Tools/
-
-try:
- ros2_distro = ros2_distro[0].decode("utf-8")
-except AttributeError:
- ros2_distro = ros2_distro[0]
-
-send_topics = [(alias[idx] if alias[idx] else s.short_name) for idx, s in enumerate(spec) if scope[idx] == MsgScope.SEND]
-recv_topics = [(alias[idx] if alias[idx] else s.short_name) for idx, s in enumerate(spec) if scope[idx] == MsgScope.RECEIVE]
-}@
-/****************************************************************************
- *
- * Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
- * Copyright (c) 2018-2021 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 of the copyright holder 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 HOLDER 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.
- *
- ****************************************************************************/
-
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-
-#include
-#include
-#include
-#include
-
-#include "microRTPS_transport.h"
-#include "microRTPS_timesync.h"
-#include "RtpsTopics.h"
-
-@[if ros2_distro]@
-#include
-@[end if]@
-
-// Default values
-#define SLEEP_US 1
-#define MAX_SLEEP_US 1000000
-#define BAUDRATE 460800
-#define MAX_DATA_RATE 10000000
-#define DEVICE "/dev/ttyACM0"
-#define POLL_MS 1
-#define MAX_POLL_MS 1000
-#define DEFAULT_RECV_PORT 2020
-#define DEFAULT_SEND_PORT 2019
-#define DEFAULT_IP "127.0.0.1"
-
-using namespace eprosima;
-using namespace eprosima::fastrtps;
-
-volatile sig_atomic_t running = 1;
-std::unique_ptr transport_node;
-std::unique_ptr topics;
-uint32_t total_sent = 0, sent = 0;
-
-struct options {
- enum class eTransports {
- UART,
- UDP
- };
- eTransports transport = options::eTransports::UART;
- char device[64] = DEVICE;
- int sleep_us = SLEEP_US;
- uint32_t baudrate = BAUDRATE;
- int poll_ms = POLL_MS;
- uint16_t recv_port = DEFAULT_RECV_PORT;
- uint16_t send_port = DEFAULT_SEND_PORT;
- char ip[16] = DEFAULT_IP;
- bool sw_flow_control = false;
- bool hw_flow_control = false;
- bool verbose_debug = false;
- std::string ns = "";
-} _options;
-
-static void usage(const char *name)
-{
- printf("usage: %s [options]\n\n"
- " -b UART device baudrate. Defaults to 460800\n"
- " -d UART device. Defaults to /dev/ttyACM0\n"
- " -f Activates UART link SW flow control\n"
- " -g Activates UART link HW flow control\n"
- " -i Target remote IP address for UDP. Defaults to 127.0.0.1\n"
- " -n Topics namespace. Identifies the vehicle in a multi-agent network\n"
- " -o UART polling timeout in milliseconds. Defaults to 1ms\n"
- " -r UDP port for receiving (local). Defaults to 2020\n"
- " -s UDP port for sending (remote). Defaults to 2019\n"
- " -t [UART|UDP] Defaults to UART\n"
- " -v Add more verbosity\n"
- " -w Iteration time for data publishing to the DDS world, in microseconds.\n"
- " Defaults to 1us\n"
- " (ROS2 only) Allows to pass arguments to the timesync ROS2 node.\n"
- " Currently used for setting the usage of simulation time by the node using\n"
- " '--ros-args -p use_sim_time:=true'\n",
- name);
-}
-
-static int parse_options(int argc, char **argv)
-{
- static const struct option options[] = {
- {"baudrate", required_argument, NULL, 'b'},
- {"device", required_argument, NULL, 'd'},
- {"sw-flow-control", no_argument, NULL, 'f'},
- {"hw-flow-control", no_argument, NULL, 'g'},
- {"ip-address", required_argument, NULL, 'i'},
- {"namespace", required_argument, NULL, 'n'},
- {"poll-ms", required_argument, NULL, 'o'},
- {"reception-port", required_argument, NULL, 'r'},
- {"sending-port", required_argument, NULL, 's'},
- {"transport", required_argument, NULL, 't'},
- {"increase-verbosity", no_argument, NULL, 'v'},
- {"sleep-time-us", required_argument, NULL, 'w'},
- {"ros-args", required_argument, NULL, 0},
- {"help", no_argument, NULL, 'h'},
- {NULL, 0, NULL, 0}};
-
- int ch;
-
- while ((ch = getopt_long(argc, argv, "t:d:w:b:o:r:s:i:fghvn:", options, nullptr)) >= 0) {
- switch (ch) {
- case 't': _options.transport = strcmp(optarg, "UDP") == 0 ?
- options::eTransports::UDP
- : options::eTransports::UART; break;
-
- case 'd': if (nullptr != optarg) strcpy(_options.device, optarg); break;
-
- case 'w': _options.sleep_us = strtoul(optarg, nullptr, 10); break;
-
- case 'b': _options.baudrate = strtoul(optarg, nullptr, 10); break;
-
- case 'o': _options.poll_ms = strtol(optarg, nullptr, 10); break;
-
- case 'r': _options.recv_port = strtoul(optarg, nullptr, 10); break;
-
- case 's': _options.send_port = strtoul(optarg, nullptr, 10); break;
-
- case 'i': if (nullptr != optarg) strcpy(_options.ip, optarg); break;
-
- case 'f': _options.sw_flow_control = true; break;
-
- case 'g': _options.hw_flow_control = true; break;
-
- case 'h': usage(argv[0]); exit(0); break;
-
- case 'v': _options.verbose_debug = true; break;
-
- case 'n': if (nullptr != optarg) _options.ns = std::string(optarg) + "/"; break;
-
- default:
-@[if ros2_distro]@
- break;
-@[else]@
- usage(argv[0]);
- return -1;
-@[end if]@
- }
- }
-
- if (_options.poll_ms < POLL_MS) {
- _options.poll_ms = POLL_MS;
- printf("\033[1;33m[ micrortps_agent ]\tPoll timeout too low. Using %d ms instead\033[0m\n", POLL_MS);
- } else if (_options.poll_ms > MAX_POLL_MS) {
- _options.poll_ms = MAX_POLL_MS;
- printf("\033[1;33m[ micrortps_agent ]\tPoll timeout too high. Using %d ms instead\033[0m\n", MAX_POLL_MS);
- }
-
- if (_options.sleep_us > MAX_SLEEP_US) {
- _options.sleep_us = MAX_SLEEP_US;
- printf("\033[1;33m[ micrortps_agent ]\tPublishing iteration cycle too slow. Using %d us instead\033[0m\n", MAX_SLEEP_US);
- }
-
- if (_options.hw_flow_control && _options.sw_flow_control) {
- printf("\033[0;31m[ micrortps_agent ]\tHW and SW flow control set. Please set only one or another\033[0m\n");
- return -1;
- }
-
- return 0;
-}
-
-@[if recv_topics]@
-std::atomic exit_sender_thread(false);
-std::condition_variable t_send_queue_cv;
-std::mutex t_send_queue_mutex;
-std::queue t_send_queue;
-
-void t_send(void *)
-{
- char data_buffer[BUFFER_SIZE] = {};
- uint32_t length = 0;
- uint8_t topic_ID = 255;
-
- while (running && !exit_sender_thread) {
- std::unique_lock lk(t_send_queue_mutex);
-
- while (t_send_queue.empty() && !exit_sender_thread) {
- t_send_queue_cv.wait(lk);
- }
-
- topic_ID = t_send_queue.front();
- t_send_queue.pop();
- lk.unlock();
-
- size_t header_length = transport_node->get_header_length();
- /* make room for the header to fill in later */
- eprosima::fastcdr::FastBuffer cdrbuffer(&data_buffer[header_length], sizeof(data_buffer) - header_length);
- eprosima::fastcdr::Cdr scdr(cdrbuffer);
-
- if (!exit_sender_thread) {
- if (topics->getMsg(topic_ID, scdr)) {
- length = scdr.getSerializedDataLength();
-
- if (0 < (length = transport_node->write(topic_ID, data_buffer, length))) {
- total_sent += length;
- ++sent;
- }
- }
- }
- }
-}
-@[end if]@
-
-void signal_handler(int signum)
-{
- printf("\n\033[1;33m[ micrortps_agent ]\tInterrupt signal (%d) received.\033[0m\n", signum);
- running = 0;
- transport_node->close();
-}
-
-int main(int argc, char **argv)
-{
- printf("\033[0;37m--- MicroRTPS Agent ---\033[0m\n");
-
- if (-1 == parse_options(argc, argv)) {
- printf("\033[1;33m[ micrortps_agent ]\tEXITING...\033[0m\n");
- return -1;
- }
-
- topics = std::make_unique();
-
-@[if ros2_distro]@
- // Initialize communications via the rmw implementation and set up a global signal handler.
- rclcpp::init(argc, argv, rclcpp::InitOptions());
-@[end if]@
-
- // register signal SIGINT and signal handler
- signal(SIGINT, signal_handler);
-
- printf("[ micrortps_agent ]\tStarting link...\n");
-
- const char* localhost_only = std::getenv("ROS_LOCALHOST_ONLY");
-
- if (localhost_only && strcmp(localhost_only, "1") == 0) {
- printf("[ micrortps_agent ]\tUsing only the localhost network...\n");
- }
-
- /**
- * Set the system ID to Mission Computer, in order to identify the agent side
- *
- * Note: theoretically a multi-agent system is possible, but this would require
- * adjustments in the way the timesync is done (would have to create a timesync
- * instance per agent). Keeping it contained for a 1:1 link for now is reasonable.
- */
- const uint8_t sys_id = static_cast(MicroRtps::System::MISSION_COMPUTER);
-
- switch (_options.transport) {
- case options::eTransports::UART: {
- transport_node = std::make_unique(_options.device, _options.baudrate, _options.poll_ms,
- _options.sw_flow_control, _options.hw_flow_control, sys_id, _options.verbose_debug);
- printf("[ micrortps_agent ]\tUART transport: device: %s; baudrate: %d; poll: %dms; flow_control: %s\n",
- _options.device, _options.baudrate, _options.poll_ms,
- _options.sw_flow_control ? "SW enabled" : (_options.hw_flow_control ? "HW enabled" : "No"));
- }
- break;
-
- case options::eTransports::UDP: {
- transport_node = std::make_unique(_options.ip, _options.recv_port, _options.send_port,
- sys_id, _options.verbose_debug);
- printf("[ micrortps_agent ]\tUDP transport: ip address: %s; recv port: %u; send port: %u\n",
- _options.ip, _options.recv_port, _options.send_port);
- }
- break;
-
- default:
- printf("\033[0;37m[ micrortps_agent ]\tEXITING...\033[0m\n");
- return -1;
- }
-
- if (0 > transport_node->init()) {
- printf("\033[0;37m[ micrortps_agent ]\tEXITING...\033[0m\n");
- return -1;
- }
-
- sleep(1);
-
-@[if send_topics]@
- char data_buffer[BUFFER_SIZE] = {};
- int received = 0, loop = 0;
- int length = 0, total_read = 0;
- bool receiving = false;
- uint8_t topic_ID = 255;
- std::chrono::time_point start, end;
-@[end if]@
-
- // Init timesync
- topics->set_timesync(std::make_shared(_options.verbose_debug));
-
-@[if recv_topics]@
- topics->init(&t_send_queue_cv, &t_send_queue_mutex, &t_send_queue, _options.ns);
-@[end if]@
-
- running = true;
-@[if recv_topics]@
- std::thread sender_thread(t_send, nullptr);
-@[end if]@
-
- while (running) {
-@[if send_topics]@
- ++loop;
- if (!receiving) { start = std::chrono::steady_clock::now(); }
-
- // Publish messages received from UART
- if (0 < (length = transport_node->read(&topic_ID, data_buffer, BUFFER_SIZE))) {
- topics->publish(topic_ID, data_buffer, sizeof(data_buffer));
- ++received;
- total_read += length;
- receiving = true;
- end = std::chrono::steady_clock::now();
- }
-@[else]@
- usleep(_options.sleep_us);
-@[end if]@
- }
-
-@[if recv_topics]@
- exit_sender_thread = true;
- t_send_queue_cv.notify_one();
- sender_thread.join();
-
- std::chrono::duration elapsed_secs = end - start;
- if (received > 0) {
- printf("[ micrortps_agent ]\tRECEIVED: %d messages - %d bytes; %d LOOPS - %.03f seconds - %.02fKB/s\n",
- received, total_read, loop, elapsed_secs.count(), static_cast(total_read) / (1000 * elapsed_secs.count()));
- }
-@[end if]@
-@[if recv_topics]@
- if (sent > 0) {
- printf("[ micrortps_agent ]\tSENT: %lu messages - %lu bytes\n", static_cast(sent),
- static_cast(total_sent));
- }
-@[end if]@
-
-@[if ros2_distro]@
- rclcpp::shutdown();
-@[end if]@
- transport_node.reset();
- topics.reset();
-
- return 0;
-}
diff --git a/msg/templates/urtps/microRTPS_agent_CMakeLists.txt.em b/msg/templates/urtps/microRTPS_agent_CMakeLists.txt.em
deleted file mode 100644
index f75d13f5d1..0000000000
--- a/msg/templates/urtps/microRTPS_agent_CMakeLists.txt.em
+++ /dev/null
@@ -1,63 +0,0 @@
-################################################################################
-#
-# Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
-# Copyright (c) 2018-2021 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 of the copyright holder 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 HOLDER 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.
-#
-################################################################################
-
-cmake_minimum_required(VERSION 2.8.12)
-project(micrortps_agent)
-
-# Find requirements
-find_package(fastrtps REQUIRED)
-find_package(fastcdr REQUIRED)
-
-# Set C++14
-include(CheckCXXCompilerFlag)
-if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANG OR
- CMAKE_CXX_COMPILER_ID MATCHES "Clang")
- check_cxx_compiler_flag(--std=c++14 SUPPORTS_CXX14)
- if(SUPPORTS_CXX14)
- add_compile_options(--std=c++14)
- else()
- message(FATAL_ERROR "Compiler doesn't support C++14")
- endif()
-endif()
-
-file(GLOB MICRORTPS_AGENT_SOURCES src/*.cpp src/*.h)
-add_executable(micrortps_agent ${MICRORTPS_AGENT_SOURCES})
-target_link_libraries(micrortps_agent fastrtps fastcdr)
-
-# Install to '/usr/local/bin' if `make install` is used
-install(
- TARGETS micrortps_agent
- ARCHIVE DESTINATION lib
- RUNTIME DESTINATION bin
- LIBRARY DESTINATION lib
-)
diff --git a/msg/templates/urtps/microRTPS_timesync.cpp.em b/msg/templates/urtps/microRTPS_timesync.cpp.em
deleted file mode 100644
index a441339fb1..0000000000
--- a/msg/templates/urtps/microRTPS_timesync.cpp.em
+++ /dev/null
@@ -1,295 +0,0 @@
-@###############################################
-@#
-@# EmPy template for generating microRTPS_timesync.cpp file
-@#
-@###############################################
-@# Start of Template
-@#
-@# Context:
-@# - package (List[str]) messages package name. Defaulted to 'px4'
-@# - ros2_distro (List[str]) ROS2 distro name
-@###############################################
-@{
-import genmsg.msgs
-from px_generate_uorb_topic_files import MsgScope # this is in Tools/
-
-package = package[0]
-fastrtps_version = fastrtps_version[0]
-try:
- ros2_distro = ros2_distro[0].decode("utf-8")
-except AttributeError:
- ros2_distro = ros2_distro[0]
-}@
-/****************************************************************************
- *
- * Copyright (c) 2020-2021 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 of the copyright holder 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 HOLDER 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.
- *
- ****************************************************************************/
-
-/*!
- * @@file microRTPS_timesync.cpp
- * @@brief source code for time sync implementation
- */
-
-#include
-#include
-#include
-
-#include "microRTPS_timesync.h"
-
-TimeSync::TimeSync(bool debug)
- : _offset_ns(-1),
-@[if ros2_distro]@
- _timesync_node(std::make_shared("timesync_node")),
-@[end if]@
- _skew_ns_per_sync(0.0),
- _num_samples(0),
- _request_reset_counter(0),
- _last_msg_seq(0),
- _last_remote_msg_seq(0),
- _debug(debug)
-{ }
-
-TimeSync::~TimeSync() { stop(); }
-
-void TimeSync::start(TimesyncPublisher *pub)
-{
- stop();
-
-@[if ros2_distro]@
- auto spin_node = [this]() {
- rclcpp::spin(_timesync_node);
- };
-@[end if]@
-
- auto run = [this, pub]() {
- while (!_request_stop) {
- timesync_msg_t msg = newTimesyncMsg();
-
- pub->publish(&msg);
-
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
- }
- };
- _request_stop = false;
-@[if ros2_distro]@
- _timesync_node_thread.reset(new std::thread(spin_node));
-@[end if]@
- _send_timesync_thread.reset(new std::thread(run));
-}
-
-void TimeSync::init_status_pub(TimesyncStatusPublisher *status_pub)
-{
- auto run = [this, status_pub]() {
- while (!_request_stop) {
- timesync_status_msg_t status_msg = newTimesyncStatusMsg();
-
- status_pub->publish(&status_msg);
-
- std::this_thread::sleep_for(std::chrono::milliseconds(100));
- }
- };
- _request_stop = false;
- _send_timesync_status_thread.reset(new std::thread(run));
-}
-
-void TimeSync::stop()
-{
- _request_stop = true;
-
-@[if ros2_distro]@
- if (_timesync_node_thread && _timesync_node_thread->joinable()) { _timesync_node_thread->join(); }
-@[end if]@
- if (_send_timesync_thread && _send_timesync_thread->joinable()) { _send_timesync_thread->join(); }
- if (_send_timesync_status_thread && _send_timesync_status_thread->joinable()) { _send_timesync_status_thread->join(); }
-}
-
-void TimeSync::reset()
-{
- _num_samples = 0;
- _request_reset_counter = 0;
-}
-
-@[if ros2_distro]@
-uint64_t TimeSync::getROSTimeNSec() const
-{
- return _timesync_node->now().nanoseconds();
-}
-
-uint64_t TimeSync::getROSTimeUSec() const
-{
- return RCL_NS_TO_US(getROSTimeNSec());
-}
-@[else]@
-uint64_t TimeSync::getSteadyTimeNSec() const
-{
- auto time = std::chrono::steady_clock::now();
- return std::chrono::time_point_cast(time).time_since_epoch().count();
-}
-
-uint64_t TimeSync::getSteadyTimeUSec() const
-{
- auto time = std::chrono::steady_clock::now();
- return std::chrono::time_point_cast(time).time_since_epoch().count();
-}
-@[end if]@
-
-bool TimeSync::addMeasurement(int64_t local_t1_ns, int64_t remote_t2_ns, int64_t local_t3_ns)
-{
- _rtti = local_t3_ns - local_t1_ns;
- _remote_time_stamp = remote_t2_ns;
-
- // assume rtti is evenly split both directions
- int64_t remote_t3_ns = remote_t2_ns + _rtti.load() / 2ll;
-
- int64_t measurement_offset = remote_t3_ns - local_t3_ns;
-
- if (_request_reset_counter > REQUEST_RESET_COUNTER_THRESHOLD) {
- reset();
-
- if (_debug) { std::cout << "\033[1;33m[ micrortps__timesync ]\tTimesync clock changed, resetting\033[0m" << std::endl; }
- }
-
- if (_num_samples == 0) {
- updateOffset(measurement_offset);
- _skew_ns_per_sync = 0;
- }
-
- if (_num_samples >= WINDOW_SIZE) {
- if (std::abs(measurement_offset - _offset_ns.load()) > TRIGGER_RESET_THRESHOLD_NS) {
- _request_reset_counter++;
-
- if (_debug) { std::cout << "\033[1;33m[ micrortps__timesync ]\tTimesync offset outlier, discarding\033[0m" << std::endl; }
-
- return false;
-
- } else {
- _request_reset_counter = 0;
- }
- }
-
- // ignore if rtti > 50ms
- if (_rtti.load() > 50ll * 1000ll * 1000ll) {
- if (_debug) { std::cout << "\033[1;33m[ micrortps__timesync ]\tRTTI too high for timesync: " << _rtti.load() / (1000ll * 1000ll) << "ms\033[0m" << std::endl; }
-
- return false;
- }
-
- double alpha = ALPHA_FINAL;
- double beta = BETA_FINAL;
-
- if (_num_samples < WINDOW_SIZE) {
- double schedule = (double)_num_samples / WINDOW_SIZE;
- double s = 1. - exp(.5 * (1. - 1. / (1. - schedule)));
- alpha = (1. - s) * ALPHA_INITIAL + s * ALPHA_FINAL;
- beta = (1. - s) * BETA_INITIAL + s * BETA_FINAL;
- }
-
- _offset_prev = _offset_ns.load();
- updateOffset(static_cast((_skew_ns_per_sync + _offset_ns.load()) * (1. - alpha) +
- measurement_offset * alpha));
- _skew_ns_per_sync =
- static_cast(beta * (_offset_ns.load() - _offset_prev.load()) + (1. - beta) * _skew_ns_per_sync);
-
- _num_samples++;
-
- return true;
-}
-
-void TimeSync::processTimesyncMsg(timesync_msg_t *msg, TimesyncPublisher *pub)
-{
- if (getMsgSeq(msg) != _last_remote_msg_seq) {
- _last_remote_msg_seq = getMsgSeq(msg);
-
- if (getMsgTC1(msg) > 0) {
-@[if ros2_distro]@
- if (!addMeasurement(getMsgTS1(msg), getMsgTC1(msg), getROSTimeNSec())) {
-@[else]@
- if (!addMeasurement(getMsgTS1(msg), getMsgTC1(msg), getSteadyTimeNSec())) {
-@[end if]@
- if (_debug) { std::cerr << "\033[1;33m[ micrortps__timesync ]\tOffset not updated\033[0m" << std::endl; }
- }
-
- } else if (getMsgTC1(msg) == 0) {
-@[if ros2_distro]@
- setMsgTimestamp(msg, getROSTimeUSec());
-@[else]@
- setMsgTimestamp(msg, getSteadyTimeUSec());
-@[end if]@
- setMsgSeq(msg, getMsgSeq(msg) + 1);
-@[if ros2_distro]@
- setMsgTC1(msg, getROSTimeNSec());
-@[else]@
- setMsgTC1(msg, getSteadyTimeNSec());
-@[end if]@
-
- pub->publish(msg);
- }
- }
-}
-
-timesync_msg_t TimeSync::newTimesyncMsg()
-{
- timesync_msg_t msg{};
-
-@[if ros2_distro]@
- setMsgTimestamp(&msg, getROSTimeUSec());
-@[else]@
- setMsgTimestamp(&msg, getSteadyTimeUSec());
-@[end if]@
- setMsgSeq(&msg, _last_msg_seq);
- setMsgTC1(&msg, 0);
-@[if ros2_distro]@
- setMsgTS1(&msg, getROSTimeNSec());
-@[else]@
- setMsgTS1(&msg, getSteadyTimeNSec());
-@[end if]@
-
- _last_msg_seq++;
-
- return msg;
-}
-
-timesync_status_msg_t TimeSync::newTimesyncStatusMsg()
-{
- timesync_status_msg_t msg{};
-
-@[if ros2_distro]@
- setMsgTimestamp(&msg, getROSTimeUSec());
-@[else]@
- setMsgTimestamp(&msg, getSteadyTimeUSec());
-@[end if]@
- setMsgSourceProtocol(&msg, 1); // SOURCE_PROTOCOL_RTPS
- setMsgRemoteTimeStamp(&msg, _remote_time_stamp.load() / 1000ULL);
- setMsgObservedOffset(&msg, _offset_prev.load());
- setMsgEstimatedOffset(&msg, _offset_ns.load());
- setMsgRoundTripTime(&msg, _rtti.load() / 1000ll);
-
- return msg;
-}
diff --git a/msg/templates/urtps/microRTPS_timesync.h.em b/msg/templates/urtps/microRTPS_timesync.h.em
deleted file mode 100644
index ffe4541f18..0000000000
--- a/msg/templates/urtps/microRTPS_timesync.h.em
+++ /dev/null
@@ -1,303 +0,0 @@
-@###############################################
-@#
-@# EmPy template for generating microRTPS_timesync.h file
-@#
-@###############################################
-@# Start of Template
-@#
-@# Context:
-@# - package (List[str]) messages package name. Defaulted to 'px4'
-@# - ros2_distro (List[str]) ROS2 distro name
-@###############################################
-@{
-import genmsg.msgs
-from packaging import version
-from px_generate_uorb_topic_files import MsgScope # this is in Tools/
-
-package = package[0]
-fastrtps_version = fastrtps_version[0]
-try:
- ros2_distro = ros2_distro[0].decode("utf-8")
-except AttributeError:
- ros2_distro = ros2_distro[0]
-}@
-/****************************************************************************
- *
- * Copyright (c) 2020-2021 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 of the copyright holder 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 HOLDER 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.
- *
- ****************************************************************************/
-
-/*!
- * @@file microRTPS_timesync.h
- * @@brief Adds time sync for the microRTPS bridge
- * @@author Nuno Marques
- * @@author Julian Kent
- */
-
-#pragma once
-
-#include
-#include
-#include
-
-@[if ros2_distro]@
-#include "Timesync_Publisher.h"
-#include "TimesyncStatus_Publisher.h"
-
-#include
-#include
-#include
-@[else]@
-#include "timesync_Publisher.h"
-#include "timesync_status_Publisher.h"
-@[end if]@
-
-static constexpr double ALPHA_INITIAL = 0.05;
-static constexpr double ALPHA_FINAL = 0.003;
-static constexpr double BETA_INITIAL = 0.05;
-static constexpr double BETA_FINAL = 0.003;
-static constexpr int WINDOW_SIZE = 500;
-static constexpr int64_t UNKNOWN = 0;
-static constexpr int64_t TRIGGER_RESET_THRESHOLD_NS = 100ll * 1000ll * 1000ll;
-static constexpr int REQUEST_RESET_COUNTER_THRESHOLD = 5;
-
-@# Sets the timesync DDS type according to the FastRTPS and ROS2 version
-@[if version.parse(fastrtps_version) <= version.parse('1.7.2')]@
-@[ if ros2_distro]@
-using timesync_msg_t = @(package)::msg::dds_::Timesync_;
-using timesync_status_msg_t = @(package)::msg::dds_::TimesyncStatus_;
-@[ else]@
-using timesync_msg_t = timesync_;
-using timesync_status_msg_t = timesync_status_;
-@[ end if]@
-@[else]@
-@[ if ros2_distro]@
-using timesync_msg_t = @(package)::msg::Timesync;
-using timesync_status_msg_t = @(package)::msg::TimesyncStatus;
-@[ else]@
-using timesync_msg_t = timesync;
-using timesync_status_msg_t = timesync_status;
-@[ end if]@
-@[end if]@
-@# Sets the timesync publisher entity depending on using ROS2 or not
-@[if ros2_distro]@
-using TimesyncPublisher = Timesync_Publisher;
-using TimesyncStatusPublisher = TimesyncStatus_Publisher;
-@[else]@
-using TimesyncPublisher = timesync_Publisher;
-using TimesyncStatusPublisher = timesync_status_Publisher;
-@[end if]@
-
-class TimeSync
-{
-public:
- TimeSync(bool debug);
- virtual ~TimeSync();
-
- /**
- * @@brief Starts the timesync publishing thread
- * @@param[in] pub The timesync publisher entity to use
- */
- void start(TimesyncPublisher *pub);
-
- /**
- * @@brief Init and run the timesync status publisher thread
- * @@param[in] pub The timesync status publisher entity to use
- */
- void init_status_pub(TimesyncStatusPublisher *status_pub);
-
- /**
- * @@brief Resets the filter
- */
- void reset();
-
- /**
- * @@brief Stops the timesync publishing thread
- */
- void stop();
-
-@[if ros2_distro]@
- /**
- * @@brief Get ROS time in nanoseconds. This will match the system time, which
- * corresponds to the system-wide real time since epoch. If use_sim_time
- * is set, the simulation time is grabbed by the node and used instead
- * More info about ROS2 clock and time in:
- * https://design.ros2.org/articles/clock_and_time.html
- * @@return ROS time in nanoseconds
- */
- uint64_t getROSTimeNSec() const;
-
- /**
- * @@brief Get ROS time in microseconds. Fetches the time from getROSTimeNSec()
- * and converts it to microseconds
- * @@return ROS time in microseconds
- */
- uint64_t getROSTimeUSec() const;
-@[else]@
- /**
- * @@brief Get clock monotonic time (raw) in nanoseconds
- * @@return Steady CLOCK_MONOTONIC time in nanoseconds
- */
- uint64_t getSteadyTimeNSec() const;
-
- /**
- * @@brief Get clock monotonic time (raw) in microseconds
- * @@return Steady CLOCK_MONOTONIC time in microseconds
- */
- uint64_t getSteadyTimeUSec() const;
-@[end if]@
-
- /**
- * @@brief Adds a time offset measurement to be filtered
- * @@param[in] local_t1_ns The agent CLOCK_MONOTONIC_RAW time in nanoseconds when the message was sent
- * @@param[in] remote_t2_ns The (client) remote CLOCK_MONOTONIC time in nanoseconds
- * @@param[in] local_t3_ns The agent current CLOCK_MONOTONIC time in nanoseconds
- * @@return true or false depending if the time offset was updated
- */
- bool addMeasurement(int64_t local_t1_ns, int64_t remote_t2_ns, int64_t local_t3_ns);
-
- /**
- * @@brief Processes DDS timesync message
- * @@param[in,out] msg The timestamp msg to be processed
- */
- void processTimesyncMsg(timesync_msg_t *msg, TimesyncPublisher *pub);
-
- /**
- * @@brief Creates a new timesync DDS message to be sent from the agent to the client
- * @@return A new timesync message with the origin in the agent and with the agent timestamp
- */
- timesync_msg_t newTimesyncMsg();
-
- /**
- * @@brief Creates a new timesync status DDS message to be sent from the agent to the client
- * @@return A new timesync status message with the origin in the agent and with the agent timestamp
- */
- timesync_status_msg_t newTimesyncStatusMsg();
-
- /**
- * @@brief Get the time sync offset in nanoseconds
- * @@return The offset in nanoseconds
- */
- inline int64_t getOffset() { return _offset_ns.load(); }
-
- /**
- * @@brief Sums the time sync offset to the timestamp
- * @@param[in,out] timestamp The timestamp to add the offset to
- */
- inline void addOffset(uint64_t ×tamp) { timestamp = (timestamp * 1000LL + _offset_ns.load()) / 1000ULL; }
-
- /**
- * @@brief Substracts the time sync offset to the timestamp
- * @@param[in,out] timestamp The timestamp to subtract the offset of
- */
- inline void subtractOffset(uint64_t ×tamp) { timestamp = (timestamp * 1000LL - _offset_ns.load()) / 1000ULL; }
-
-private:
- std::atomic _offset_ns;
- std::atomic _offset_prev;
- std::atomic _remote_time_stamp;
- std::atomic _rtti;
-
-@[if ros2_distro]@
- /**
- * @@brief A ROS2 node to fetch the ROS time to be used for timesync
- */
- std::shared_ptr _timesync_node;
-@[end if]@
-
- int64_t _skew_ns_per_sync;
- int64_t _num_samples;
-
- int32_t _request_reset_counter;
- uint8_t _last_msg_seq;
- uint8_t _last_remote_msg_seq;
-
- bool _debug;
-
- std::unique_ptr _send_timesync_thread;
- std::unique_ptr _send_timesync_status_thread;
-@[if ros2_distro]@
- std::unique_ptr _timesync_node_thread;
-@[end if]@
- std::atomic _request_stop{false};
-
- /**
- * @@brief Updates the offset of the time sync filter
- * @@param[in] offset The value of the offset to update to
- */
- inline void updateOffset(const uint64_t &offset) { _offset_ns.store(offset, std::memory_order_relaxed); }
-
- /** Timesync msg Getters **/
-@[if version.parse(fastrtps_version) <= version.parse('1.7.2') or not ros2_distro]@
- inline uint64_t getMsgTimestamp(const timesync_msg_t *msg) { return msg->timestamp_(); }
- inline uint8_t getMsgSeq(const timesync_msg_t *msg) { return msg->seq_(); }
- inline int64_t getMsgTC1(const timesync_msg_t *msg) { return msg->tc1_(); }
- inline int64_t getMsgTS1(const timesync_msg_t *msg) { return msg->ts1_(); }
-@[elif ros2_distro]@
- inline uint64_t getMsgTimestamp(const timesync_msg_t *msg) { return msg->timestamp(); }
- inline uint8_t getMsgSeq(const timesync_msg_t *msg) { return msg->seq(); }
- inline int64_t getMsgTC1(const timesync_msg_t *msg) { return msg->tc1(); }
- inline int64_t getMsgTS1(const timesync_msg_t *msg) { return msg->ts1(); }
- @[end if]@
-
- /** Common timestamp setter **/
-@[if version.parse(fastrtps_version) <= version.parse('1.7.2') or not ros2_distro]@
- template
- inline void setMsgTimestamp(T *msg, const uint64_t ×tamp) { msg->timestamp_() = timestamp; }
-@[elif ros2_distro]@
- template
- inline void setMsgTimestamp(T *msg, const uint64_t ×tamp) { msg->timestamp() = timestamp; }
-@[end if]@
-
- /** Timesync msg Setters **/
-@[if version.parse(fastrtps_version) <= version.parse('1.7.2') or not ros2_distro]@
- inline void setMsgSeq(timesync_msg_t *msg, const uint8_t &seq) { msg->seq_() = seq; }
- inline void setMsgTC1(timesync_msg_t *msg, const int64_t &tc1) { msg->tc1_() = tc1; }
- inline void setMsgTS1(timesync_msg_t *msg, const int64_t &ts1) { msg->ts1_() = ts1; }
-@[elif ros2_distro]@
- inline void setMsgSeq(timesync_msg_t *msg, const uint8_t &seq) { msg->seq() = seq; }
- inline void setMsgTC1(timesync_msg_t *msg, const int64_t &tc1) { msg->tc1() = tc1; }
- inline void setMsgTS1(timesync_msg_t *msg, const int64_t &ts1) { msg->ts1() = ts1; }
-@[end if]@
-
- /** Timesync Status msg Setters **/
-@[if version.parse(fastrtps_version) <= version.parse('1.7.2') or not ros2_distro]@
- inline void setMsgSourceProtocol(timesync_status_msg_t *msg, const uint8_t &source_protocol) { msg->source_protocol_() = source_protocol; }
- inline void setMsgRemoteTimeStamp(timesync_status_msg_t *msg, const uint64_t &remote_timestamp) { msg->remote_timestamp_() = remote_timestamp; }
- inline void setMsgObservedOffset(timesync_status_msg_t *msg, const int64_t &observed_offset) { msg->observed_offset_() = observed_offset; }
- inline void setMsgEstimatedOffset(timesync_status_msg_t *msg, const int64_t &estimated_offset) { msg->estimated_offset_() = estimated_offset; }
- inline void setMsgRoundTripTime(timesync_status_msg_t *msg, const uint32_t &round_trip_time) { msg->round_trip_time_() = round_trip_time; }
-@[elif ros2_distro]@
- inline void setMsgSourceProtocol(timesync_status_msg_t *msg, const uint8_t &source_protocol) { msg->source_protocol() = source_protocol; }
- inline void setMsgRemoteTimeStamp(timesync_status_msg_t *msg, const uint64_t &remote_timestamp) { msg->remote_timestamp() = remote_timestamp; }
- inline void setMsgObservedOffset(timesync_status_msg_t *msg, const int64_t &observed_offset) { msg->observed_offset() = observed_offset; }
- inline void setMsgEstimatedOffset(timesync_status_msg_t *msg, const int64_t &estimated_offset) { msg->estimated_offset() = estimated_offset; }
- inline void setMsgRoundTripTime(timesync_status_msg_t *msg, const uint32_t &round_trip_time) { msg->round_trip_time() = round_trip_time; }
-@[end if]@
-};
diff --git a/msg/templates/urtps/microRTPS_transport.cpp b/msg/templates/urtps/microRTPS_transport.cpp
deleted file mode 100644
index 9252d26eb9..0000000000
--- a/msg/templates/urtps/microRTPS_transport.cpp
+++ /dev/null
@@ -1,801 +0,0 @@
-/****************************************************************************
- *
- * Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
- * Copyright (c) 2018-2021 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 of the copyright holder 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 HOLDER 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.
- *
- ****************************************************************************/
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#include
-#if __has_include("px4_platform_common/log.h") && __has_include("px4_platform_common/time.h")
-#include
-#include
-#endif
-
-#if defined(__linux__) || defined(__PX4_LINUX)
-#include
-#endif /* __linux__ */
-
-#include "microRTPS_transport.h"
-
-
-/** CRC table for the CRC-16. The poly is 0x8005 (x^16 + x^15 + x^2 + 1) */
-uint16_t const crc16_table[256] = {
- 0x0000, 0xC0C1, 0xC181, 0x0140, 0xC301, 0x03C0, 0x0280, 0xC241,
- 0xC601, 0x06C0, 0x0780, 0xC741, 0x0500, 0xC5C1, 0xC481, 0x0440,
- 0xCC01, 0x0CC0, 0x0D80, 0xCD41, 0x0F00, 0xCFC1, 0xCE81, 0x0E40,
- 0x0A00, 0xCAC1, 0xCB81, 0x0B40, 0xC901, 0x09C0, 0x0880, 0xC841,
- 0xD801, 0x18C0, 0x1980, 0xD941, 0x1B00, 0xDBC1, 0xDA81, 0x1A40,
- 0x1E00, 0xDEC1, 0xDF81, 0x1F40, 0xDD01, 0x1DC0, 0x1C80, 0xDC41,
- 0x1400, 0xD4C1, 0xD581, 0x1540, 0xD701, 0x17C0, 0x1680, 0xD641,
- 0xD201, 0x12C0, 0x1380, 0xD341, 0x1100, 0xD1C1, 0xD081, 0x1040,
- 0xF001, 0x30C0, 0x3180, 0xF141, 0x3300, 0xF3C1, 0xF281, 0x3240,
- 0x3600, 0xF6C1, 0xF781, 0x3740, 0xF501, 0x35C0, 0x3480, 0xF441,
- 0x3C00, 0xFCC1, 0xFD81, 0x3D40, 0xFF01, 0x3FC0, 0x3E80, 0xFE41,
- 0xFA01, 0x3AC0, 0x3B80, 0xFB41, 0x3900, 0xF9C1, 0xF881, 0x3840,
- 0x2800, 0xE8C1, 0xE981, 0x2940, 0xEB01, 0x2BC0, 0x2A80, 0xEA41,
- 0xEE01, 0x2EC0, 0x2F80, 0xEF41, 0x2D00, 0xEDC1, 0xEC81, 0x2C40,
- 0xE401, 0x24C0, 0x2580, 0xE541, 0x2700, 0xE7C1, 0xE681, 0x2640,
- 0x2200, 0xE2C1, 0xE381, 0x2340, 0xE101, 0x21C0, 0x2080, 0xE041,
- 0xA001, 0x60C0, 0x6180, 0xA141, 0x6300, 0xA3C1, 0xA281, 0x6240,
- 0x6600, 0xA6C1, 0xA781, 0x6740, 0xA501, 0x65C0, 0x6480, 0xA441,
- 0x6C00, 0xACC1, 0xAD81, 0x6D40, 0xAF01, 0x6FC0, 0x6E80, 0xAE41,
- 0xAA01, 0x6AC0, 0x6B80, 0xAB41, 0x6900, 0xA9C1, 0xA881, 0x6840,
- 0x7800, 0xB8C1, 0xB981, 0x7940, 0xBB01, 0x7BC0, 0x7A80, 0xBA41,
- 0xBE01, 0x7EC0, 0x7F80, 0xBF41, 0x7D00, 0xBDC1, 0xBC81, 0x7C40,
- 0xB401, 0x74C0, 0x7580, 0xB541, 0x7700, 0xB7C1, 0xB681, 0x7640,
- 0x7200, 0xB2C1, 0xB381, 0x7340, 0xB101, 0x71C0, 0x7080, 0xB041,
- 0x5000, 0x90C1, 0x9181, 0x5140, 0x9301, 0x53C0, 0x5280, 0x9241,
- 0x9601, 0x56C0, 0x5780, 0x9741, 0x5500, 0x95C1, 0x9481, 0x5440,
- 0x9C01, 0x5CC0, 0x5D80, 0x9D41, 0x5F00, 0x9FC1, 0x9E81, 0x5E40,
- 0x5A00, 0x9AC1, 0x9B81, 0x5B40, 0x9901, 0x59C0, 0x5880, 0x9841,
- 0x8801, 0x48C0, 0x4980, 0x8941, 0x4B00, 0x8BC1, 0x8A81, 0x4A40,
- 0x4E00, 0x8EC1, 0x8F81, 0x4F40, 0x8D01, 0x4DC0, 0x4C80, 0x8C41,
- 0x4400, 0x84C1, 0x8581, 0x4540, 0x8701, 0x47C0, 0x4680, 0x8641,
- 0x8201, 0x42C0, 0x4380, 0x8341, 0x4100, 0x81C1, 0x8081, 0x4040
-};
-
-Transport_node::Transport_node(const uint8_t sys_id, const bool debug):
- _rx_buff_pos(0),
- _debug(debug),
- _sys_id(sys_id)
-{
-}
-
-Transport_node::~Transport_node()
-{
-}
-
-uint16_t Transport_node::crc16_byte(uint16_t crc, const uint8_t data)
-{
- return (crc >> 8) ^ crc16_table[(crc ^ data) & 0xff];
-}
-
-uint16_t Transport_node::crc16(uint8_t const *buffer, size_t len)
-{
- uint16_t crc = 0;
-
- while (len--) {
- crc = crc16_byte(crc, *buffer++);
- }
-
- return crc;
-}
-
-ssize_t Transport_node::read(uint8_t *topic_id, char out_buffer[], size_t buffer_len)
-{
- if (nullptr == out_buffer || nullptr == topic_id || !fds_OK()) {
- return -1;
- }
-
- *topic_id = 255;
-
- ssize_t len = node_read((void *)(_rx_buffer + _rx_buff_pos), sizeof(_rx_buffer) - _rx_buff_pos);
-
- if (len < 0) {
- int errsv = errno;
-
- if (errsv && EAGAIN != errsv && ETIMEDOUT != errsv) {
-#ifndef PX4_DEBUG
-
- if (_debug) { printf("\033[0;31m[ micrortps_transport ]\tRead fail %d\033[0m\n", errsv); }
-
-#else
-
- if (_debug) { PX4_DEBUG("Read fail %d", errsv); }
-
-#endif /* PX4_DEBUG */
- }
-
- return len;
- }
-
- _rx_buff_pos += len;
-
- // We read some
- size_t header_size = sizeof(struct Header);
-
- // but not enough
- if (_rx_buff_pos < header_size) {
- return 0;
- }
-
- uint32_t msg_start_pos = 0;
-
- for (msg_start_pos = 0; msg_start_pos <= _rx_buff_pos - header_size; ++msg_start_pos) {
- if ('>' == _rx_buffer[msg_start_pos] && memcmp(_rx_buffer + msg_start_pos, ">>>", 3) == 0) {
- break;
- }
- }
-
- // Start not found
- if (msg_start_pos > (_rx_buff_pos - header_size)) {
-#ifndef PX4_DEBUG
-
- if (_debug) { printf("\033[1;33m[ micrortps_transport ]\t (↓↓ %" PRIu32 ")\033[0m\n", msg_start_pos); }
-
-#else
-
- if (_debug) { PX4_DEBUG(" (↓↓ %" PRIu32 ")", msg_start_pos); }
-
-#endif /* PX4_DEBUG */
-
- // All we've checked so far is garbage, drop it - but save unchecked bytes
- memmove(_rx_buffer, _rx_buffer + msg_start_pos, _rx_buff_pos - msg_start_pos);
- _rx_buff_pos -= msg_start_pos;
- return -1;
- }
-
- // [>,>,>,topic_id,sys_id,seq,payload_length_H,payload_length_L,CRCHigh,CRCLow,payloadStart, ... ,payloadEnd]
- struct Header *header = (struct Header *)&_rx_buffer[msg_start_pos];
- uint32_t payload_len = ((uint32_t)header->payload_len_h << 8) | header->payload_len_l;
-
- // The received message comes from this system. Discard it.
- // This might happen when:
- // 1. The same UDP port is being used to send a rcv packets or
- // 2. The same topic on the agent is being used for outgoing and incoming data
- if (header->sys_id == _sys_id) {
- // Drop the message and continue with the read buffer
- memmove(_rx_buffer, _rx_buffer + msg_start_pos + 1, _rx_buff_pos - (msg_start_pos + 1));
- _rx_buff_pos -= (msg_start_pos + 1);
- return -1;
- }
-
- // The message won't fit the buffer.
- if (buffer_len < header_size + payload_len) {
- // Drop the message and continue with the read buffer
- memmove(_rx_buffer, _rx_buffer + msg_start_pos + 1, _rx_buff_pos - (msg_start_pos + 1));
- _rx_buff_pos -= (msg_start_pos + 1);
- return -EMSGSIZE;
- }
-
- // We do not have a complete message yet
- if (msg_start_pos + header_size + payload_len > _rx_buff_pos) {
- // If there's garbage at the beginning, drop it
- if (msg_start_pos > 0) {
-#ifndef PX4_DEBUG
-
- if (_debug) { printf("\033[1;33m[ micrortps_transport ]\t (↓ %" PRIu32 ")\033[0m\n", msg_start_pos); }
-
-#else
-
- if (_debug) { PX4_DEBUG(" (↓ %" PRIu32 ")", msg_start_pos); }
-
-#endif /* PX4_DEBUG */
- memmove(_rx_buffer, _rx_buffer + msg_start_pos, _rx_buff_pos - msg_start_pos);
- _rx_buff_pos -= msg_start_pos;
- }
-
- return 0;
- }
-
- uint16_t read_crc = ((uint16_t)header->crc_h << 8) | header->crc_l;
- uint16_t calc_crc = crc16((uint8_t *)_rx_buffer + msg_start_pos + header_size, payload_len);
-
- if (read_crc != calc_crc) {
-#ifndef PX4_DEBUG
-
- if (_debug) { printf("\033[0;31m[ micrortps_transport ]\tBad CRC %" PRIu16 " != %" PRIu16 "\t\t(↓ %lu)\033[0m\n", read_crc, calc_crc, (unsigned long)(header_size + payload_len)); }
-
-#else
-
- if (_debug) { PX4_DEBUG("Bad CRC %u != %u\t\t(↓ %lu)", read_crc, calc_crc, (unsigned long)(header_size + payload_len)); }
-
-#endif /* PX4_DEBUG */
-
- // Drop garbage up just beyond the start of the message
- memmove(_rx_buffer, _rx_buffer + (msg_start_pos + 1), _rx_buff_pos);
-
- // If there is a CRC error, the payload len cannot be trusted
- _rx_buff_pos -= (msg_start_pos + 1);
-
- len = -1;
-
- } else {
- // copy message to outbuffer and set other return values
- memmove(out_buffer, _rx_buffer + msg_start_pos + header_size, payload_len);
- *topic_id = header->topic_id;
- len = payload_len + header_size;
-
- // discard message from _rx_buffer
- _rx_buff_pos -= msg_start_pos + header_size + payload_len;
- memmove(_rx_buffer, _rx_buffer + msg_start_pos + header_size + payload_len, _rx_buff_pos);
- }
-
- return len;
-}
-
-size_t Transport_node::get_header_length()
-{
- return sizeof(struct Header);
-}
-
-ssize_t Transport_node::write(const uint8_t topic_id, char buffer[], size_t length)
-{
- if (!fds_OK()) {
- return -1;
- }
-
- static struct Header header = {{'>', '>', '>'}, 0u, 0u, 0u, 0u, 0u, 0u, 0u};
-
- // [>,>,>,topic_id,seq,payload_length,CRCHigh,CRCLow,payload_start, ... ,payload_end]
- uint16_t crc = crc16((uint8_t *)&buffer[sizeof(header)], length);
-
- header.topic_id = topic_id;
- header.sys_id = _sys_id;
- header.seq = _seq_number++;
- header.payload_len_h = (length >> 8) & 0xff;
- header.payload_len_l = length & 0xff;
- header.crc_h = (crc >> 8) & 0xff;
- header.crc_l = crc & 0xff;
-
- /* Headroom for header is created in client */
- /* Fill in the header in the same payload buffer to call a single node_write */
- memcpy(buffer, &header, sizeof(header));
- ssize_t len = node_write(buffer, length + sizeof(header));
-
- if (len != ssize_t(length + sizeof(header))) {
- return len;
- }
-
- return len + sizeof(header);
-}
-
-UART_node::UART_node(const char *uart_name, const uint32_t baudrate,
- const uint32_t poll_ms, const bool hw_flow_control,
- const bool sw_flow_control, const uint8_t sys_id,
- const bool debug):
- Transport_node(sys_id, debug),
- _uart_fd(-1),
- _baudrate(baudrate),
- _poll_ms(poll_ms),
- _hw_flow_control(hw_flow_control),
- _sw_flow_control(sw_flow_control)
-{
-
- if (nullptr != uart_name) {
- strcpy(_uart_name, uart_name);
- }
-}
-
-UART_node::~UART_node()
-{
- close();
-}
-
-int UART_node::init()
-{
- // Open a serial port
- _uart_fd = open(_uart_name, O_RDWR | O_NOCTTY | O_NONBLOCK);
-
- if (_uart_fd < 0) {
-#ifndef PX4_ERR
- printf("\033[0;31m[ micrortps_transport ]\tUART transport: Failed to open device: %s (%d)\033[0m\n", _uart_name, errno);
-#else
- PX4_ERR("UART transport: Failed to open device: %s (%d)", _uart_name, errno);
-#endif /* PX4_ERR */
- return -errno;
- }
-
- // If using shared UART, no need to set it up
- if (_baudrate == 0) {
- _poll_fd[0].fd = _uart_fd;
- _poll_fd[0].events = POLLIN;
- return _uart_fd;
- }
-
- // Try to set baud rate
- struct termios uart_config;
- int termios_state;
-
- // Back up the original uart configuration to restore it after exit
- if ((termios_state = tcgetattr(_uart_fd, &uart_config)) < 0) {
- int errno_bkp = errno;
-#ifndef PX4_ERR
- printf("\033[0;31m[ micrortps_transport ]\tUART transport: ERR GET CONF %s: %d (%d)\n\033[0m", _uart_name, termios_state,
- errno);
-#else
- PX4_ERR("UART transport: ERR GET CONF %s: %d (%d)", _uart_name, termios_state, errno);
-#endif /* PX4_ERR */
- close();
- return -errno_bkp;
- }
-
-#if defined(__linux__) || defined(__PX4_LINUX)
- uart_config.c_iflag &= ~(IGNBRK | BRKINT | ICRNL | INLCR | PARMRK | INPCK | ISTRIP | IXON);
- uart_config.c_oflag &= ~(OCRNL | ONLCR | ONLRET | ONOCR | OFILL | OPOST);
-
- uart_config.c_lflag &= ~(ECHO | ECHOE | ECHOK | ECHOCTL | ECHOKE | ECHONL | ICANON | IEXTEN | ISIG);
-
- // never send SIGTTOU
- uart_config.c_lflag &= ~(TOSTOP);
-
- // ignore modem control lines
- uart_config.c_cflag |= CLOCAL;
-
- // 8 bits
- uart_config.c_cflag |= CS8;
-#else /* __linux__ */
-
- // Clear ONLCR flag (which appends a CR for every LF)
- uart_config.c_oflag &= ~ONLCR;
-#endif
-
- // Flow control
- if (_hw_flow_control) {
- // HW flow control
- uart_config.c_cflag |= CRTSCTS;
- uart_config.c_iflag &= ~(IXON | IXOFF | IXANY);
- } else if (_sw_flow_control) {
- // SW flow control
- uart_config.c_cflag &= ~CRTSCTS;
- uart_config.c_lflag |= (IXON | IXOFF | IXANY);
- } else {
- uart_config.c_cflag &= ~CRTSCTS;
- uart_config.c_iflag &= ~(IXON | IXOFF | IXANY);
- }
-
- // Set baud rate
- speed_t speed;
-
- if (!baudrate_to_speed(_baudrate, &speed)) {
-#ifndef PX4_ERR
- printf("\033[0;31m[ micrortps_transport ]\tUART transport: ERR SET BAUD %s: Unsupported _baudrate: %d\n\tsupported examples:\n\t9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000, 921600, 1000000\033[0m\n",
- _uart_name, _baudrate);
-#else
- PX4_ERR("UART transport: ERR SET BAUD %s: Unsupported baudrate: %" PRIu32 "\n\tsupported examples:\n\t9600, 19200, 38400, 57600, 115200, 230400, 460800, 500000, 921600, 1000000\n",
- _uart_name, _baudrate);
-#endif /* PX4_ERR */
- close();
- return -EINVAL;
- }
-
- if (cfsetispeed(&uart_config, speed) < 0 || cfsetospeed(&uart_config, speed) < 0) {
- int errno_bkp = errno;
-#ifndef PX4_ERR
- printf("\033[0;31m[ micrortps_transport ]\tUART transport: ERR SET BAUD %s: %d (%d)\033[0m\n", _uart_name, termios_state,
- errno);
-#else
- PX4_ERR("ERR SET BAUD %s: %d (%d)", _uart_name, termios_state, errno);
-#endif /* PX4_ERR */
- close();
- return -errno_bkp;
- }
-
- if ((termios_state = tcsetattr(_uart_fd, TCSANOW, &uart_config)) < 0) {
- int errno_bkp = errno;
-#ifndef PX4_ERR
- printf("\033[0;31m[ micrortps_transport ]\tUART transport: ERR SET CONF %s (%d)\033[0m\n", _uart_name, errno);
-#else
- PX4_ERR("UART transport: ERR SET CONF %s (%d)", _uart_name, errno);
-#endif /* PX4_ERR */
- close();
- return -errno_bkp;
- }
-
-#if defined(__linux__) || defined(__PX4_LINUX)
- // For Linux, set high speed polling at the chip level. Since this routine relies on a USB latency
- // change at the chip level it may fail on certain chip sets if their driver does not support this
- // configuration request
- {
- struct serial_struct serial_ctl;
-
- if (ioctl(_uart_fd, TIOCGSERIAL, &serial_ctl) < 0) {
- printf("\033[0;31m[ micrortps_transport ]\tError while trying to read serial port configuration: %d\033[0m\n", errno);
-
- if (ioctl(_uart_fd, TCFLSH, TCIOFLUSH) == -1) {
- int errno_bkp = errno;
- printf("\033[0;31m[ protocol__splitter ]\tCould not flush terminal\033[0m\n");
- close();
- return -errno_bkp;
- }
- }
-
- serial_ctl.flags |= ASYNC_LOW_LATENCY;
-
- if (ioctl(_uart_fd, TIOCSSERIAL, &serial_ctl) < 0) {
- int errno_bkp = errno;
- printf("\033[0;31m[ micrortps_transport ]\tError while trying to write serial port latency: %d\033[0m\n", errno);
- close();
- return -errno_bkp;
- }
- }
-#endif /* __linux__ */
-
- char aux[64];
- bool flush = false;
-
- while (0 < ::read(_uart_fd, (void *)&aux, 64)) {
- flush = true;
-#ifndef px4_usleep
- usleep(1000);
-#else
- /* With PX4 px4_usleep() should be used. */
- px4_usleep(1000);
-#endif /* px4_usleep */
- }
-
- if (flush) {
-#ifndef PX4_DEBUG
-
- if (_debug) { printf("[ micrortps_transport ]\tUART transport: Flush\n"); }
-
-#else
-
- if (_debug) { PX4_DEBUG("UART transport: Flush"); }
-
-#endif /* PX4_DEBUG */
-
- } else {
-#ifndef PX4_DEBUG
-
- if (_debug) { printf("[ micrortps_transport ]\tUART transport: No flush\n"); }
-
-#else
-
- if (_debug) { PX4_DEBUG("UART transport: No flush"); }
-
-#endif /* PX4_INFO */
- }
-
- _poll_fd[0].fd = _uart_fd;
- _poll_fd[0].events = POLLIN;
-
- return _uart_fd;
-}
-
-bool UART_node::fds_OK()
-{
- return (-1 != _uart_fd);
-}
-
-uint8_t UART_node::close()
-{
- if (-1 != _uart_fd) {
-#ifndef PX4_WARN
- printf("\033[1;33m[ micrortps_transport ]\tClosed UART.\n\033[0m");
-#else
- PX4_WARN("Closed UART.");
-#endif /* PX4_WARN */
- ::close(_uart_fd);
- _uart_fd = -1;
- memset(&_poll_fd, 0, sizeof(_poll_fd));
- }
-
- return 0;
-}
-
-ssize_t UART_node::node_read(void *buffer, size_t len)
-{
- if (nullptr == buffer || !fds_OK()) {
- return -1;
- }
-
- ssize_t ret = 0;
- int r = poll(_poll_fd, 1, _poll_ms);
-
- if (r == 1 && (_poll_fd[0].revents & POLLIN)) {
- ret = ::read(_uart_fd, buffer, len);
- }
-
- return ret;
-}
-
-ssize_t UART_node::node_write(void *buffer, size_t len)
-{
- if (nullptr == buffer || !fds_OK()) {
- return -1;
- }
-
- return ::write(_uart_fd, buffer, len);
-}
-
-bool UART_node::baudrate_to_speed(uint32_t bauds, speed_t *speed)
-{
-#ifndef B460800
-#define B460800 460800
-#endif
-
-#ifndef B500000
-#define B500000 500000
-#endif
-
-#ifndef B921600
-#define B921600 921600
-#endif
-
-#ifndef B1000000
-#define B1000000 1000000
-#endif
-
-#ifndef B1500000
-#define B1500000 1500000
-#endif
-
-#ifndef B2000000
-#define B2000000 2000000
-#endif
-
- switch (bauds) {
- case 0: *speed = B0; break;
-
- case 50: *speed = B50; break;
-
- case 75: *speed = B75; break;
-
- case 110: *speed = B110; break;
-
- case 134: *speed = B134; break;
-
- case 150: *speed = B150; break;
-
- case 200: *speed = B200; break;
-
- case 300: *speed = B300; break;
-
- case 600: *speed = B600; break;
-
- case 1200: *speed = B1200; break;
-
- case 1800: *speed = B1800; break;
-
- case 2400: *speed = B2400; break;
-
- case 4800: *speed = B4800; break;
-
- case 9600: *speed = B9600; break;
-
- case 19200: *speed = B19200; break;
-
- case 38400: *speed = B38400; break;
-
- case 57600: *speed = B57600; break;
-
- case 115200: *speed = B115200; break;
-
- case 230400: *speed = B230400; break;
-
- case 460800: *speed = B460800; break;
-
- case 500000: *speed = B500000; break;
-
- case 921600: *speed = B921600; break;
-
- case 1000000: *speed = B1000000; break;
-
- case 1500000: *speed = B1500000; break;
-
- case 2000000: *speed = B2000000; break;
-
-#ifdef B3000000
- case 3000000: *speed = B3000000; break;
-
-#endif
-#ifdef B3500000
- case 3500000: *speed = B3500000; break;
-
-#endif
-#ifdef B4000000
- case 4000000: *speed = B4000000; break;
-
-#endif
- default:
- return false;
- }
-
- return true;
-}
-
-UDP_node::UDP_node(const char *udp_ip, uint16_t udp_port_recv,
- uint16_t udp_port_send, const uint8_t sys_id, const bool debug):
- Transport_node(sys_id, debug),
- _sender_fd(-1),
- _receiver_fd(-1),
- _udp_port_recv(udp_port_recv),
- _udp_port_send(udp_port_send)
-{
- if (nullptr != udp_ip) {
- strcpy(_udp_ip, udp_ip);
- }
-}
-
-UDP_node::~UDP_node()
-{
- close();
-}
-
-int UDP_node::init()
-{
- if (0 > init_receiver(_udp_port_recv) || 0 > init_sender(_udp_port_send)) {
- return -1;
- }
-
- return 0;
-}
-
-bool UDP_node::fds_OK()
-{
- return (-1 != _sender_fd && -1 != _receiver_fd);
-}
-
-int UDP_node::init_receiver(uint16_t udp_port)
-{
-#if !defined (__PX4_NUTTX) || (defined (CONFIG_NET) && defined (__PX4_NUTTX))
- // udp socket data
- memset((char *)&_receiver_inaddr, 0, sizeof(_receiver_inaddr));
- _receiver_inaddr.sin_family = AF_INET;
- _receiver_inaddr.sin_port = htons(udp_port);
- _receiver_inaddr.sin_addr.s_addr = htonl(INADDR_ANY);
-
- if ((_receiver_fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
-#ifndef PX4_ERR
- printf("\033[0;31m[ micrortps_transport ]\tUDP transport: Create socket failed\033[0m\n");
-#else
- PX4_ERR("UDP transport: Create socket failed");
-#endif /* PX4_ERR */
- return -1;
- }
-
-#ifndef PX4_INFO
- printf("[ micrortps_transport ]\tUDP transport: Trying to connect...\n");
-#else
- PX4_INFO("UDP transport: Trying to connect...");
-#endif /* PX4_INFO */
-
- if (bind(_receiver_fd, (struct sockaddr *)&_receiver_inaddr, sizeof(_receiver_inaddr)) < 0) {
-#ifndef PX4_ERR
- printf("\033[0;31m[ micrortps_transport ]\tUDP transport: Bind failed\033[0m\n");
-#else
- PX4_ERR("UDP transport: Bind failed");
-#endif /* PX4_ERR */
- return -1;
- }
-
-#ifndef PX4_INFO
- printf("[ micrortps_transport ]\tUDP transport: Connected to server!\n\n");
-#else
- PX4_INFO("UDP transport: Connected to server!");
-#endif /* PX4_INFO */
-#endif /* __PX4_NUTTX */
- return 0;
-}
-
-int UDP_node::init_sender(uint16_t udp_port)
-{
-#if !defined (__PX4_NUTTX) || (defined (CONFIG_NET) && defined (__PX4_NUTTX))
-
- if ((_sender_fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
-#ifndef PX4_ERR
- printf("\033[0;31m[ micrortps_transport ]\tUDP transport: Create socket failed\033[0m\n");
-#else
- PX4_ERR("UDP transport: Create socket failed");
-#endif /* PX4_ERR */
- return -1;
- }
-
- memset((char *) &_sender_outaddr, 0, sizeof(_sender_outaddr));
- _sender_outaddr.sin_family = AF_INET;
- _sender_outaddr.sin_port = htons(udp_port);
-
- if (inet_aton(_udp_ip, &_sender_outaddr.sin_addr) == 0) {
-#ifndef PX4_ERR
- printf("\033[0;31m[ micrortps_transport ]\tUDP transport: inet_aton() failed\033[0m\n");
-#else
- PX4_ERR("UDP transport: inet_aton() failed");
-#endif /* PX4_ERR */
- return -1;
- }
-
-#endif /* __PX4_NUTTX */
-
- return 0;
-}
-
-uint8_t UDP_node::close()
-{
-#if !defined (__PX4_NUTTX) || (defined (CONFIG_NET) && defined (__PX4_NUTTX))
-
- if (_sender_fd != -1) {
-#ifndef PX4_WARN
- printf("\033[1;33m[ micrortps_transport ]\tUDP transport: Closed sender socket!\033[0m\n");
-#else
- PX4_WARN("UDP transport: Closed sender socket!");
-#endif /* PX4_WARN */
- shutdown(_sender_fd, SHUT_RDWR);
- ::close(_sender_fd);
- _sender_fd = -1;
- }
-
- if (_receiver_fd != -1) {
-#ifndef PX4_WARN
- printf("\033[1;33m[ micrortps_transport ]\tUDP transport: Closed receiver socket!\033[0m\n");
-#else
- PX4_WARN("UDP transport: Closed receiver socket!");
-#endif /* PX4_WARN */
- shutdown(_receiver_fd, SHUT_RDWR);
- ::close(_receiver_fd);
- _receiver_fd = -1;
- }
-
-#endif /* __PX4_NUTTX */
- return 0;
-}
-
-ssize_t UDP_node::node_read(void *buffer, size_t len)
-{
- if (nullptr == buffer || !fds_OK()) {
- return -1;
- }
-
- ssize_t ret = 0;
-#if !defined (__PX4_NUTTX) || (defined (CONFIG_NET) && defined (__PX4_NUTTX))
- // Blocking call
- static socklen_t addrlen = sizeof(_receiver_outaddr);
- ret = recvfrom(_receiver_fd, buffer, len, 0, (struct sockaddr *)&_receiver_outaddr, &addrlen);
-#endif /* !defined (__PX4_NUTTX) || (defined (CONFIG_NET) && defined (__PX4_NUTTX)) */
- return ret;
-}
-
-ssize_t UDP_node::node_write(void *buffer, size_t len)
-{
- if (nullptr == buffer || !fds_OK()) {
- return -1;
- }
-
- ssize_t ret = 0;
-#if !defined (__PX4_NUTTX) || (defined (CONFIG_NET) && defined (__PX4_NUTTX))
- ret = sendto(_sender_fd, buffer, len, 0, (struct sockaddr *)&_sender_outaddr, sizeof(_sender_outaddr));
-#endif /* !defined (__PX4_NUTTX) || (defined (CONFIG_NET) && defined (__PX4_NUTTX)) */
- return ret;
-}
diff --git a/msg/templates/urtps/microRTPS_transport.h b/msg/templates/urtps/microRTPS_transport.h
deleted file mode 100644
index 3605b63f8c..0000000000
--- a/msg/templates/urtps/microRTPS_transport.h
+++ /dev/null
@@ -1,158 +0,0 @@
-/****************************************************************************
- *
- * Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
- * Copyright (c) 2018-2021 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 of the copyright holder 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 HOLDER 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.
- *
- ****************************************************************************/
-
-#pragma once
-
-#include
-#include
-#include
-#include
-
-#define BUFFER_SIZE 1024
-#define DEFAULT_UART "/dev/ttyACM0"
-
-namespace MicroRtps {
- enum class System {
- FMU,
- MISSION_COMPUTER
- };
-}
-
-class Transport_node
-{
-public:
- Transport_node(const uint8_t sys_id, const bool debug);
- virtual ~Transport_node();
-
- virtual int init() {return 0;}
- virtual uint8_t close() {return 0;}
- ssize_t read(uint8_t *topic_id, char out_buffer[], size_t buffer_len);
-
- /**
- * write a buffer
- * @param topic_id
- * @param buffer buffer to write: it must leave get_header_length() bytes free at the beginning. This will be
- * filled with the header. length does not include get_header_length(). So buffer looks like this:
- * -------------------------------------------------
- * | header (leave free) | payload data |
- * | get_header_length() bytes | length bytes |
- * -------------------------------------------------
- * @param length buffer length excluding header length
- * @return length on success, <0 on error
- */
- ssize_t write(const uint8_t topic_id, char buffer[], size_t length);
-
- /** Get the Length of struct Header to make headroom for the size of struct Header along with payload */
- size_t get_header_length();
-
-private:
- struct __attribute__((packed)) Header {
- char marker[3];
- uint8_t topic_id;
- uint8_t sys_id;
- uint8_t seq;
- uint8_t payload_len_h;
- uint8_t payload_len_l;
- uint8_t crc_h;
- uint8_t crc_l;
- };
-
-protected:
- virtual ssize_t node_read(void *buffer, size_t len) = 0;
- virtual ssize_t node_write(void *buffer, size_t len) = 0;
- virtual bool fds_OK() = 0;
- uint16_t crc16_byte(uint16_t crc, const uint8_t data);
- uint16_t crc16(uint8_t const *buffer, size_t len);
-
- uint32_t _rx_buff_pos;
- char _rx_buffer[BUFFER_SIZE]{};
-
- bool _debug;
-
- uint8_t _sys_id;
- uint8_t _seq_number{0};
-};
-
-class UART_node: public Transport_node
-{
-public:
- UART_node(const char *uart_name, const uint32_t baudrate,
- const uint32_t poll_ms, const bool hw_flow_control,
- const bool sw_flow_control, const uint8_t sys_id,
- const bool debug);
- virtual ~UART_node();
-
- int init();
- uint8_t close();
-
-protected:
- ssize_t node_read(void *buffer, size_t len);
- ssize_t node_write(void *buffer, size_t len);
- bool fds_OK();
- bool baudrate_to_speed(uint32_t bauds, speed_t *speed);
-
- int _uart_fd;
- char _uart_name[64]{};
- uint32_t _baudrate;
- uint32_t _poll_ms;
- bool _hw_flow_control{false};
- bool _sw_flow_control{false};
- struct pollfd _poll_fd[1]{};
-};
-
-class UDP_node: public Transport_node
-{
-public:
- UDP_node(const char *udp_ip, uint16_t udp_port_recv, uint16_t udp_port_send,
- const uint8_t sys_id, const bool debug);
- virtual ~UDP_node();
-
- int init();
- uint8_t close();
-
-protected:
- int init_receiver(uint16_t udp_port);
- int init_sender(uint16_t udp_port);
- ssize_t node_read(void *buffer, size_t len);
- ssize_t node_write(void *buffer, size_t len);
- bool fds_OK();
-
- int _sender_fd;
- int _receiver_fd;
- char _udp_ip[16]{};
- uint16_t _udp_port_recv;
- uint16_t _udp_port_send;
- struct sockaddr_in _sender_outaddr;
- struct sockaddr_in _receiver_inaddr;
- struct sockaddr_in _receiver_outaddr;
-};
diff --git a/msg/templates/urtps/msg.idl.em b/msg/templates/urtps/msg.idl.em
deleted file mode 100644
index 1fa20e3fe6..0000000000
--- a/msg/templates/urtps/msg.idl.em
+++ /dev/null
@@ -1,154 +0,0 @@
-@###############################################
-@#
-@# ROS message to IDL converter
-@#
-@# EmPy template for generating .idl files
-@#
-@###############################################
-@# Start of Template
-@#
-@# Context:
-@# - spec (msggen.MsgSpec) Parsed specification of the .msg file
-@################################################################################
-@#
-@# Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
-@# Copyright (c) 2018-2021 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 of the copyright holder 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 HOLDER 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.
-@#
-@################################################################################
-@{
-import genmsg.msgs
-from packaging import version
-from px_generate_uorb_topic_helper import * # this is in Tools/
-
-builtin_types = set()
-array_types = set()
-
-topic = alias if alias else spec.short_name
-}@
-@#################################################
-@# Searching for serialize function per each field
-@#################################################
-@{
-
-def get_include_directives(spec):
- include_directives = set()
- for field in (spec.parsed_fields()):
- if genmsg.msgs.is_valid_constant_type(genmsg.msgs.bare_msg_type(field.type)):
- continue
- builtin_type = str(field.base_type).replace('px4/', '')
- if version.parse(fastrtps_version) <= version.parse('1.7.2'):
- include_directive = '#include "%s_.idl"' % builtin_type
- else:
- include_directive = '#include "%s.idl"' % builtin_type
- builtin_types.add(builtin_type)
- include_directives.add(include_directive)
- return sorted(include_directives)
-
-
-def get_idl_type_name(field_type):
- if field_type in type_idl_map:
- return type_idl_map[field_type]
- else:
- (package, name) = genmsg.names.package_resource_name(field_type)
- return name
-
-
-def add_msg_field(field):
- if (not field.is_header):
- if field.is_array:
- if version.parse(fastrtps_version) <= version.parse('1.7.2'):
- print(' {0}__{1}_array_{2} {3}_;'.format(topic, str(get_idl_type_name(field.base_type)).replace(" ", "_"), str(field.array_len), field.name))
- else:
- print(' {0}__{1}_array_{2} {3};'.format(topic, str(get_idl_type_name(field.base_type)).replace(" ", "_"), str(field.array_len), field.name))
- else:
- if version.parse(fastrtps_version) <= version.parse('1.7.2'):
- base_type = get_idl_type_name(field.base_type) + "_" if get_idl_type_name(field.base_type) in builtin_types else get_idl_type_name(field.base_type)
- else:
- base_type = get_idl_type_name(field.base_type) if get_idl_type_name(field.base_type) in builtin_types else get_idl_type_name(field.base_type)
- print(' {0} {1}_;'.format(base_type, field.name))
-
-def add_msg_fields():
- for field in spec.parsed_fields():
- add_msg_field(field)
-
-
-def add_array_typedefs():
- for field in spec.parsed_fields():
- if not field.is_header and field.is_array:
- if version.parse(fastrtps_version) <= version.parse('1.7.2'):
- base_type = get_idl_type_name(field.base_type) + "_" if get_idl_type_name(field.base_type) in builtin_types else get_idl_type_name(field.base_type)
- else:
- base_type = get_idl_type_name(field.base_type) if get_idl_type_name(field.base_type) in builtin_types else get_idl_type_name(field.base_type)
- array_type = 'typedef {0} {1}__{2}_array_{3}[{4}];'.format(base_type, topic, get_idl_type_name(field.base_type).replace(" ", "_"), field.array_len, field.array_len)
- if array_type not in array_types:
- array_types.add(array_type)
- for atype in array_types:
- print(atype)
-
-
-def add_msg_constants():
- sorted_constants = sorted(spec.constants,
- key=sizeof_field_type, reverse=True)
- for constant in sorted_constants:
- print('const {0} {1}__{2} = {3};'.format(get_idl_type_name(constant.type), topic, constant.name, constant.val))
-
-}
-#ifndef __@(topic)__idl__
-#define __@(topic)__idl__
-
-@#############################
-@# Include dependency messages
-@#############################
-@[for line in get_include_directives(spec)]@
-@(line)@
-@[end for]@
-
-
-@# Constants
-@add_msg_constants()
-@# Array types
-@add_array_typedefs()
-@[if version.parse(fastrtps_version) <= version.parse('1.7.2')]@
-struct @(topic)_
-@[else]@
-struct @(topic)
-@[end if]@
-{
-@add_msg_fields()
-@[if version.parse(fastrtps_version) <= version.parse('1.7.2')]@
-}; // struct @(topic)_
-
-#pragma keylist @(topic)_
-@[else]@
-}; // struct @(topic)
-
-#pragma keylist @(topic)
-@[end if]@
-
-#endif // __@(topic)__idl__
diff --git a/msg/tools/generate_microRTPS_bridge.py b/msg/tools/generate_microRTPS_bridge.py
deleted file mode 100644
index 3162d635d1..0000000000
--- a/msg/tools/generate_microRTPS_bridge.py
+++ /dev/null
@@ -1,444 +0,0 @@
-#!/usr/bin/env python3
-################################################################################
-#
-# Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima).
-# Copyright (c) 2018-2021 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 of the copyright holder 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 HOLDER 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.
-#
-################################################################################
-
-# This script can generate the client and agent code based on a set of topics
-# to sent and set to receive. It uses fastrtpsgen to generate the code from the
-# IDL for the topic messages. The PX4 msg definitions are used to create the IDL
-# used by fastrtpsgen using templates.
-
-import sys
-import os
-import argparse
-import shutil
-import px_generate_uorb_topic_files
-from uorb_rtps_classifier import Classifier
-import subprocess
-import glob
-import errno
-import re
-
-try:
- from six.moves import input
-except ImportError as e:
- print("Failed to import six: " + e)
- print("")
- print("You may need to install it using:")
- print(" pip3 install --user six")
- print("")
- sys.exit(1)
-
-try:
- from packaging import version
-except ImportError as e:
- print("Failed to import packaging: " + str(e))
- print("")
- print("You may need to install it using:")
- print(" pip3 install --user packaging")
- print("")
- sys.exit(1)
-
-
-default_client_out = "src/modules/micrortps_bridge/micrortps_client"
-default_agent_out = "src/modules/micrortps_bridge/micrortps_agent"
-default_uorb_templates_dir = "templates/uorb_microcdr"
-default_urtps_templates_dir = "templates/urtps"
-default_urtps_topics_file = "tools/urtps_bridge_topics.yaml"
-default_package_name = px_generate_uorb_topic_files.PACKAGE
-
-parser = argparse.ArgumentParser()
-
-parser.add_argument("-a", "--agent", dest='agent', action="store_true",
- help="Flag for generate the agent, by default is true if -c is not specified")
-parser.add_argument("-c", "--client", dest='client', action="store_true",
- help="Flag for generate the client, by default is true if -a is not specified")
-parser.add_argument("-i", "--generate-idl", dest='gen_idl',
- action="store_true", help="Flag for generate idl files for each msg")
-parser.add_argument("-j", "--idl-dir", dest='idl_dir',
- type=str, help="IDL files dir", default='')
-parser.add_argument("-m", "--mkdir-build", dest='mkdir_build',
- action="store_true", help="Flag to create 'build' dir")
-parser.add_argument("-l", "--generate-cmakelists", dest='cmakelists',
- action="store_true", help="Flag to generate a CMakeLists.txt file for the micro-RTPS agent")
-parser.add_argument("-t", "--topic-msg-dir", dest='msgdir', type=str,
- help="Topics message, by default using relative path 'msg/'", default="msg")
-parser.add_argument("-b", "--uorb-templates-dir", dest='uorb_templates', type=str,
- help="uORB templates, by default using relative path to msgdir 'templates/uorb_microcdr'", default=default_uorb_templates_dir)
-parser.add_argument("-q", "--urtps-templates-dir", dest='urtps_templates', type=str,
- help="uRTPS templates, by default using relative path to msgdir 'templates/urtps'", default=default_urtps_templates_dir)
-parser.add_argument("-y", "--rtps-ids-file", dest='yaml_file', type=str,
- help="Setup uRTPS bridge topics file path, by default using relative path to msgdir 'tools/urtps_bridge_topics.yaml'", default=default_urtps_topics_file)
-parser.add_argument("-p", "--package", dest='package', type=str,
- help="Msg package naming, by default px4", default=default_package_name)
-parser.add_argument("-o", "--agent-outdir", dest='agentdir', type=str,
- help="Agent output dir, by default using relative path 'src/modules/micrortps_bridge/micrortps_agent'", default=default_agent_out)
-parser.add_argument("-u", "--client-outdir", dest='clientdir', type=str,
- help="Client output dir, by default using relative path 'src/modules/micrortps_bridge/micrortps_client'", default=default_client_out)
-parser.add_argument("-f", "--fastrtpsgen-dir", dest='fastrtpsgen', type=str, nargs='?',
- help="fastrtpsgen installation dir, only needed if fastrtpsgen is not in PATH, by default empty", default="")
-parser.add_argument("-g", "--fastrtpsgen-include", dest='fastrtpsgen_include', type=str,
- help="directory(ies) to add to preprocessor include paths of fastrtpsgen, by default empty", default="")
-parser.add_argument("-r", "--ros2-distro", dest='ros2_distro', type=str, nargs='?',
- help="ROS2 distro, only required if generating the agent for usage with ROS2 nodes, by default empty", default="")
-parser.add_argument("--delete-tree", dest='del_tree',
- action="store_true", help="Delete dir tree output dir(s)")
-
-
-if len(sys.argv) <= 1:
- parser.print_usage()
- exit(-1)
-
-# Parse arguments
-args = parser.parse_args()
-agent = args.agent
-client = args.client
-cmakelists = args.cmakelists
-del_tree = args.del_tree
-gen_idl = args.gen_idl
-mkdir_build = args.mkdir_build
-package = args.package
-
-# Msg files path
-msg_dir = os.path.abspath(args.msgdir)
-px_generate_uorb_topic_files.append_to_include_path(
- {msg_dir}, px_generate_uorb_topic_files.INCL_DEFAULT, package)
-
-# Agent files output path
-agent_out_dir = os.path.abspath(args.agentdir)
-
-# Client files output path
-client_out_dir = os.path.abspath(args.clientdir)
-
-# IDL files path
-idl_dir = args.idl_dir
-if idl_dir != '':
- idl_dir = os.path.abspath(args.idl_dir)
-else:
- idl_dir = os.path.join(agent_out_dir, "idl")
-
-if args.fastrtpsgen is None or args.fastrtpsgen == '':
- # Assume fastrtpsgen is in PATH
- fastrtpsgen_path = 'fastrtpsgen'
- for dirname in os.environ['PATH'].split(':'):
- candidate = os.path.join(dirname, 'fastrtpsgen')
- if os.path.isfile(candidate):
- fastrtpsgen_path = candidate
-else:
- # Path to fastrtpsgen is explicitly specified
- if os.path.isdir(args.fastrtpsgen):
- fastrtpsgen_path = os.path.join(
- os.path.abspath(args.fastrtpsgen), 'fastrtpsgen')
- else:
- fastrtpsgen_path = args.fastrtpsgen
-
-fastrtpsgen_include = args.fastrtpsgen_include
-if fastrtpsgen_include is not None and fastrtpsgen_include != '':
- fastrtpsgen_include = "-I " + \
- os.path.abspath(
- args.fastrtpsgen_include) + " "
-
-# get FastRTPSGen version
-# .. note:: since Fast-RTPS 1.8.0 release, FastRTPSGen is a separated repository
-# and not included in the Fast-RTPS project.
-# The starting version since this separation is 1.0.0, which follows its own
-# versioning
-fastrtpsgen_version = version.Version("1.0.0")
-if(os.path.exists(fastrtpsgen_path)):
- try:
- fastrtpsgen_version_out = subprocess.check_output(
- [fastrtpsgen_path, "-version"]).decode("utf-8").strip()[-5:]
- except OSError:
- raise
-
- try:
- fastrtpsgen_version = version.parse(fastrtpsgen_version_out)
- except version.InvalidVersion:
- raise Exception(
- "'fastrtpsgen -version' returned None or an invalid version")
-else:
- raise Exception(
- "FastRTPSGen not found. Specify the location of fastrtpsgen with the -f flag")
-
-
-# get ROS 2 version, if exists
-ros2_distro = ''
-ros_version = os.environ.get('ROS_VERSION')
-if ros_version == '2':
- if args.ros2_distro != '':
- ros2_distro = args.ros2_distro
- else:
- ros2_distro = os.environ.get('ROS_DISTRO')
-
-# get FastRTPS version
-fastrtps_version = ''
-if not ros2_distro:
- # grab the version installed system wise
- fastrtps_version = subprocess.check_output(
- "ldconfig -v 2>/dev/null | grep libfastrtps", shell=True).decode("utf-8").strip().split('so.')[-1]
-else:
- # grab the version of the ros--fastrtps package
- fastrtps_version = re.search(r'Version:\s*([\dd.]+)', subprocess.check_output(
- "dpkg -s ros-" + ros2_distro + "-fastrtps 2>/dev/null | grep -i version", shell=True).decode("utf-8").strip()).group(1)
-
-
-# If nothing specified it's generated both
-if agent == False and client == False:
- agent = True
- client = True
-
-if del_tree:
- if agent:
- _continue = str(input("\nFiles in " + agent_out_dir +
- " will be erased, continue?[Y/n]\n"))
- if _continue == "N" or _continue == "n":
- print("Aborting execution...")
- exit(-1)
- else:
- if agent and os.path.isdir(agent_out_dir):
- shutil.rmtree(agent_out_dir)
-
- if client:
- _continue = str(input(
- "\nFiles in " + client_out_dir + " will be erased, continue?[Y/n]\n"))
- if _continue.strip() in ("N", "n"):
- print("Aborting execution...")
- exit(-1)
- else:
- if client and os.path.isdir(client_out_dir):
- shutil.rmtree(client_out_dir)
-
-if agent and os.path.isdir(os.path.join(agent_out_dir, "idl")):
- shutil.rmtree(os.path.join(agent_out_dir, "idl"))
-
-# uORB templates path
-uorb_templates_dir = (args.uorb_templates if os.path.isabs(args.uorb_templates)
- else os.path.join(msg_dir, args.uorb_templates))
-
-# uRTPS templates path
-urtps_templates_dir = (args.urtps_templates if os.path.isabs(args.urtps_templates)
- else os.path.join(msg_dir, args.urtps_templates))
-
-# parse yaml file into a map of ids and messages to send and receive
-classifier = (Classifier(os.path.abspath(args.yaml_file), msg_dir) if os.path.isabs(args.yaml_file)
- else Classifier(os.path.join(msg_dir, args.yaml_file), msg_dir))
-
-
-uRTPS_CLIENT_TEMPL_FILE = 'microRTPS_client.cpp.em'
-uRTPS_AGENT_TOPICS_H_TEMPL_FILE = 'RtpsTopics.h.em'
-uRTPS_AGENT_TOPICS_SRC_TEMPL_FILE = 'RtpsTopics.cpp.em'
-uRTPS_AGENT_TEMPL_FILE = 'microRTPS_agent.cpp.em'
-uRTPS_TIMESYNC_CPP_TEMPL_FILE = 'microRTPS_timesync.cpp.em'
-uRTPS_TIMESYNC_H_TEMPL_FILE = 'microRTPS_timesync.h.em'
-uRTPS_AGENT_CMAKELISTS_TEMPL_FILE = 'microRTPS_agent_CMakeLists.txt.em'
-uRTPS_PUBLISHER_SRC_TEMPL_FILE = 'Publisher.cpp.em'
-uRTPS_PUBLISHER_H_TEMPL_FILE = 'Publisher.h.em'
-uRTPS_SUBSCRIBER_SRC_TEMPL_FILE = 'Subscriber.cpp.em'
-uRTPS_SUBSCRIBER_H_TEMPL_FILE = 'Subscriber.h.em'
-
-
-def generate_agent(out_dir):
- global fastrtps_version
-
- if classifier.msgs_to_send:
- for msg_file in classifier.msgs_to_send:
- if gen_idl:
- if out_dir != agent_out_dir:
- px_generate_uorb_topic_files.generate_idl_file(msg_file, msg_dir, "", os.path.join(out_dir, "/idl"), urtps_templates_dir,
- package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_version, ros2_distro, classifier.msg_list)
- else:
- px_generate_uorb_topic_files.generate_idl_file(msg_file, msg_dir, "", idl_dir, urtps_templates_dir,
- package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_version, ros2_distro, classifier.msg_list)
- px_generate_uorb_topic_files.generate_topic_file(msg_file, msg_dir, "", out_dir, urtps_templates_dir,
- package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_list, fastrtps_version, ros2_distro, uRTPS_PUBLISHER_SRC_TEMPL_FILE)
- px_generate_uorb_topic_files.generate_topic_file(msg_file, msg_dir, "", out_dir, urtps_templates_dir,
- package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_list, fastrtps_version, ros2_distro, uRTPS_PUBLISHER_H_TEMPL_FILE)
-
- if classifier.alias_msgs_to_send:
- for msg_file in classifier.alias_msgs_to_send:
- msg_alias = msg_file[0]
- msg_name = msg_file[1]
- if gen_idl:
- if out_dir != agent_out_dir:
- px_generate_uorb_topic_files.generate_idl_file(msg_name, msg_dir, msg_alias, os.path.join(out_dir, "/idl"), urtps_templates_dir,
- package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_version, ros2_distro, classifier.msg_list)
- else:
- px_generate_uorb_topic_files.generate_idl_file(msg_name, msg_dir, msg_alias, idl_dir, urtps_templates_dir,
- package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_version, ros2_distro, classifier.msg_list)
- px_generate_uorb_topic_files.generate_topic_file(msg_name, msg_dir, msg_alias, out_dir, urtps_templates_dir,
- package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_list, fastrtps_version, ros2_distro, uRTPS_PUBLISHER_SRC_TEMPL_FILE)
- px_generate_uorb_topic_files.generate_topic_file(msg_name, msg_dir, msg_alias, out_dir, urtps_templates_dir,
- package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_list, fastrtps_version, ros2_distro, uRTPS_PUBLISHER_H_TEMPL_FILE)
-
- if classifier.msgs_to_receive:
- for msg_file in classifier.msgs_to_receive:
- if gen_idl:
- if out_dir != agent_out_dir:
- px_generate_uorb_topic_files.generate_idl_file(msg_file, msg_dir, "", os.path.join(out_dir, "/idl"), urtps_templates_dir,
- package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_version, ros2_distro, classifier.msg_list)
- else:
- px_generate_uorb_topic_files.generate_idl_file(msg_file, msg_dir, "", idl_dir, urtps_templates_dir,
- package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_version, ros2_distro, classifier.msg_list)
- px_generate_uorb_topic_files.generate_topic_file(msg_file, msg_dir, "", out_dir, urtps_templates_dir,
- package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_list, fastrtps_version, ros2_distro, uRTPS_SUBSCRIBER_SRC_TEMPL_FILE)
- px_generate_uorb_topic_files.generate_topic_file(msg_file, msg_dir, "", out_dir, urtps_templates_dir,
- package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_list, fastrtps_version, ros2_distro, uRTPS_SUBSCRIBER_H_TEMPL_FILE)
-
- if classifier.alias_msgs_to_receive:
- for msg_file in classifier.alias_msgs_to_receive:
- msg_alias = msg_file[0]
- msg_name = msg_file[1]
- if gen_idl:
- if out_dir != agent_out_dir:
- px_generate_uorb_topic_files.generate_idl_file(msg_name, msg_dir, msg_alias, os.path.join(out_dir, "/idl"), urtps_templates_dir,
- package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_version, ros2_distro, classifier.msg_list)
- else:
- px_generate_uorb_topic_files.generate_idl_file(msg_name, msg_dir, msg_alias, idl_dir, urtps_templates_dir,
- package, px_generate_uorb_topic_files.INCL_DEFAULT, fastrtps_version, ros2_distro, classifier.msg_list)
- px_generate_uorb_topic_files.generate_topic_file(msg_name, msg_dir, msg_alias, out_dir, urtps_templates_dir,
- package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_list, fastrtps_version, ros2_distro, uRTPS_SUBSCRIBER_SRC_TEMPL_FILE)
- px_generate_uorb_topic_files.generate_topic_file(msg_name, msg_dir, msg_alias, out_dir, urtps_templates_dir,
- package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_list, fastrtps_version, ros2_distro, uRTPS_SUBSCRIBER_H_TEMPL_FILE)
-
- px_generate_uorb_topic_files.generate_uRTPS_general(classifier.msgs_to_send, classifier.alias_msgs_to_send, classifier.msgs_to_receive, classifier.alias_msgs_to_receive, msg_dir, out_dir,
- urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_list, fastrtps_version, ros2_distro, uRTPS_AGENT_TEMPL_FILE)
- px_generate_uorb_topic_files.generate_uRTPS_general(classifier.msgs_to_send, classifier.alias_msgs_to_send, classifier.msgs_to_receive, classifier.alias_msgs_to_receive, msg_dir, out_dir,
- urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_list, fastrtps_version, ros2_distro, uRTPS_TIMESYNC_CPP_TEMPL_FILE)
- px_generate_uorb_topic_files.generate_uRTPS_general(classifier.msgs_to_send, classifier.alias_msgs_to_send, classifier.msgs_to_receive, classifier.alias_msgs_to_receive, msg_dir, out_dir,
- urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_list, fastrtps_version, ros2_distro, uRTPS_TIMESYNC_H_TEMPL_FILE)
- px_generate_uorb_topic_files.generate_uRTPS_general(classifier.msgs_to_send, classifier.alias_msgs_to_send, classifier.msgs_to_receive, classifier.alias_msgs_to_receive, msg_dir, out_dir,
- urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_list, fastrtps_version, ros2_distro, uRTPS_AGENT_TOPICS_H_TEMPL_FILE)
- px_generate_uorb_topic_files.generate_uRTPS_general(classifier.msgs_to_send, classifier.alias_msgs_to_send, classifier.msgs_to_receive, classifier.alias_msgs_to_receive, msg_dir, out_dir,
- urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_list, fastrtps_version, ros2_distro, uRTPS_AGENT_TOPICS_SRC_TEMPL_FILE)
- if cmakelists:
- px_generate_uorb_topic_files.generate_uRTPS_general(classifier.msgs_to_send, classifier.alias_msgs_to_send, classifier.msgs_to_receive, classifier.alias_msgs_to_receive, msg_dir, os.path.dirname(out_dir),
- urtps_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_list, fastrtps_version, ros2_distro, uRTPS_AGENT_CMAKELISTS_TEMPL_FILE)
-
- # Final steps to install agent
- mkdir_p(os.path.join(out_dir, "fastrtpsgen"))
- prev_cwd_path = os.getcwd()
- os.chdir(os.path.join(out_dir, "fastrtpsgen"))
- if not glob.glob(os.path.join(idl_dir, "*.idl")):
- raise Exception("No IDL files found in %s" % idl_dir)
-
- # If it is generating the bridge code for interfacing with ROS2, then set
- # the '-typeros2' option in fastrtpsgen.
- # .. note:: This is only available in FastRTPSGen 1.0.4 and above
- gen_ros2_typename = ""
- if ros2_distro and ros2_distro in ['dashing', 'eloquent', 'foxy', 'galactic', 'rolling'] and fastrtpsgen_version >= version.Version("1.0.4"):
- gen_ros2_typename = "-typeros2 "
-
- idl_files = []
- for idl_file in glob.glob(os.path.join(idl_dir, "*.idl")):
- # Only run the generator for the topics that are actually marked to be
- # used by the bridge
- if os.path.splitext(os.path.basename(idl_file))[0] in classifier.msg_list:
- idl_files.append(idl_file)
-
- try:
- ret = subprocess.check_call(fastrtpsgen_path + " -d " + out_dir +
- "/fastrtpsgen -example x64Linux2.6gcc " + gen_ros2_typename + fastrtpsgen_include + " ".join(str(idl_file) for idl_file in idl_files), shell=True)
- except OSError:
- raise
-
- rm_wildcard(os.path.join(out_dir, "fastrtpsgen/*PubSubMain*"))
- rm_wildcard(os.path.join(out_dir, "fastrtpsgen/makefile*"))
- rm_wildcard(os.path.join(out_dir, "fastrtpsgen/*Publisher*"))
- rm_wildcard(os.path.join(out_dir, "fastrtpsgen/*Subscriber*"))
- for f in glob.glob(os.path.join(out_dir, "fastrtpsgen/*.cxx")):
- os.rename(f, f.replace(".cxx", ".cpp"))
- cp_wildcard(os.path.join(out_dir, "fastrtpsgen/*"), out_dir)
- if os.path.isdir(os.path.join(out_dir, "fastrtpsgen")):
- shutil.rmtree(os.path.join(out_dir, "fastrtpsgen"))
- cp_wildcard(os.path.join(urtps_templates_dir,
- "microRTPS_transport.*"), agent_out_dir)
- if cmakelists:
- os.rename(os.path.join(os.path.dirname(out_dir), "microRTPS_agent_CMakeLists.txt"),
- os.path.join(os.path.dirname(out_dir), "CMakeLists.txt"))
- if (mkdir_build):
- mkdir_p(os.path.join(os.path.dirname(out_dir), "build"))
- os.chdir(prev_cwd_path)
- return 0
-
-
-def rm_wildcard(pattern):
- for f in glob.glob(pattern):
- os.remove(f)
-
-
-def cp_wildcard(pattern, destdir):
- for f in glob.glob(pattern):
- shutil.copy(f, destdir)
-
-
-def mkdir_p(dirpath):
- try:
- os.makedirs(dirpath)
- except OSError as e:
- if e.errno == errno.EEXIST and os.path.isdir(dirpath):
- pass
- else:
- raise
-
-
-def generate_client(out_dir):
- global fastrtps_version
-
- # Rename work in the default path
- if default_client_out != out_dir:
- def_file = os.path.join(default_client_out, "microRTPS_client.cpp")
- if os.path.isfile(def_file):
- os.rename(def_file, def_file.replace(".cpp", ".cpp_"))
- def_file = os.path.join(default_client_out, "microRTPS_transport.cpp")
- if os.path.isfile(def_file):
- os.rename(def_file, def_file.replace(".cpp", ".cpp_"))
- def_file = os.path.join(default_client_out, "microRTPS_transport.h")
- if os.path.isfile(def_file):
- os.rename(def_file, def_file.replace(".h", ".h_"))
-
- px_generate_uorb_topic_files.generate_uRTPS_general(classifier.msgs_to_send, classifier.alias_msgs_to_send, classifier.msgs_to_receive, classifier.alias_msgs_to_receive, msg_dir,
- out_dir, uorb_templates_dir, package, px_generate_uorb_topic_files.INCL_DEFAULT, classifier.msg_list, fastrtps_version, ros2_distro, uRTPS_CLIENT_TEMPL_FILE)
-
- # Final steps to install client
- cp_wildcard(os.path.join(urtps_templates_dir,
- "microRTPS_transport.*"), out_dir)
-
- return 0
-
-
-if agent:
- generate_agent(agent_out_dir)
- print(("\nAgent created in: " + agent_out_dir))
-
-if client:
- generate_client(client_out_dir)
- print(("\nClient created in: " + client_out_dir))
diff --git a/msg/tools/generate_msg_docs.py b/msg/tools/generate_msg_docs.py
index c3f542a8e6..3daa9249b8 100755
--- a/msg/tools/generate_msg_docs.py
+++ b/msg/tools/generate_msg_docs.py
@@ -66,7 +66,7 @@ if __name__ == "__main__":
with open(msg_filename, 'r') as source_file:
msg_contents = source_file.read()
- #Format markdown using msg name, comment, url, contents.
+ #Format markdown using msg name, comment, url, contents.
markdown_output="""# %s (UORB message)
%s
@@ -93,9 +93,6 @@ if __name__ == "__main__":
This list is [auto-generated](https://github.com/PX4/PX4-Autopilot/blob/master/msg/tools/generate_msg_docs.py) from the source code.
:::
-This topic lists the UORB messages available in PX4 (some of which may be may be shared by the [PX4-ROS 2 Bridge](../ros/ros2_comm.md)).
-Graphs showing how these are used [can be found here](../middleware/uorb_graph.md).
-
%s
""" % (filelist_in_markdown)
readme_file = os.path.join(output_dir, 'README.md')
diff --git a/msg/tools/px_generate_uorb_topic_files.py b/msg/tools/px_generate_uorb_topic_files.py
index 1872539fac..96a3a46fdb 100755
--- a/msg/tools/px_generate_uorb_topic_files.py
+++ b/msg/tools/px_generate_uorb_topic_files.py
@@ -34,7 +34,7 @@
"""
px_generate_uorb_topic_files.py
-Generates c/cpp header/source files for uorb topics from .msg (ROS syntax)
+Generates c/cpp header/source files for uorb topics from .msg
message files
"""
@@ -42,6 +42,7 @@ import os
import shutil
import filecmp
import argparse
+import re
import sys
try:
@@ -76,93 +77,54 @@ except ImportError as e:
__author__ = "Sergey Belash, Thomas Gubler, Beat Kueng"
-__copyright__ = "Copyright (C) 2013-2016 PX4 Development Team."
+__copyright__ = "Copyright (C) 2013-2021 PX4 Development Team."
__license__ = "BSD"
__email__ = "thomasgubler@gmail.com"
-TEMPLATE_FILE = ['msg.h.em', 'msg.cpp.em']
-TOPICS_LIST_TEMPLATE_FILE = ['uORBTopics.hpp.em', 'uORBTopics.cpp.em']
-OUTPUT_FILE_EXT = ['.h', '.cpp']
+TEMPLATE_FILE = ['msg.h.em']
+OUTPUT_FILE_EXT = ['.h']
INCL_DEFAULT = ['std_msgs:./msg/std_msgs']
PACKAGE = 'px4'
-TOPICS_TOKEN = '# TOPICS '
-IDL_TEMPLATE_FILE = 'msg.idl.em'
-
CONSTRAINED_FLASH = False
-
class MsgScope:
NONE = 0
SEND = 1
RECEIVE = 2
-
-def get_multi_topics(filename):
- """
- Get TOPICS names from a "# TOPICS" line
- """
- ofile = open(filename, 'r')
- text = ofile.read()
- result = []
- for each_line in text.split('\n'):
- if each_line.startswith(TOPICS_TOKEN):
- topic_names_str = each_line.strip()
- topic_names_str = topic_names_str.replace(TOPICS_TOKEN, "")
- result.extend(topic_names_str.split(" "))
- ofile.close()
- return result
-
-
-def get_msgs_list(msgdir):
- """
- Makes list of msg files in the given directory
- """
- return [fn for fn in os.listdir(msgdir) if fn.endswith(".msg")]
-
-
-def generate_output_from_file(format_idx, filename, outputdir, package, templatedir, includepath):
+def generate_output_from_file(filename, outputdir, package, templatedir, includepath):
"""
Converts a single .msg file to an uorb header/source file
"""
msg_context = genmsg.msg_loader.MsgContext.create_default()
- full_type_name = genmsg.gentools.compute_full_type_name(
- package, os.path.basename(filename))
- spec = genmsg.msg_loader.load_msg_from_file(
- msg_context, filename, full_type_name)
+ full_type_name = genmsg.gentools.compute_full_type_name(package, os.path.basename(filename))
+
+ file_base_name = os.path.basename(filename).replace(".msg", "")
+
+ full_type_name_snake = re.sub(r'(? maxinputtime:
- maxinputtime = it
-
- # Find the most recent modification time in output dir
- maxouttime = 0
- if os.path.isdir(outputdir):
- for f in os.listdir(outputdir):
- fni = os.path.join(outputdir, f)
- if os.path.isfile(fni):
- it = os.path.getmtime(fni)
- if it > maxouttime:
- maxouttime = it
-
- # Do not generate if nothing changed on the input
- if (maxinputtime != 0 and maxouttime != 0 and maxinputtime < maxouttime):
- return False
-
- includepath = INCL_DEFAULT + [':'.join([package, inputdir])]
- for f in os.listdir(inputdir):
- # Ignore hidden files
- if f.startswith("."):
- continue
-
- fn = os.path.join(inputdir, f)
- # Only look at actual files
- if not os.path.isfile(fn):
- continue
-
- if fn[-4:].lower() != '.msg':
- continue
-
- generate_output_from_file(
- format_idx, fn, outputdir, package, templatedir, includepath)
- return True
-
-
-def copy_changed(inputdir, outputdir, prefix='', quiet=False):
- """
- Copies files from inputdir to outputdir if they don't exist in
- ouputdir or if their content changed
- """
-
- # Make sure output directory exists:
- if not os.path.isdir(outputdir):
- os.makedirs(outputdir)
-
- for input_file in os.listdir(inputdir):
- fni = os.path.join(inputdir, input_file)
- if os.path.isfile(fni):
- # Check if input_file exists in outpoutdir, copy the file if not
- fno = os.path.join(outputdir, prefix + input_file)
- if not os.path.isfile(fno):
- shutil.copy(fni, fno)
- if not quiet:
- print("{0}: new header file".format(fno))
- continue
-
- if os.path.getmtime(fni) > os.path.getmtime(fno):
- # The file exists in inputdir and outputdir
- # only copy if contents do not match
- if not filecmp.cmp(fni, fno):
- shutil.copy(fni, fno)
- if not quiet:
- print("{0}: updated".format(input_file))
- continue
-
- if not quiet:
- print("{0}: unchanged".format(input_file))
-
-
-def convert_dir_save(format_idx, inputdir, outputdir, package, templatedir, temporarydir, prefix, quiet=False):
- """
- Converts all .msg files in inputdir to uORB header files
- Unchanged existing files are not overwritten.
- """
- # Create new headers in temporary output directory
- convert_dir(format_idx, inputdir, temporarydir, package, templatedir)
- if generate_idx == 1:
- generate_topics_list_file(inputdir, temporarydir, TOPICS_LIST_TEMPLATE_FILE[1], templatedir)
- # Copy changed headers from temporary dir to output dir
- copy_changed(temporarydir, outputdir, prefix, quiet)
-
-
-def generate_topics_list_file(msgdir, outputdir, template_filename, templatedir):
- # generate cpp file with topics list
- msgs = get_msgs_list(msgdir)
- multi_topics = []
- for msg in msgs:
- msg_filename = os.path.join(msgdir, msg)
- multi_topics.extend(get_multi_topics(msg_filename))
- tl_globals = {"msgs": msgs, "multi_topics": multi_topics}
- tl_template_file = os.path.join(templatedir, template_filename)
- tl_out_file = os.path.join(outputdir, template_filename.replace(".em", ""))
- generate_by_template(tl_out_file, tl_template_file, tl_globals)
-
-
-def generate_topics_list_file_from_files(files, outputdir, template_filename, templatedir):
- # generate cpp file with topics list
- filenames = [os.path.basename(
- p) for p in files if os.path.basename(p).endswith(".msg")]
- multi_topics = []
- for msg_filename in files:
- multi_topics.extend(get_multi_topics(msg_filename))
- tl_globals = {"msgs": filenames, "multi_topics": multi_topics}
- tl_template_file = os.path.join(templatedir, template_filename)
- tl_out_file = os.path.join(outputdir, template_filename.replace(".em", ""))
- generate_by_template(tl_out_file, tl_template_file, tl_globals)
-
-
def append_to_include_path(path_to_append, curr_include, package):
for p in path_to_append:
curr_include.append('%s:%s' % (package, p))
if __name__ == "__main__":
- parser = argparse.ArgumentParser(
- description='Convert msg files to uorb headers/sources')
- parser.add_argument('--headers', help='Generate header files',
- action='store_true')
- parser.add_argument('--sources', help='Generate source files',
- action='store_true')
- parser.add_argument('-d', dest='dir', help='directory with msg files')
+ parser = argparse.ArgumentParser(description='Convert msg files to uorb headers')
parser.add_argument('-f', dest='file',
help="files to convert (use only without -d)",
nargs="+")
@@ -500,14 +253,9 @@ if __name__ == "__main__":
help='package name')
parser.add_argument('-o', dest='outputdir',
help='output directory for header files')
- parser.add_argument('-t', dest='temporarydir',
- help='temporary directory')
parser.add_argument('-p', dest='prefix', default='',
help='string added as prefix to the output file '
' name when converting directories')
- parser.add_argument('-q', dest='quiet', default=False, action='store_true',
- help='string added as prefix to the output file '
- ' name when converting directories')
parser.add_argument('--constrained-flash', dest='constrained_flash', default=False, action='store_true',
help='set to save flash space')
args = parser.parse_args()
@@ -517,27 +265,6 @@ if __name__ == "__main__":
CONSTRAINED_FLASH = args.constrained_flash
- if args.headers:
- generate_idx = 0
- elif args.sources:
- generate_idx = 1
- else:
- print('Error: either --headers or --sources must be specified')
- exit(-1)
if args.file is not None:
for f in args.file:
- generate_output_from_file(
- generate_idx, f, args.temporarydir, args.package, args.templatedir, INCL_DEFAULT)
-
- generate_topics_list_file_from_files(args.file, args.outputdir, TOPICS_LIST_TEMPLATE_FILE[generate_idx], args.templatedir)
- copy_changed(args.temporarydir, args.outputdir, args.prefix, args.quiet)
- elif args.dir is not None:
- convert_dir_save(
- generate_idx,
- args.dir,
- args.outputdir,
- args.package,
- args.templatedir,
- args.temporarydir,
- args.prefix,
- args.quiet)
+ generate_output_from_file(f, args.outputdir, args.package, args.templatedir, INCL_DEFAULT)
diff --git a/msg/tools/px_generate_uorb_topic_helper.py b/msg/tools/px_generate_uorb_topic_helper.py
index 1f90a01ddf..d2508cb64f 100644
--- a/msg/tools/px_generate_uorb_topic_helper.py
+++ b/msg/tools/px_generate_uorb_topic_helper.py
@@ -41,6 +41,7 @@ precompiled and thus message generation will be much faster
import os
import errno
+import re
import genmsg.msgs
@@ -257,6 +258,7 @@ def print_field_def(field):
type_prefix = ''
if (sl_pos >= 0):
type_name = type_name[sl_pos + 1:]
+ type_name = re.sub(r'(? None:
- self.msg_folder = msg_folder
- self.msg_map = self.parse_yaml_msgs_file(yaml_file)
-
- # Check if base types are defined correctly
- self.check_base_type()
-
- # Get messages to send and to receive
- self.msgs_to_send: Dict[str, int] = dict()
- self.msgs_to_receive: Dict[str, int] = dict()
- self.alias_msgs_to_send: List[Tuple[str, str]] = []
- self.alias_msgs_to_receive: List[Tuple[str, str]] = []
- self.msg_list: List[str] = []
-
- # Create message map
- self.setup_msg_map()
-
- self.msg_files_send = self.set_msg_files_send()
- self.msg_files_receive = self.set_msg_files_receive()
-
- def setup_msg_map(self) -> None:
- """Setup dictionary with an ID map for the messages."""
- for topic in self.msg_map['rtps']:
- if 'send' in list(topic.keys()):
- if 'base' in list(topic.keys()):
- self.alias_msgs_to_send.append(
- (topic['msg'], topic['base']))
- else:
- self.msgs_to_send.update({topic['msg']: 0})
- if 'receive' in list(topic.keys()):
- if 'base' in list(topic.keys()):
- self.alias_msgs_to_receive.append(
- (topic['msg'], topic['base']))
- else:
- self.msgs_to_receive.update({topic['msg']: 0})
- self.msg_list.append(topic['msg'])
-
- def set_msg_files_send(self) -> list:
- """
- Append the path to the files which messages are marked to
- be sent.
- """
- return [os.path.join(self.msg_folder, msg + ".msg")
- for msg in list(self.msgs_to_send.keys())]
-
- def set_msg_files_receive(self) -> list:
- """
- Append the path to the files which messages are marked to
- be received.
- """
- return [os.path.join(self.msg_folder, msg + ".msg")
- for msg in list(self.msgs_to_receive.keys())]
-
- def check_base_type(self) -> None:
- """Check if alias message has correct base type."""
- registered_alias_msgs = list(
- topic['base'] for topic in self.msg_map['rtps'] if 'base' in list(topic.keys()))
-
- base_types = []
- for topic in self.msg_map['rtps']:
- if 'base' not in list(topic.keys()):
- base_types.append(topic['msg'])
-
- incorrect_base_types = list(
- set(registered_alias_msgs) - set(base_types))
-
- base_types_suggestion = {}
- for incorrect in incorrect_base_types:
- base_types_suggestion.update({incorrect: difflib.get_close_matches(
- incorrect, base_types, n=1, cutoff=0.6)})
-
- if len(base_types_suggestion) > 0:
- raise AssertionError(
- ('\n' + '\n'.join('\t- The multi-topic message base type \'{}\' does not exist.{}'.format(k, (' Did you mean \'' + v[0] + '\'?' if v else '')) for k, v in list(base_types_suggestion.items()))))
-
- @staticmethod
- def parse_yaml_msgs_file(yaml_file) -> dict:
- """Parses a yaml file into a dict."""
- try:
- with open(yaml_file, 'r') as file:
- return yaml.safe_load(file)
- except OSError as err:
- if err.errno == errno.ENOENT:
- raise IOError(errno.ENOENT, os.strerror(
- errno.ENOENT), yaml_file)
- raise
-
-
-if __name__ == "__main__":
- parser = argparse.ArgumentParser()
-
- parser.add_argument("-s", "--send", dest='send',
- action="store_true", help="Get topics to be sent")
- parser.add_argument("-a", "--alias", dest='alias',
- action="store_true", help="Get alias topics")
- parser.add_argument("-r", "--receive", dest='receive',
- action="store_true", help="Get topics to be received")
- parser.add_argument("-i", "--ignore", dest='ignore',
- action="store_true", help="Get topics to be ignored")
- parser.add_argument("-p", "--path", dest='path',
- action="store_true", help="Get msgs and its paths")
- parser.add_argument("-m", "--topic-msg-dir", dest='msgdir', type=str,
- help="Topics message dir, by default msg/", default="msg")
- parser.add_argument("-y", "--rtps-ids-file", dest='yaml_file', type=str,
- help="RTPS msg IDs definition file absolute path, by default use relative path to msg, tools/urtps_bridge_topics.yaml",
- default='tools/urtps_bridge_topics.yaml')
-
- # Parse arguments
- args = parser.parse_args()
-
- msg_dir = args.msgdir
- if args.msgdir == 'msg':
- msg_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
- else:
- msg_dir = os.path.abspath(args.msgdir)
- classifier = (Classifier(os.path.abspath(args.yaml_file), msg_dir) if os.path.isabs(args.yaml_file)
- else Classifier(os.path.join(msg_dir, args.yaml_file), msg_dir))
-
- if args.send:
- if args.path:
- print(('send files: ' + ', '.join(str(msg_file)
- for msg_file in classifier.msg_files_send) + '\n'))
- else:
- if args.alias:
- print((', '.join(str(msg)
- for msg in sorted(classifier.msgs_to_send)) + (' alias ' + ', '.join(msg[0]
- for msg in classifier.alias_msgs_to_send) if len(classifier.alias_msgs_to_send) > 0 else '') + '\n'))
- else:
- print((', '.join(str(msg)
- for msg in sorted(classifier.msgs_to_send))))
- if args.receive:
- if args.path:
- print(('receive files: ' + ', '.join(str(msg_file)
- for msg_file in classifier.msg_files_receive) + '\n'))
- else:
- if args.alias:
- print((', '.join(str(msg)
- for msg in sorted(classifier.msgs_to_receive)) + (' alias ' + ', '.join(msg[0]
- for msg in classifier.alias_msgs_to_receive) if len(classifier.alias_msgs_to_receive) > 0 else '') + '\n'))
- else:
- print((', '.join(str(msg)
- for msg in sorted(classifier.msgs_to_receive))))
diff --git a/msg/tools/uorb_to_ros_msgs.py b/msg/tools/uorb_to_ros_msgs.py
deleted file mode 100755
index a0d2aa9fb3..0000000000
--- a/msg/tools/uorb_to_ros_msgs.py
+++ /dev/null
@@ -1,127 +0,0 @@
-#!/usr/bin/env python3
-"""
-Script to parse uORB message format to ROS msg format
-Adapted from https://github.com/eProsima/px4_to_ros/blob/master/px4_to_ros2_PoC/px4_msgs/scripts/copy_and_rename.py
-"""
-
-import os
-import re
-import sys
-from shutil import copyfile
-
-__author__ = 'PX4 Development Team'
-__copyright__ = \
- '''
- '
- ' Copyright (c) 2018 PX4 Development Team. All rights reserved.
- '
- ' Redistribution and use in source and binary forms, or without
- ' modification, permitted provided that the following conditions
- ' are met:
- '
- ' 1. Redistributions of source code must retain the above copyright
- ' notice, list of conditions and the following disclaimer.
- ' 2. Redistributions in binary form must reproduce the above copyright
- ' notice, 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 self 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, NOT
- ' LIMITED TO, 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, CONSEQUENTIAL DAMAGES (INCLUDING,
- ' BUT NOT LIMITED TO, OF SUBSTITUTE GOODS OR SERVICES; LOSS
- ' OF USE, DATA, PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- ' AND ON ANY THEORY OF LIABILITY, IN CONTRACT, STRICT
- ' LIABILITY, TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ' ANY WAY OUT OF THE USE OF THIS SOFTWARE, IF ADVISED OF THE
- ' POSSIBILITY OF SUCH DAMAGE.
- '
- '''
-__credits__ = ['Nuno Marques ']
-__license__ = 'BSD-3-Clause'
-__version__ = '0.1.0'
-__maintainer__ = 'Nuno Marques'
-__email__ = 'nuno.marques@dronesolution.io'
-__status__ = 'Development'
-
-input_dir = sys.argv[1]
-output_dir = sys.argv[2]
-
-
-def main():
- print("----------------------- \033[1mmicroRTPS bridge uORB to ROS messages\033[0m -----------------------")
- print("-------------------------------------------------------------------------------------------------------")
-
- if not os.path.exists(os.path.abspath(output_dir)):
- os.mkdir(os.path.abspath(output_dir))
- else:
- ros_msg_dir = os.path.abspath(output_dir)
- msg_files = os.listdir(ros_msg_dir)
- for msg in msg_files:
- if msg.endswith(".msg"):
- os.remove(os.path.join(ros_msg_dir, msg))
-
- msg_list = list()
-
- for filename in os.listdir(input_dir):
- if '.msg' in filename:
- msg_list.append(filename.rstrip('.msg'))
- input_file = input_dir + filename
-
- output_file = output_dir + \
- filename.partition(".")[0].title().replace('_', '') + ".msg"
- copyfile(input_file, output_file)
-
- for filename in os.listdir(output_dir):
- if '.msg' in filename:
- input_file = output_dir + filename
-
- fileUpdated = False
-
- with open(input_file, 'r') as f:
- lines = f.readlines()
- newlines = []
- alias_msgs = []
- alias_msg_files = []
-
- for line in lines:
- for msg_type in msg_list:
- if ('px4/' + msg_type + ' ') in line:
- fileUpdated = True
- line = line.replace(('px4/' + msg_type),
- msg_type.partition(".")[0].title().replace('_', ''))
-
- if re.findall('^' + msg_type + '[\s\[]', line.partition('#')[0]):
- fileUpdated = True
- line = line.replace(msg_type,
- msg_type.partition(".")[0].title().replace('_', ''))
- if '# TOPICS' in line:
- fileUpdated = True
- alias_msgs += line.split()
- alias_msgs.remove('#')
- alias_msgs.remove('TOPICS')
- line = line.replace(line, '')
- newlines.append(line)
-
- for msg_file in alias_msgs:
- with open(output_dir + msg_file.partition(".")[0].title().replace('_', '') + ".msg", 'w+') as f:
- for line in newlines:
- f.write(line)
-
- if fileUpdated:
- with open(input_file, 'w+') as f:
- for line in newlines:
- f.write(line)
-
- print("--\t\t- Generated {} ROS message files in '{}'".format(len(os.listdir(output_dir)), os.path.abspath(output_dir)))
- print("-------------------------------------------------------------------------------------------------------")
-
-
-if __name__ == '__main__':
- main()
diff --git a/msg/tools/uorb_to_ros_urtps_topics.py b/msg/tools/uorb_to_ros_urtps_topics.py
deleted file mode 100755
index 8ff5f0e59d..0000000000
--- a/msg/tools/uorb_to_ros_urtps_topics.py
+++ /dev/null
@@ -1,160 +0,0 @@
-#!/usr/bin/env python3
-"""
-Script to read an yaml file containing the microRTPS topics and update the naming convention to PascalCase
-"""
-
-import argparse
-import errno
-from pathlib import Path
-import os
-import six
-import yaml
-
-__author__ = 'PX4 Development Team'
-__copyright__ = \
- '''
- '
- ' Copyright (c) 2018-2021 PX4 Development Team. All rights reserved.
- '
- ' Redistribution and use in source and binary forms, or without
- ' modification, permitted provided that the following conditions
- ' are met:
- '
- ' 1. Redistributions of source code must retain the above copyright
- ' notice, list of conditions and the following disclaimer.
- ' 2. Redistributions in binary form must reproduce the above copyright
- ' notice, 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 self 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, NOT
- ' LIMITED TO, 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, CONSEQUENTIAL DAMAGES (INCLUDING,
- ' BUT NOT LIMITED TO, OF SUBSTITUTE GOODS OR SERVICES; LOSS
- ' OF USE, DATA, PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
- ' AND ON ANY THEORY OF LIABILITY, IN CONTRACT, STRICT
- ' LIABILITY, TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
- ' ANY WAY OUT OF THE USE OF THIS SOFTWARE, IF ADVISED OF THE
- ' POSSIBILITY OF SUCH DAMAGE.
- '
- '''
-__credits__ = ['Nuno Marques ']
-__license__ = 'BSD-3-Clause'
-__version__ = '0.1.0'
-__maintainer__ = 'Nuno Marques'
-__email__ = 'nuno.marques@dronesolution.io'
-__status__ = 'Development'
-
-verbose = False
-
-
-class IndenterDumper(yaml.Dumper):
- """ Custom dumper for yaml files that apply the correct indentation """
-
- def increase_indent(self, flow=False, indentless=False):
- return super(IndenterDumper, self).increase_indent(flow, False)
-
-
-def load_yaml_file(file):
- """
- Open yaml file and parse the data into a list of dict
-
- :param file: the yaml file to load
- :returns: the list of dictionaries that represent the topics to send and receive
- :raises IOError: raises and error when the file is not found
- """
- try:
- with open(file, 'r') as f:
- if verbose:
- print(("--\t\t- '%s' file loaded" % file))
- return yaml.safe_load(f)
- except OSError as e:
- if e.errno == errno.ENOENT:
- raise IOError(errno.ENOENT, os.strerror(errno.ENOENT), file)
- else:
- raise
-
-
-def update_dict(list):
- """
- Update the message naming on the dictionary to fit the PascalCase convention
-
- :param file: the list of dicts to be updated
- """
- if verbose:
- num_of_msgs = 0
- for i, dictionary in enumerate(list["rtps"]):
- list["rtps"][i] = {k: v.title().replace('_', '') if isinstance(
- v, six.string_types) else v for k, v in six.iteritems(dictionary)}
- if verbose:
- num_of_msgs += 1
- if verbose:
- print(("--\t\t- %d ROS message file names updated" % num_of_msgs))
-
-
-def update_yaml_file(list, in_file, out_file):
- """
- Open the yaml file to dump the new list of dict toself.
-
- :param list: the list of updated dicts
- :param file: the yaml file to load and write the new data
- :raises IOError: raises and error when the file is not found
- """
- try:
- with open(out_file, 'w') as f:
- f.write("# AUTOGENERATED-FILE! DO NOT MODIFY IT DIRECTLY.\n#"
- " Edit instead the same file under PX4-Autopilot/msg/tools and"
- " use the \n# PX4-Autopilot/msg/tools/uorb_to_ros_urtps_topics.py"
- " to regenerate this file.\n")
- yaml.dump(list, f, Dumper=IndenterDumper, default_flow_style=False)
- if verbose:
- if in_file == out_file:
- print(("--\t\t- '%s' updated" % in_file))
- else:
- print(("--\t\t- '%s' created" % out_file))
-
- except OSError as err:
- if err.errno == errno.ENOENT:
- raise IOError(errno.ENOENT, os.strerror(errno.ENOENT), out_file)
- raise
-
-
-def main():
- parser = argparse.ArgumentParser(
- description='Read an yaml file containing the microRTPS topics and update the naming convention to PascalCase')
- optional = parser._action_groups.pop()
- required = parser.add_argument_group('Required')
- required.add_argument("-i", "--input-file", dest="input_file",
- help="Yaml file to read", metavar="INFILE")
- optional.add_argument("-o", "--output-file", dest="output_file",
- help="Yaml file to dump. If not set, it is the same as the input",
- metavar="OUTFILE", default="")
- optional.add_argument("-q", "--quiet", action="store_false", dest="verbose",
- default=True, help="Don't print status messages to stdout")
-
- args = parser.parse_args()
- global verbose
- verbose = args.verbose
- in_file = Path(args.input_file)
- out_file = Path(args.output_file) if (
- Path(args.output_file) != in_file and Path(args.output_file) != "") else in_file
-
- if verbose:
- print("---------------------- \033[1mmicroRTPS bridge yaml PX4 to ROS topics\033[0m ----------------------")
- print("-------------------------------------------------------------------------------------------------------")
-
- list = load_yaml_file(in_file)
- update_dict(list)
- update_yaml_file(list, in_file, out_file)
- if verbose:
- print("-------------------------------------------------------------------------------------------------------")
-
-
-if __name__ == "__main__":
- main()
diff --git a/msg/tools/urtps_bridge_topics.yaml b/msg/tools/urtps_bridge_topics.yaml
deleted file mode 100644
index 1cc21f7478..0000000000
--- a/msg/tools/urtps_bridge_topics.yaml
+++ /dev/null
@@ -1,91 +0,0 @@
-#####
-#
-# This file maps all the topics that are to be used on the microRTPS bridge.
-# When one wants to add a new topic to the bridge, it should add it to this file
-# and mark it to be sent or received from the link.
-# For alias/multi-topic messages (i.e. the ones found on the '#TOPICS' of the
-# uORB messages), these can be also added, requiring an extra entry ('base') to
-# define the base message.
-#
-# IMPORTANT NOTICE: The IDs of the messages sent on the bridge get generated
-# according to the order of the messages in this file. To keep consistency and
-# backwards compatibility, it is recommended that any new message that one wants
-# to be streamed in the bridge gets added to the end of the list. Any changes
-# in the middle of the list (additions, removals, replacements) will change also
-# the current message IDS, which might result with incompatibilities with
-# previous PX4 versions (where the list with this format got introduced or
-# subsisted).
-#
-# Any updates to this file should be mirrored in both sides of the bridge (i.e.,
-# PX4 and px4_ros_com), when using it with ROS2. That can be easily done using
-# the 'msg/tools/uorb_to_ros_urtps_topics.py' script to regenerate this same
-# file under 'px4_ros_com/templates/''. The same is not applicable/required if
-# using this bridge with "raw" RTPS/DDS applications, since the microRTPS agent
-# to be used and stored in 'build//src/modules/micrortps_bridge/''
-# gets generated using this same list.
-#
-#####
-rtps:
- # topic ID 1
- - msg: debug_array
- receive: true
- # topic ID 2
- - msg: debug_key_value
- receive: true
- # topic ID 3
- - msg: debug_value
- receive: true
- # ...
- - msg: debug_vect
- receive: true
- - msg: offboard_control_mode
- receive: true
- - msg: optical_flow
- receive: true
- - msg: position_setpoint
- receive: true
- - msg: position_setpoint_triplet
- receive: true
- - msg: telemetry_status
- receive: true
- - msg: timesync
- receive: true
- send: true
- - msg: trajectory_waypoint
- send: true
- - msg: vehicle_command
- receive: true
- - msg: vehicle_control_mode
- send: true
- - msg: vehicle_local_position_setpoint
- receive: true
- - msg: trajectory_setpoint # multi-topic / alias of vehicle_local_position_setpoint
- base: vehicle_local_position_setpoint
- receive: true
- - msg: vehicle_odometry
- send: true
- - msg: vehicle_mocap_odometry # multi-topic / alias of vehicle_odometry
- base: vehicle_odometry
- receive: true
- - msg: vehicle_visual_odometry # multi-topic / alias of vehicle_odometry
- base: vehicle_odometry
- receive: true
- - msg: vehicle_status
- send: true
- - msg: vehicle_trajectory_waypoint
- receive: true
- - msg: vehicle_trajectory_waypoint_desired # multi-topic / alias of vehicle_trajectory_waypoint
- base: vehicle_trajectory_waypoint
- send: true
- - msg: collision_constraints
- send: true
- - msg: onboard_computer_status
- receive: true
- - msg: trajectory_bezier
- receive: true
- - msg: vehicle_trajectory_bezier
- receive: true
- - msg: timesync_status
- send: true
- - msg: sensor_combined
- send: true
diff --git a/package.xml b/package.xml
index d2eb83f934..7decc69d7a 100644
--- a/package.xml
+++ b/package.xml
@@ -1,66 +1,27 @@
-
+
+
px4
- 1.0.0
- The PX4 Flight Stack package
+ 1.13.0
+ PX4 Autopilot
+ dagar
+ BSD 3
-
-
-
- Lorenz Meier
+ rosidl_default_generators
+ ament_cmake
-
-
-
- BSD
+ rclcpp
+ std_msgs
+ rosidl_default_runtime
-
-
-
- http://px4.io/ros
+ rosidl_interface_packages
+ ament_lint_auto
+ ament_lint_common
-
-
-
-
-
-
-
-
-
-
- message_generation
-
-
-
- message_runtime
-
-
- catkin
- roscpp
- rospy
- std_msgs
- libmavconn
- tf
- rostest
- mav_msgs
- roscpp
- rospy
- std_msgs
- libmavconn
- tf
- mav_msgs
-
-
-
-
-
-
-
-
+ ament_cmake
diff --git a/platforms/common/CMakeLists.txt b/platforms/common/CMakeLists.txt
index 120a59fdfe..167ee4bdf3 100644
--- a/platforms/common/CMakeLists.txt
+++ b/platforms/common/CMakeLists.txt
@@ -35,13 +35,13 @@ set(SRCS)
if(NOT "${PX4_BOARD}" MATCHES "io-v2" AND NOT "${PX4_BOARD_LABEL}" MATCHES "bootloader")
list(APPEND SRCS
+ events.cpp
px4_log.cpp
)
endif()
-add_library(px4_platform
+add_library(px4_platform STATIC
board_identity.c
- events.cpp
external_reset_lockout.cpp
i2c.cpp
i2c_spi_buses.cpp
@@ -54,7 +54,7 @@ add_library(px4_platform
)
target_link_libraries(px4_platform prebuild_targets px4_work_queue)
-if (NOT "${PX4_BOARD}" MATCHES "io-v2")
+if(NOT "${PX4_BOARD}" MATCHES "io-v2")
add_subdirectory(uORB)
endif()
diff --git a/platforms/common/include/px4_platform_common/Node.hpp b/platforms/common/include/px4_platform_common/Node.hpp
new file mode 100644
index 0000000000..53af88d21e
--- /dev/null
+++ b/platforms/common/include/px4_platform_common/Node.hpp
@@ -0,0 +1,47 @@
+
+#pragma once
+
+namespace px4
+{
+
+class Node
+{
+public:
+ explicit Node(const char *node_name) :
+ _name(node_name)
+ {
+
+ }
+
+ ~Node() override = default;
+
+
+ const char *get_name() const { return _name; }
+
+ // bool get_parameter()
+
+
+private:
+
+
+ const char *_name{nullptr};
+
+};
+
+};
+
+// int main(int argc, char *argv[])
+// {
+// rclcpp::init(argc, argv);
+// rclcpp::spin(std::make_shared());
+// rclcpp::shutdown();
+// return 0;
+// }
+
+
+// #include "rclcpp_components/register_node_macro.hpp"
+
+// // Register the component with class_loader.
+// // This acts as a sort of entry point, allowing the component to be discoverable when its library
+// // is being loaded into a running process.
+// RCLCPP_COMPONENTS_REGISTER_NODE(composition::Client)
diff --git a/platforms/common/include/px4_platform_common/workqueue.h b/platforms/common/include/px4_platform_common/workqueue.h
index 8b7ee24163..36ab23ed9f 100644
--- a/platforms/common/include/px4_platform_common/workqueue.h
+++ b/platforms/common/include/px4_platform_common/workqueue.h
@@ -43,7 +43,6 @@
#include
#include
-#include
__BEGIN_DECLS
diff --git a/platforms/common/uORB/CMakeLists.txt b/platforms/common/uORB/CMakeLists.txt
index 0f0060836b..d94fe942d8 100644
--- a/platforms/common/uORB/CMakeLists.txt
+++ b/platforms/common/uORB/CMakeLists.txt
@@ -34,8 +34,6 @@
# this includes the generated topics directory
include_directories(${CMAKE_CURRENT_BINARY_DIR})
-set(SRCS)
-
set(SRCS_COMMON
ORBSet.hpp
Publication.hpp
@@ -49,22 +47,22 @@ set(SRCS_COMMON
uORB.h
uORBCommon.hpp
uORBCommunicator.hpp
- uORBManager.hpp
uORBUtils.cpp
uORBUtils.hpp
- uORBDeviceMaster.hpp
- uORBDeviceNode.hpp
- )
+)
set(SRCS_KERNEL
uORBDeviceMaster.cpp
+ uORBDeviceMaster.hpp
uORBDeviceNode.cpp
+ uORBDeviceNode.hpp
uORBManager.cpp
- )
+ uORBManager.hpp
+)
set(SRCS_USER
uORBManagerUsr.cpp
- )
+)
if (NOT DEFINED CONFIG_BUILD_FLAT AND "${PX4_PLATFORM}" MATCHES "nuttx")
# Kernel side library in nuttx kernel/protected build
diff --git a/platforms/common/uORB/Publication.hpp b/platforms/common/uORB/Publication.hpp
index 7547e3b7fa..88a5e0de49 100644
--- a/platforms/common/uORB/Publication.hpp
+++ b/platforms/common/uORB/Publication.hpp
@@ -43,7 +43,7 @@
#include
#include "uORBManager.hpp"
-#include
+#include
namespace uORB
{
diff --git a/platforms/common/uORB/Subscription.hpp b/platforms/common/uORB/Subscription.hpp
index 496b8cf261..5cb0ce63b0 100644
--- a/platforms/common/uORB/Subscription.hpp
+++ b/platforms/common/uORB/Subscription.hpp
@@ -39,7 +39,7 @@
#pragma once
#include
-#include
+#include
#include
#include
@@ -181,6 +181,10 @@ public:
unsigned get_last_generation() const { return _last_generation; }
orb_id_t get_topic() const { return get_orb_meta(_orb_id); }
+ ORB_ID get_topic_enum() const { return _orb_id; }
+
+ size_t get_topic_size() const { return get_orb_meta(_orb_id)->o_size; }
+
protected:
friend class SubscriptionCallback;
diff --git a/platforms/common/uORB/SubscriptionInterval.hpp b/platforms/common/uORB/SubscriptionInterval.hpp
index 31d1b0a7af..ddeda31de4 100644
--- a/platforms/common/uORB/SubscriptionInterval.hpp
+++ b/platforms/common/uORB/SubscriptionInterval.hpp
@@ -140,6 +140,9 @@ public:
unsigned get_last_generation() const { return _subscription.get_last_generation(); }
orb_id_t get_topic() const { return _subscription.get_topic(); }
+ ORB_ID get_topic_enum() const { return _subscription.get_topic_enum(); }
+ size_t get_topic_size() const { return _subscription.get_topic_size(); }
+
/**
* Set the interval in microseconds
* @param interval The interval in microseconds.
diff --git a/platforms/common/uORB/uORB.h b/platforms/common/uORB/uORB.h
index c96f3c08d4..702e3ebd42 100644
--- a/platforms/common/uORB/uORB.h
+++ b/platforms/common/uORB/uORB.h
@@ -1,6 +1,6 @@
/****************************************************************************
*
- * Copyright (c) 2012-2015 PX4 Development Team. All rights reserved.
+ * Copyright (c) 2012-2021 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
@@ -251,10 +251,16 @@ void orb_print_message_internal(const struct orb_metadata *meta, const void *dat
__END_DECLS
/* Diverse uORB header defines */ //XXX: move to better location
-#define ORB_ID_VEHICLE_ATTITUDE_CONTROLS ORB_ID(actuator_controls_0)
typedef uint8_t arming_state_t;
typedef uint8_t main_state_t;
typedef uint8_t hil_state_t;
typedef uint8_t navigation_state_t;
typedef uint8_t switch_pos_t;
+
+
+#ifdef __cplusplus
+
+#include
+
+#endif // __cplusplus
diff --git a/platforms/common/uORB/uORBCommunicator.hpp b/platforms/common/uORB/uORBCommunicator.hpp
index cbb996b82b..80ccb2d1ab 100644
--- a/platforms/common/uORB/uORBCommunicator.hpp
+++ b/platforms/common/uORB/uORBCommunicator.hpp
@@ -100,8 +100,6 @@ public:
virtual int16_t add_subscription(const char *messageName, int32_t msgRateInHz) = 0;
-
-
/**
* @brief Interface to notify the remote entity of removal of a subscription
*
@@ -116,13 +114,11 @@ public:
virtual int16_t remove_subscription(const char *messageName) = 0;
-
/**
* Register Message Handler. This is internal for the IChannel implementer*
*/
virtual int16_t register_handler(uORBCommunicator::IChannelRxHandler *handler) = 0;
-
//=========================================================================
// INTERFACES FOR Data messages
//=========================================================================
@@ -143,7 +139,6 @@ public:
*/
virtual int16_t send_message(const char *messageName, int32_t length, uint8_t *data) = 0;
-
};
/**
@@ -153,7 +148,6 @@ public:
class uORBCommunicator::IChannelRxHandler
{
public:
-
/**
* Interface to process a received topic from remote.
* @param topic_name
@@ -184,7 +178,6 @@ public:
virtual int16_t process_add_subscription(const char *messageName, int32_t msgRateInHz) = 0;
-
/**
* Interface to process a received control msg to remove subscription
* @param messageName
@@ -198,7 +191,6 @@ public:
virtual int16_t process_remove_subscription(const char *messageName) = 0;
-
/**
* Interface to process the received data message.
* @param messageName
@@ -215,7 +207,6 @@ public:
*/
virtual int16_t process_received_message(const char *messageName, int32_t length, uint8_t *data) = 0;
-
};
#endif /* _uORBCommunicator_hpp_ */
diff --git a/platforms/common/uORB/uORBDeviceMaster.hpp b/platforms/common/uORB/uORBDeviceMaster.hpp
index 94c97e61df..67c0491b3c 100644
--- a/platforms/common/uORB/uORBDeviceMaster.hpp
+++ b/platforms/common/uORB/uORBDeviceMaster.hpp
@@ -36,7 +36,7 @@
#include
#include "uORBCommon.hpp"
-#include
+#include
#include
diff --git a/platforms/common/uORB/uORBManager.hpp b/platforms/common/uORB/uORBManager.hpp
index d5df89605d..92b77d2f91 100644
--- a/platforms/common/uORB/uORBManager.hpp
+++ b/platforms/common/uORB/uORBManager.hpp
@@ -38,7 +38,7 @@
#include "uORBCommon.hpp"
#include "uORBDeviceMaster.hpp"
-#include // For ORB_ID enum
+#include