Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(glog): add initialization check #6792

Merged
merged 1 commit into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion common/glog_component/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ autoware_package()
ament_auto_add_library(glog_component SHARED
src/glog_component.cpp
)
target_link_libraries(glog_component glog)
target_link_libraries(glog_component glog::glog)

rclcpp_components_register_node(glog_component
PLUGIN "GlogComponent"
Expand Down
2 changes: 1 addition & 1 deletion common/glog_component/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<buildtool_depend>ament_cmake_auto</buildtool_depend>
<buildtool_depend>autoware_cmake</buildtool_depend>

<depend>libgoogle-glog-dev</depend>
<depend>glog</depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>

Expand Down
6 changes: 4 additions & 2 deletions common/glog_component/src/glog_component.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@
GlogComponent::GlogComponent(const rclcpp::NodeOptions & node_options)
: Node("glog_component", node_options)
{
google::InitGoogleLogging("glog_component");
google::InstallFailureSignalHandler();
if (!google::IsGoogleLoggingInitialized()) {
google::InitGoogleLogging("glog_component");
google::InstallFailureSignalHandler();
}
}

#include <rclcpp_components/register_node_macro.hpp>
Expand Down
2 changes: 0 additions & 2 deletions evaluator/perception_online_evaluator/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ autoware_package()

find_package(pluginlib REQUIRED)

find_package(glog REQUIRED)

ament_auto_add_library(${PROJECT_NAME}_node SHARED
src/metrics_calculator.cpp
src/${PROJECT_NAME}_node.cpp
Expand Down
2 changes: 1 addition & 1 deletion evaluator/perception_online_evaluator/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
<depend>diagnostic_msgs</depend>
<depend>eigen</depend>
<depend>geometry_msgs</depend>
<depend>glog</depend>
<depend>lanelet2_extension</depend>
<depend>libgoogle-glog-dev</depend>
<depend>motion_utils</depend>
<depend>nav_msgs</depend>
<depend>object_recognition_utils</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ PerceptionOnlineEvaluatorNode::PerceptionOnlineEvaluatorNode(
{
using std::placeholders::_1;

google::InitGoogleLogging("perception_online_evaluator_node");
google::InstallFailureSignalHandler();
if (!google::IsGoogleLoggingInitialized()) {
google::InitGoogleLogging("perception_online_evaluator_node");
google::InstallFailureSignalHandler();
}

objects_sub_ = create_subscription<PredictedObjects>(
"~/input/objects", 1, std::bind(&PerceptionOnlineEvaluatorNode::onObjects, this, _1));
Expand Down
2 changes: 1 addition & 1 deletion localization/ndt_scan_matcher/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
<depend>diagnostic_msgs</depend>
<depend>fmt</depend>
<depend>geometry_msgs</depend>
<depend>libgoogle-glog-dev</depend>
<depend>glog</depend>
<depend>libpcl-all-dev</depend>
<depend>localization_util</depend>
<depend>nav_msgs</depend>
Expand Down
6 changes: 4 additions & 2 deletions localization/ndt_scan_matcher/src/ndt_scan_matcher_node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@

int main(int argc, char ** argv)
{
google::InitGoogleLogging(argv[0]); // NOLINT
google::InstallFailureSignalHandler();
if (!google::IsGoogleLoggingInitialized()) {
google::InitGoogleLogging(argv[0]); // NOLINT
google::InstallFailureSignalHandler();
}

rclcpp::init(argc, argv);
auto ndt_scan_matcher = std::make_shared<NDTScanMatcher>();
Expand Down
2 changes: 1 addition & 1 deletion localization/pose_estimator_arbiter/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
<depend>autoware_auto_mapping_msgs</depend>
<depend>diagnostic_msgs</depend>
<depend>geometry_msgs</depend>
<depend>glog</depend>
<depend>lanelet2_extension</depend>
<depend>libgoogle-glog-dev</depend>
<depend>magic_enum</depend>
<depend>pcl_conversions</depend>
<depend>pcl_ros</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

int main(int argc, char * argv[])
{
google::InitGoogleLogging(argv[0]);
google::InstallFailureSignalHandler();
if (!google::IsGoogleLoggingInitialized()) {
google::InitGoogleLogging(argv[0]);
google::InstallFailureSignalHandler();
}

rclcpp::init(argc, argv);
auto node = std::make_shared<pose_estimator_arbiter::PoseEstimatorArbiter>();
Expand Down
2 changes: 1 addition & 1 deletion localization/yabloc/yabloc_common/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
<depend>autoware_auto_mapping_msgs</depend>
<depend>cv_bridge</depend>
<depend>geometry_msgs</depend>
<depend>glog</depend>
<depend>lanelet2_core</depend>
<depend>lanelet2_extension</depend>
<depend>libgoogle-glog-dev</depend>
<depend>pcl_conversions</depend>
<depend>rclcpp</depend>
<depend>sensor_msgs</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

int main(int argc, char ** argv)
{
google::InitGoogleLogging(argv[0]);
google::InstallFailureSignalHandler();
if (!google::IsGoogleLoggingInitialized()) {
google::InitGoogleLogging(argv[0]);
google::InstallFailureSignalHandler();
}

rclcpp::init(argc, argv);
rclcpp::spin(std::make_shared<yabloc::ground_server::GroundServer>());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,10 @@

int main(int argc, char * argv[])
{
google::InitGoogleLogging(argv[0]);
google::InstallFailureSignalHandler();
if (!google::IsGoogleLoggingInitialized()) {
google::InitGoogleLogging(argv[0]);
google::InstallFailureSignalHandler();
}

namespace mpf = yabloc::modularized_particle_filter;
rclcpp::init(argc, argv);
Expand Down
2 changes: 1 addition & 1 deletion perception/map_based_prediction/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

<depend>autoware_auto_perception_msgs</depend>
<depend>autoware_perception_msgs</depend>
<depend>glog</depend>
<depend>interpolation</depend>
<depend>lanelet2_extension</depend>
<depend>libgoogle-glog-dev</depend>
<depend>motion_utils</depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2021 Tier IV, Inc.

Check notice on line 1 in perception/map_based_prediction/src/map_based_prediction_node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Lines of Code in a Single File

The lines of code increases from 1771 to 1773, improve code health by reducing it to 1000. The number of Lines of Code in a single file. More Lines of Code lowers the code health.

Check notice on line 1 in perception/map_based_prediction/src/map_based_prediction_node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Overall Code Complexity

The mean cyclomatic complexity increases from 6.52 to 6.54, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -715,8 +715,10 @@
MapBasedPredictionNode::MapBasedPredictionNode(const rclcpp::NodeOptions & node_options)
: Node("map_based_prediction", node_options), debug_accumulated_time_(0.0)
{
google::InitGoogleLogging("map_based_prediction_node");
google::InstallFailureSignalHandler();
if (!google::IsGoogleLoggingInitialized()) {
google::InitGoogleLogging("map_based_prediction_node");
google::InstallFailureSignalHandler();
}

Check warning on line 721 in perception/map_based_prediction/src/map_based_prediction_node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

❌ Getting worse: Large Method

MapBasedPredictionNode::MapBasedPredictionNode increases from 89 to 91 lines of code, threshold = 70. Large functions with many lines of code are generally harder to understand and lower the code health. Avoid adding more lines to this function.
enable_delay_compensation_ = declare_parameter<bool>("enable_delay_compensation");
prediction_time_horizon_ = declare_parameter<double>("prediction_time_horizon");
lateral_control_time_horizon_ =
Expand Down
5 changes: 1 addition & 4 deletions perception/multi_object_tracker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,13 @@ ament_auto_add_library(multi_object_tracker_node SHARED

target_link_libraries(multi_object_tracker_node
Eigen3::Eigen
glog::glog
)

ament_auto_add_executable(${PROJECT_NAME}
src/multi_object_tracker_node.cpp
)

target_link_libraries(${PROJECT_NAME}
multi_object_tracker_node glog
)

ament_auto_package(INSTALL_TO_SHARE
launch
config
Expand Down
2 changes: 1 addition & 1 deletion perception/multi_object_tracker/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
<depend>autoware_auto_perception_msgs</depend>
<depend>diagnostic_updater</depend>
<depend>eigen</depend>
<depend>glog</depend>
<depend>kalman_filter</depend>
<depend>libgoogle-glog-dev</depend>
<depend>mussp</depend>
<depend>object_recognition_utils</depend>
<depend>rclcpp</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@

int main(int argc, char ** argv)
{
google::InitGoogleLogging(argv[0]); // NOLINT
google::InstallFailureSignalHandler();
if (!google::IsGoogleLoggingInitialized()) {
google::InitGoogleLogging(argv[0]); // NOLINT
google::InstallFailureSignalHandler();
}

rclcpp::init(argc, argv);
rclcpp::NodeOptions options;
Expand Down
2 changes: 1 addition & 1 deletion perception/radar_object_tracker/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@

<depend>autoware_auto_perception_msgs</depend>
<depend>eigen</depend>
<depend>glog</depend>
<depend>kalman_filter</depend>
<depend>lanelet2_extension</depend>
<depend>libgoogle-glog-dev</depend>
<depend>mussp</depend>
<depend>nlohmann-json-dev</depend>
<depend>object_recognition_utils</depend>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright 2023 TIER IV, Inc.

Check notice on line 1 in perception/radar_object_tracker/src/radar_object_tracker_node/radar_object_tracker_node.cpp

View check run for this annotation

CodeScene Delta Analysis / CodeScene Cloud Delta Analysis (main)

ℹ Getting worse: Overall Code Complexity

The mean cyclomatic complexity increases from 5.19 to 5.25, threshold = 4. This file has many conditional statements (e.g. if, for, while) across its implementation, leading to lower code health. Avoid adding more conditionals.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -196,8 +196,10 @@
tf_listener_(tf_buffer_)
{
// glog for debug
google::InitGoogleLogging("radar_object_tracker");
google::InstallFailureSignalHandler();
if (!google::IsGoogleLoggingInitialized()) {
google::InitGoogleLogging("radar_object_tracker");
google::InstallFailureSignalHandler();
}

// Create publishers and subscribers
detected_object_sub_ = create_subscription<autoware_auto_perception_msgs::msg::DetectedObjects>(
Expand Down
2 changes: 1 addition & 1 deletion perception/tracking_object_merger/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

<depend>autoware_auto_perception_msgs</depend>
<depend>eigen</depend>
<depend>libgoogle-glog-dev</depend>
<depend>glog</depend>
<depend>mussp</depend>
<depend>object_recognition_utils</depend>
<depend>rclcpp</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,8 +88,10 @@ DecorativeTrackerMergerNode::DecorativeTrackerMergerNode(const rclcpp::NodeOptio
tf_listener_(tf_buffer_)
{
// glog for debug
google::InitGoogleLogging("decorative_object_merger_node");
google::InstallFailureSignalHandler();
if (!google::IsGoogleLoggingInitialized()) {
google::InitGoogleLogging("decorative_object_merger_node");
google::InstallFailureSignalHandler();
}

// Subscriber
sub_main_objects_ = create_subscription<TrackedObjects>(
Expand Down
Loading