Skip to content

Commit

Permalink
feat(localization_error_monitor): componentize LocalizationErrorMonit…
Browse files Browse the repository at this point in the history
…or (#7102)

* remove unusing main func file

Signed-off-by: a-maumau <[email protected]>

* add and mod to use glog

Signed-off-by: a-maumau <[email protected]>

* change name to localization_error_monitor

Signed-off-by: a-maumau <[email protected]>

* style(pre-commit): autofix

* rm dependencies

Signed-off-by: a-maumau <[email protected]>

* change log output from screen to both

Signed-off-by: a-maumau <[email protected]>

---------

Signed-off-by: a-maumau <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
a-maumau and pre-commit-ci[bot] authored May 24, 2024
1 parent 2ac6116 commit 11f010a
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 43 deletions.
17 changes: 9 additions & 8 deletions localization/localization_error_monitor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,34 @@ project(localization_error_monitor)
find_package(autoware_cmake REQUIRED)
autoware_package()

ament_auto_add_library(localization_error_monitor_module SHARED
ament_auto_add_library(${PROJECT_NAME} SHARED
src/diagnostics.cpp
src/localization_error_monitor.cpp
)

ament_auto_add_executable(localization_error_monitor
src/main.cpp
src/node.cpp
rclcpp_components_register_node(${PROJECT_NAME}
PLUGIN "LocalizationErrorMonitor"
EXECUTABLE ${PROJECT_NAME}_node
EXECUTOR SingleThreadedExecutor
)
target_link_libraries(localization_error_monitor localization_error_monitor_module)

if(BUILD_TESTING)
function(add_testcase filepath)
get_filename_component(filename ${filepath} NAME)
string(REGEX REPLACE ".cpp" "" test_name ${filename})
ament_add_gtest(${test_name} ${filepath})
target_include_directories(${test_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
target_link_libraries(${test_name} localization_error_monitor_module)
target_link_libraries(${test_name} ${PROJECT_NAME})
ament_target_dependencies(${test_name} ${${PROJECT_NAME}_FOUND_BUILD_DEPENDS})
endfunction()


find_package(ament_lint_auto REQUIRED)
ament_lint_auto_find_test_dependencies()
add_testcase(test/test_diagnostics.cpp)
endif()

ament_auto_package(INSTALL_TO_SHARE
ament_auto_package(
INSTALL_TO_SHARE
config
launch
)
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#ifndef LOCALIZATION_ERROR_MONITOR__NODE_HPP_
#define LOCALIZATION_ERROR_MONITOR__NODE_HPP_
#ifndef LOCALIZATION_ERROR_MONITOR__LOCALIZATION_ERROR_MONITOR_HPP_
#define LOCALIZATION_ERROR_MONITOR__LOCALIZATION_ERROR_MONITOR_HPP_

#include <Eigen/Dense>
#include <rclcpp/rclcpp.hpp>
Expand Down Expand Up @@ -58,7 +58,7 @@ class LocalizationErrorMonitor : public rclcpp::Node
double measureSizeEllipseAlongBodyFrame(const Eigen::Matrix2d & Pinv, double theta);

public:
LocalizationErrorMonitor();
explicit LocalizationErrorMonitor(const rclcpp::NodeOptions & options);
~LocalizationErrorMonitor() = default;
};
#endif // LOCALIZATION_ERROR_MONITOR__NODE_HPP_
#endif // LOCALIZATION_ERROR_MONITOR__LOCALIZATION_ERROR_MONITOR_HPP_
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<arg name="input/odom" default="/localization/kinematic_state"/>
<arg name="param_file" default="$(find-pkg-share localization_error_monitor)/config/localization_error_monitor.param.yaml"/>

<node name="localization_error_monitor" exec="localization_error_monitor" pkg="localization_error_monitor" output="screen">
<node pkg="localization_error_monitor" exec="localization_error_monitor_node" output="both">
<remap from="input/odom" to="$(var input/odom)"/>
<param from="$(var param_file)"/>
</node>
Expand Down
1 change: 1 addition & 0 deletions localization/localization_error_monitor/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<depend>diagnostic_msgs</depend>
<depend>diagnostic_updater</depend>
<depend>nav_msgs</depend>
<depend>rclcpp_components</depend>
<depend>tf2</depend>
<depend>tf2_geometry_msgs</depend>
<depend>tier4_autoware_utils</depend>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

#include "localization_error_monitor/node.hpp"
#include "localization_error_monitor/localization_error_monitor.hpp"

#include "localization_error_monitor/diagnostics.hpp"

Expand All @@ -32,7 +32,8 @@
#include <string>
#include <utility>

LocalizationErrorMonitor::LocalizationErrorMonitor() : Node("localization_error_monitor")
LocalizationErrorMonitor::LocalizationErrorMonitor(const rclcpp::NodeOptions & options)
: Node("localization_error_monitor", options)
{
scale_ = this->declare_parameter<double>("scale");
error_ellipse_size_ = this->declare_parameter<double>("error_ellipse_size");
Expand Down Expand Up @@ -143,3 +144,6 @@ double LocalizationErrorMonitor::measureSizeEllipseAlongBodyFrame(
double d = std::sqrt((e.transpose() * Pinv * e)(0, 0) / Pinv.determinant());
return d;
}

#include <rclcpp_components/register_node_macro.hpp>
RCLCPP_COMPONENTS_REGISTER_NODE(LocalizationErrorMonitor)
28 changes: 0 additions & 28 deletions localization/localization_error_monitor/src/main.cpp

This file was deleted.

0 comments on commit 11f010a

Please sign in to comment.