Skip to content

Commit 11f010a

Browse files
feat(localization_error_monitor): componentize LocalizationErrorMonitor (#7102)
* remove unusing main func file Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> * add and mod to use glog Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> * change name to localization_error_monitor Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> * style(pre-commit): autofix * rm dependencies Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> * change log output from screen to both Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> --------- Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 2ac6116 commit 11f010a

File tree

6 files changed

+21
-43
lines changed

6 files changed

+21
-43
lines changed

localization/localization_error_monitor/CMakeLists.txt

+9-8
Original file line numberDiff line numberDiff line change
@@ -4,33 +4,34 @@ project(localization_error_monitor)
44
find_package(autoware_cmake REQUIRED)
55
autoware_package()
66

7-
ament_auto_add_library(localization_error_monitor_module SHARED
7+
ament_auto_add_library(${PROJECT_NAME} SHARED
88
src/diagnostics.cpp
9+
src/localization_error_monitor.cpp
910
)
1011

11-
ament_auto_add_executable(localization_error_monitor
12-
src/main.cpp
13-
src/node.cpp
12+
rclcpp_components_register_node(${PROJECT_NAME}
13+
PLUGIN "LocalizationErrorMonitor"
14+
EXECUTABLE ${PROJECT_NAME}_node
15+
EXECUTOR SingleThreadedExecutor
1416
)
15-
target_link_libraries(localization_error_monitor localization_error_monitor_module)
1617

1718
if(BUILD_TESTING)
1819
function(add_testcase filepath)
1920
get_filename_component(filename ${filepath} NAME)
2021
string(REGEX REPLACE ".cpp" "" test_name ${filename})
2122
ament_add_gtest(${test_name} ${filepath})
2223
target_include_directories(${test_name} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include)
23-
target_link_libraries(${test_name} localization_error_monitor_module)
24+
target_link_libraries(${test_name} ${PROJECT_NAME})
2425
ament_target_dependencies(${test_name} ${${PROJECT_NAME}_FOUND_BUILD_DEPENDS})
2526
endfunction()
2627

27-
2828
find_package(ament_lint_auto REQUIRED)
2929
ament_lint_auto_find_test_dependencies()
3030
add_testcase(test/test_diagnostics.cpp)
3131
endif()
3232

33-
ament_auto_package(INSTALL_TO_SHARE
33+
ament_auto_package(
34+
INSTALL_TO_SHARE
3435
config
3536
launch
3637
)

localization/localization_error_monitor/include/localization_error_monitor/node.hpp localization/localization_error_monitor/include/localization_error_monitor/localization_error_monitor.hpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#ifndef LOCALIZATION_ERROR_MONITOR__NODE_HPP_
16-
#define LOCALIZATION_ERROR_MONITOR__NODE_HPP_
15+
#ifndef LOCALIZATION_ERROR_MONITOR__LOCALIZATION_ERROR_MONITOR_HPP_
16+
#define LOCALIZATION_ERROR_MONITOR__LOCALIZATION_ERROR_MONITOR_HPP_
1717

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

6060
public:
61-
LocalizationErrorMonitor();
61+
explicit LocalizationErrorMonitor(const rclcpp::NodeOptions & options);
6262
~LocalizationErrorMonitor() = default;
6363
};
64-
#endif // LOCALIZATION_ERROR_MONITOR__NODE_HPP_
64+
#endif // LOCALIZATION_ERROR_MONITOR__LOCALIZATION_ERROR_MONITOR_HPP_

localization/localization_error_monitor/launch/localization_error_monitor.launch.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<arg name="input/odom" default="/localization/kinematic_state"/>
33
<arg name="param_file" default="$(find-pkg-share localization_error_monitor)/config/localization_error_monitor.param.yaml"/>
44

5-
<node name="localization_error_monitor" exec="localization_error_monitor" pkg="localization_error_monitor" output="screen">
5+
<node pkg="localization_error_monitor" exec="localization_error_monitor_node" output="both">
66
<remap from="input/odom" to="$(var input/odom)"/>
77
<param from="$(var param_file)"/>
88
</node>

localization/localization_error_monitor/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
<depend>diagnostic_msgs</depend>
2424
<depend>diagnostic_updater</depend>
2525
<depend>nav_msgs</depend>
26+
<depend>rclcpp_components</depend>
2627
<depend>tf2</depend>
2728
<depend>tf2_geometry_msgs</depend>
2829
<depend>tier4_autoware_utils</depend>

localization/localization_error_monitor/src/node.cpp localization/localization_error_monitor/src/localization_error_monitor.cpp

+6-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
#include "localization_error_monitor/node.hpp"
15+
#include "localization_error_monitor/localization_error_monitor.hpp"
1616

1717
#include "localization_error_monitor/diagnostics.hpp"
1818

@@ -32,7 +32,8 @@
3232
#include <string>
3333
#include <utility>
3434

35-
LocalizationErrorMonitor::LocalizationErrorMonitor() : Node("localization_error_monitor")
35+
LocalizationErrorMonitor::LocalizationErrorMonitor(const rclcpp::NodeOptions & options)
36+
: Node("localization_error_monitor", options)
3637
{
3738
scale_ = this->declare_parameter<double>("scale");
3839
error_ellipse_size_ = this->declare_parameter<double>("error_ellipse_size");
@@ -143,3 +144,6 @@ double LocalizationErrorMonitor::measureSizeEllipseAlongBodyFrame(
143144
double d = std::sqrt((e.transpose() * Pinv * e)(0, 0) / Pinv.determinant());
144145
return d;
145146
}
147+
148+
#include <rclcpp_components/register_node_macro.hpp>
149+
RCLCPP_COMPONENTS_REGISTER_NODE(LocalizationErrorMonitor)

localization/localization_error_monitor/src/main.cpp

-28
This file was deleted.

0 commit comments

Comments
 (0)