Skip to content

Commit 583cd85

Browse files
authored
feat(localization_error_monitor): componentize EKFLocalizer (#7104)
* 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> --------- Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com>
1 parent 11f010a commit 583cd85

File tree

6 files changed

+16
-41
lines changed

6 files changed

+16
-41
lines changed

localization/ekf_localizer/CMakeLists.txt

+8-9
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ include_directories(
1313

1414
ament_auto_find_build_dependencies()
1515

16-
ament_auto_add_library(ekf_localizer_lib SHARED
16+
ament_auto_add_library(${PROJECT_NAME} SHARED
1717
src/ekf_localizer.cpp
1818
src/covariance.cpp
1919
src/diagnostics.cpp
@@ -24,21 +24,20 @@ ament_auto_add_library(ekf_localizer_lib SHARED
2424
src/ekf_module.cpp
2525
)
2626

27-
target_link_libraries(ekf_localizer_lib Eigen3::Eigen)
28-
29-
ament_auto_add_executable(ekf_localizer src/ekf_localizer_node.cpp)
30-
31-
target_compile_options(ekf_localizer PUBLIC -g -Wall -Wextra -Wpedantic -Werror)
27+
rclcpp_components_register_node(${PROJECT_NAME}
28+
PLUGIN "EKFLocalizer"
29+
EXECUTABLE ${PROJECT_NAME}_node
30+
EXECUTOR SingleThreadedExecutor
31+
)
3232

33-
target_link_libraries(ekf_localizer ekf_localizer_lib)
34-
target_include_directories(ekf_localizer PUBLIC include)
33+
target_link_libraries(${PROJECT_NAME} Eigen3::Eigen)
3534

3635
function(add_testcase filepath)
3736
get_filename_component(filename ${filepath} NAME)
3837
string(REGEX REPLACE ".cpp" "" test_name ${filename})
3938

4039
ament_add_gtest(${test_name} ${filepath})
41-
target_link_libraries("${test_name}" ekf_localizer_lib)
40+
target_link_libraries("${test_name}" ${PROJECT_NAME})
4241
ament_target_dependencies(${test_name} ${${PROJECT_NAME}_FOUND_BUILD_DEPENDS})
4342
endfunction()
4443

localization/ekf_localizer/include/ekf_localizer/ekf_localizer.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class Simple1DFilter
102102
class EKFLocalizer : public rclcpp::Node
103103
{
104104
public:
105-
EKFLocalizer(const std::string & node_name, const rclcpp::NodeOptions & options);
105+
explicit EKFLocalizer(const rclcpp::NodeOptions & options);
106106

107107
private:
108108
const std::shared_ptr<Warning> warning_;

localization/ekf_localizer/launch/ekf_localizer.launch.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<arg name="output_twist_name" default="ekf_twist"/>
1818
<arg name="output_twist_with_covariance_name" default="ekf_twist_with_covariance"/>
1919

20-
<node pkg="ekf_localizer" exec="ekf_localizer" name="ekf_localizer" output="screen">
20+
<node pkg="ekf_localizer" exec="ekf_localizer_node" output="both">
2121
<remap from="in_pose_with_covariance" to="$(var input_pose_with_cov_name)"/>
2222

2323
<remap from="in_twist_with_covariance" to="$(var input_twist_with_cov_name)"/>

localization/ekf_localizer/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
<depend>kalman_filter</depend>
3030
<depend>nav_msgs</depend>
3131
<depend>rclcpp</depend>
32+
<depend>rclcpp_components</depend>
3233
<depend>std_srvs</depend>
3334
<depend>tf2</depend>
3435
<depend>tf2_ros</depend>

localization/ekf_localizer/src/ekf_localizer.cpp

+5-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@
4040

4141
using std::placeholders::_1;
4242

43-
EKFLocalizer::EKFLocalizer(const std::string & node_name, const rclcpp::NodeOptions & node_options)
44-
: rclcpp::Node(node_name, node_options),
43+
EKFLocalizer::EKFLocalizer(const rclcpp::NodeOptions & node_options)
44+
: rclcpp::Node("ekf_localizer", node_options),
4545
warning_(std::make_shared<Warning>(this)),
4646
params_(this),
4747
ekf_dt_(params_.ekf_dt),
@@ -479,3 +479,6 @@ void EKFLocalizer::serviceTriggerNode(
479479
res->success = true;
480480
return;
481481
}
482+
483+
#include <rclcpp_components/register_node_macro.hpp>
484+
RCLCPP_COMPONENTS_REGISTER_NODE(EKFLocalizer)

localization/ekf_localizer/src/ekf_localizer_node.cpp

-28
This file was deleted.

0 commit comments

Comments
 (0)