From 0422848dd6afbc247d10ff6054fc67f42b808763 Mon Sep 17 00:00:00 2001 From: Jilada Eccleston Date: Mon, 14 Dec 2020 14:34:56 +0900 Subject: [PATCH] ROS2 Linting: gnss_poser (#166) * Add linting and fix litner errors * Address PR comment: - Use author name instead of user - Remove ROS2 maintainer (remnants of older porting) --- sensing/preprocessor/gnss/gnss_poser/CMakeLists.txt | 13 ++++++++++--- .../gnss/gnss_poser/include/gnss_poser/convert.hpp | 10 ++++++---- .../include/gnss_poser/gnss_poser_core.hpp | 8 +++++--- .../gnss_poser/include/gnss_poser/gnss_stat.hpp | 6 +++--- sensing/preprocessor/gnss/gnss_poser/package.xml | 5 +++-- .../gnss/gnss_poser/src/gnss_poser_core.cpp | 11 +++++++---- 6 files changed, 34 insertions(+), 19 deletions(-) diff --git a/sensing/preprocessor/gnss/gnss_poser/CMakeLists.txt b/sensing/preprocessor/gnss/gnss_poser/CMakeLists.txt index 4ee7d94b31268..4760eb1b05c7d 100644 --- a/sensing/preprocessor/gnss/gnss_poser/CMakeLists.txt +++ b/sensing/preprocessor/gnss/gnss_poser/CMakeLists.txt @@ -4,6 +4,8 @@ project(gnss_poser) ### Compile options if(NOT CMAKE_CXX_STANDARD) set(CMAKE_CXX_STANDARD 14) + set(CMAKE_CXX_STANDARD_REQUIRED ON) + set(CMAKE_CXX_EXTENSIONS OFF) endif() if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang") add_compile_options(-Wno-unused-parameter -Wall -Wextra -Wpedantic) @@ -16,11 +18,11 @@ set(GNSS_POSER_HEADERS include/gnss_poser/convert.hpp include/gnss_poser/gnss_poser_core.hpp include/gnss_poser/gnss_stat.hpp - ) +) ament_auto_add_library(gnss_poser_node SHARED - src/gnss_poser_core.cpp - ${GNSS_POSER_HEADERS} + src/gnss_poser_core.cpp + ${GNSS_POSER_HEADERS} ) rclcpp_components_register_node(gnss_poser_node @@ -28,6 +30,11 @@ rclcpp_components_register_node(gnss_poser_node EXECUTABLE gnss_poser ) +if(BUILD_TESTING) + find_package(ament_lint_auto REQUIRED) + ament_lint_auto_find_test_dependencies() +endif() + ament_auto_package(INSTALL_TO_SHARE launch ) diff --git a/sensing/preprocessor/gnss/gnss_poser/include/gnss_poser/convert.hpp b/sensing/preprocessor/gnss/gnss_poser/include/gnss_poser/convert.hpp index d1a22dcd28c3b..fd9fa5ae1c100 100644 --- a/sensing/preprocessor/gnss/gnss_poser/include/gnss_poser/convert.hpp +++ b/sensing/preprocessor/gnss/gnss_poser/include/gnss_poser/convert.hpp @@ -11,8 +11,10 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef GNSS_POSER_CONVERT_HPP_ -#define GNSS_POSER_CONVERT_HPP_ +#ifndef GNSS_POSER__CONVERT_HPP_ +#define GNSS_POSER__CONVERT_HPP_ + +#include #include "gnss_poser/gnss_stat.hpp" #include "geo_pos_conv/geo_pos_conv.hpp" @@ -99,7 +101,7 @@ GNSSStat UTM2MGRS( std::pow( 10, static_cast(MGRSPrecision::_1_METER) - static_cast(precision)); // set unit as [m] - mgrs.z = utm.z; // TODO + mgrs.z = utm.z; // TODO(ryo.watanabe) } catch (const GeographicLib::GeographicErr & err) { RCLCPP_ERROR_STREAM(logger, "Failed to convert from UTM to MGRS" << err.what()); } @@ -131,4 +133,4 @@ GNSSStat NavSatFix2PLANE( } } // namespace GNSSPoser -#endif +#endif // GNSS_POSER__CONVERT_HPP_ diff --git a/sensing/preprocessor/gnss/gnss_poser/include/gnss_poser/gnss_poser_core.hpp b/sensing/preprocessor/gnss/gnss_poser/include/gnss_poser/gnss_poser_core.hpp index 0edc69d9782ce..120b3ad0c6631 100644 --- a/sensing/preprocessor/gnss/gnss_poser/include/gnss_poser/gnss_poser_core.hpp +++ b/sensing/preprocessor/gnss/gnss_poser/include/gnss_poser/gnss_poser_core.hpp @@ -11,8 +11,10 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef GNSS_POSER_GNSS_POSER_CORE_HPP_ -#define GNSS_POSER_GNSS_POSER_CORE_HPP_ +#ifndef GNSS_POSER__GNSS_POSER_CORE_HPP_ +#define GNSS_POSER__GNSS_POSER_CORE_HPP_ + +#include #include "gnss_poser/convert.hpp" #include "gnss_poser/gnss_stat.hpp" @@ -89,4 +91,4 @@ class GNSSPoser : public rclcpp::Node }; } // namespace GNSSPoser -#endif +#endif // GNSS_POSER__GNSS_POSER_CORE_HPP_ diff --git a/sensing/preprocessor/gnss/gnss_poser/include/gnss_poser/gnss_stat.hpp b/sensing/preprocessor/gnss/gnss_poser/include/gnss_poser/gnss_stat.hpp index a7ccbcfeec880..bb08a1b6b0c86 100644 --- a/sensing/preprocessor/gnss/gnss_poser/include/gnss_poser/gnss_stat.hpp +++ b/sensing/preprocessor/gnss/gnss_poser/include/gnss_poser/gnss_stat.hpp @@ -11,8 +11,8 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#ifndef GNSS_POSER_GNSS_STAT_HPP_ -#define GNSS_POSER_GNSS_STAT_HPP_ +#ifndef GNSS_POSER__GNSS_STAT_HPP_ +#define GNSS_POSER__GNSS_STAT_HPP_ namespace GNSSPoser { @@ -50,4 +50,4 @@ struct GNSSStat }; } // namespace GNSSPoser -#endif +#endif // GNSS_POSER__GNSS_STAT_HPP_ diff --git a/sensing/preprocessor/gnss/gnss_poser/package.xml b/sensing/preprocessor/gnss/gnss_poser/package.xml index a62075c500a3d..c3d174e888cc6 100644 --- a/sensing/preprocessor/gnss/gnss_poser/package.xml +++ b/sensing/preprocessor/gnss/gnss_poser/package.xml @@ -5,8 +5,6 @@ 1.0.0 The ROS2 gnss_poser package Ryo Watanabe - - Jilada ECCLESTON Apache License 2.0 ament_cmake_auto @@ -24,6 +22,9 @@ rclcpp rclcpp_components + ament_lint_auto + ament_lint_common + ament_cmake diff --git a/sensing/preprocessor/gnss/gnss_poser/src/gnss_poser_core.cpp b/sensing/preprocessor/gnss/gnss_poser/src/gnss_poser_core.cpp index 4e3cae285ed2c..8da2ebf257614 100644 --- a/sensing/preprocessor/gnss/gnss_poser/src/gnss_poser_core.cpp +++ b/sensing/preprocessor/gnss/gnss_poser/src/gnss_poser_core.cpp @@ -11,11 +11,13 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -#include "gnss_poser/gnss_poser_core.hpp" -#include "rclcpp_components/register_node_macro.hpp" #include +#include #include +#include + +#include "gnss_poser/gnss_poser_core.hpp" namespace GNSSPoser { @@ -105,7 +107,7 @@ void GNSSPoser::callbackNavSatFix( // transform pose from gnss_antenna to base_link geometry_msgs::msg::PoseStamped gnss_base_pose_msg; - //remove rotation + // remove rotation tf_base_to_gnss_ptr->transform.rotation.x = 0.0; tf_base_to_gnss_ptr->transform.rotation.y = 0.0; tf_base_to_gnss_ptr->transform.rotation.z = 0.0; @@ -343,6 +345,7 @@ void GNSSPoser::publishTF( tf2_broadcaster_.sendTransform(transform_stamped); } -RCLCPP_COMPONENTS_REGISTER_NODE(GNSSPoser) +#include "rclcpp_components/register_node_macro.hpp" +RCLCPP_COMPONENTS_REGISTER_NODE(GNSSPoser) } // namespace GNSSPoser