From f3e264874702289f8d835866fed7d420553ce21b Mon Sep 17 00:00:00 2001 From: Mark Charlebois Date: Mon, 31 Jul 2017 14:02:44 -0700 Subject: [PATCH] Use dummy bridge stub if fastrtpsgen not found If the build config specifies RTPS topics to import/export and fastrtpsgen is not installed on the build machine, then a dummy stub is used for the RTPS bridge. Signed-off-by: Mark Charlebois --- cmake/configs/nuttx_px4fmu-v4_default.cmake | 2 - cmake/configs/posix_sitl_default.cmake | 2 - .../micrortps_client/CMakeLists.txt | 25 +++++-- .../microRTPS_client_dummy.cpp | 68 +++++++++++++++++++ 4 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 src/modules/micrortps_bridge/micrortps_client/microRTPS_client_dummy.cpp diff --git a/cmake/configs/nuttx_px4fmu-v4_default.cmake b/cmake/configs/nuttx_px4fmu-v4_default.cmake index 2bf7d52bfd..c3c56a6711 100644 --- a/cmake/configs/nuttx_px4fmu-v4_default.cmake +++ b/cmake/configs/nuttx_px4fmu-v4_default.cmake @@ -207,8 +207,6 @@ set(config_module_list examples/ekf_att_pos_estimator ) -set(GENERATE_RTPS_BRIDGE on) - set(config_rtps_send_topics sensor_combined ) diff --git a/cmake/configs/posix_sitl_default.cmake b/cmake/configs/posix_sitl_default.cmake index 66e7ee796c..ee82489674 100644 --- a/cmake/configs/posix_sitl_default.cmake +++ b/cmake/configs/posix_sitl_default.cmake @@ -184,8 +184,6 @@ set(config_extra_builtin_cmds sercon ) -set(GENERATE_RTPS_BRIDGE on) - set(config_rtps_send_topics sensor_baro ) diff --git a/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt b/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt index 458e42a3c7..1d58287867 100644 --- a/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt +++ b/src/modules/micrortps_bridge/micrortps_client/CMakeLists.txt @@ -31,7 +31,26 @@ # ############################################################################ -if(NOT GENERATE_RTPS_BRIDGE MATCHES "off") +find_program(FASTRTPSGEN fastrtpsgen) +if(NOT FASTRTPSGEN) + message(WARNING "WARNING: Unable to find fastrtpsgen") + set(GENERATE_RTPS_BRIDGE off) +else() + set(GENERATE_RTPS_BRIDGE on) +endif() + +if(GENERATE_RTPS_BRIDGE MATCHES "off") + + message(WARNING "WARNING: Building PX4 without RTPS bridge support") + px4_add_module( + MODULE modules__micrortps_bridge__micrortps_client + MAIN micrortps_client + SRCS + microRTPS_client_dummy.cpp + DEPENDS + platforms__common + ) +else() include_directories(.) include_directories(${CMAKE_CURRENT_BINARY_DIR}) @@ -72,8 +91,6 @@ if(NOT GENERATE_RTPS_BRIDGE MATCHES "off") set(receive_topic_opt "-r") endif() - message("SEND ${send_topic_files_opt}") - message("RECV ${receive_topic_files_opt}") add_custom_command(OUTPUT ${topic_bridge_files_out} COMMAND ${PYTHON_EXECUTABLE} ${PX4_SOURCE_DIR}/Tools/generate_microRTPS_bridge.py @@ -87,7 +104,6 @@ if(NOT GENERATE_RTPS_BRIDGE MATCHES "off") VERBATIM ) endif() -endif() px4_add_module( MODULE modules__micrortps_bridge__micrortps_client @@ -101,4 +117,5 @@ px4_add_module( DEPENDS platforms__common ) +endif() # vim: set noet ft=cmake fenc=utf-8 ff=unix : diff --git a/src/modules/micrortps_bridge/micrortps_client/microRTPS_client_dummy.cpp b/src/modules/micrortps_bridge/micrortps_client/microRTPS_client_dummy.cpp new file mode 100644 index 0000000000..e4362425c2 --- /dev/null +++ b/src/modules/micrortps_bridge/micrortps_client/microRTPS_client_dummy.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** + * + * Copyright 2017 Proyectos y Sistemas de Mantenimiento SL (eProsima). + * + * 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 + +extern "C" __EXPORT int micrortps_client_main(int argc, char *argv[]); + + +static void usage(const char *name) +{ + PX4_INFO("usage: %s start|stop\n\n", name); +} + +int micrortps_client_main(int argc, char *argv[]) +{ + if (argc < 2) + { + usage(argv[0]); + return -1; + } + + if (!strcmp(argv[1], "start")) + { + PX4_WARN("PX4 built without RTPS bridge support, EXITING...\n"); + return -1; + } + + if (!strcmp(argv[1], "stop")) + { + PX4_INFO("Not running"); + return -1; + } + + usage(argv[0]); + + return -1; +}