From 5d0585f35f57e8c23f50bf2af76b8484119389cd Mon Sep 17 00:00:00 2001 From: schmiddey Date: Wed, 30 Aug 2023 19:25:42 +0200 Subject: [PATCH] changed to c++17 and added ns to diff_drive and laser plugin --- flatland_msgs/CMakeLists.txt | 2 +- flatland_plugins/CMakeLists.txt | 8 ++++---- flatland_plugins/src/diff_drive.cpp | 8 ++++++++ flatland_plugins/src/laser.cpp | 4 ++++ flatland_server/CMakeLists.txt | 8 ++++---- flatland_viz/CMakeLists.txt | 2 +- 6 files changed, 22 insertions(+), 10 deletions(-) diff --git a/flatland_msgs/CMakeLists.txt b/flatland_msgs/CMakeLists.txt index c80ce9b4..b87c6ba1 100644 --- a/flatland_msgs/CMakeLists.txt +++ b/flatland_msgs/CMakeLists.txt @@ -8,7 +8,7 @@ endif() # Default to C++14 if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 14) + set(CMAKE_CXX_STANDARD 17) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") diff --git a/flatland_plugins/CMakeLists.txt b/flatland_plugins/CMakeLists.txt index e3d79242..063cdd9d 100644 --- a/flatland_plugins/CMakeLists.txt +++ b/flatland_plugins/CMakeLists.txt @@ -3,12 +3,12 @@ cmake_minimum_required(VERSION 3.5) project(flatland_plugins) # Default to C++14 -if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 14) -endif() +# if(NOT CMAKE_CXX_STANDARD) +# set(CMAKE_CXX_STANDARD 17) +# endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wextra -Wpedantic) + add_compile_options(-Wall -Wextra -Wpedantic -std=c++17) endif() diff --git a/flatland_plugins/src/diff_drive.cpp b/flatland_plugins/src/diff_drive.cpp index 60880e59..be53b3b4 100644 --- a/flatland_plugins/src/diff_drive.cpp +++ b/flatland_plugins/src/diff_drive.cpp @@ -110,6 +110,14 @@ void DiffDrive::OnInitialize(const YAML::Node & config) throw YAMLException("Body with name " + Q(body_name) + " does not exist"); } + //append namespace to topics + std::string ns = this->GetModel()->GetNameSpace(); + twist_topic = ns + "/" + twist_topic; + odom_topic = ns + "/" + odom_topic; + ground_truth_topic = ns + "/" + ground_truth_topic; + twist_pub_topic = ns + "/" + twist_pub_topic; + + // publish and subscribe to topics using std::placeholders::_1; twist_sub_ = node_->create_subscription( diff --git a/flatland_plugins/src/laser.cpp b/flatland_plugins/src/laser.cpp index f044b006..e93a008e 100644 --- a/flatland_plugins/src/laser.cpp +++ b/flatland_plugins/src/laser.cpp @@ -68,6 +68,10 @@ void Laser::OnInitialize(const YAML::Node & config) ParseParameters(config); update_timer_.SetRate(update_rate_); + + //add namespace + std::string ns = GetModel()->GetName(); + topic_ = ns + "/" + topic_; scan_publisher_ = node_->create_publisher(topic_, 1); // construct the body to laser transformation matrix once since it never diff --git a/flatland_server/CMakeLists.txt b/flatland_server/CMakeLists.txt index 51f0c792..7ee6cbf8 100644 --- a/flatland_server/CMakeLists.txt +++ b/flatland_server/CMakeLists.txt @@ -3,12 +3,12 @@ cmake_minimum_required(VERSION 3.5) project(flatland_server) # Default to C++14 -if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 14) -endif() +# if(NOT CMAKE_CXX_STANDARD) +# set(CMAKE_CXX_STANDARD 17) +# endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") - add_compile_options(-Wall -Wextra -Wpedantic) + add_compile_options(-Wall -Wextra -Wpedantic -std=c++17) endif() ## Find macros and libraries diff --git a/flatland_viz/CMakeLists.txt b/flatland_viz/CMakeLists.txt index 8243d33b..5e7cc787 100644 --- a/flatland_viz/CMakeLists.txt +++ b/flatland_viz/CMakeLists.txt @@ -3,7 +3,7 @@ project(flatland_viz) # Default to C++14 if(NOT CMAKE_CXX_STANDARD) - set(CMAKE_CXX_STANDARD 14) + set(CMAKE_CXX_STANDARD 17) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")