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

feat(ekf_localizer): componentize EKFLocalizer #7104

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
17 changes: 8 additions & 9 deletions localization/ekf_localizer/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ include_directories(

ament_auto_find_build_dependencies()

ament_auto_add_library(ekf_localizer_lib SHARED
ament_auto_add_library(${PROJECT_NAME} SHARED
src/ekf_localizer.cpp
src/covariance.cpp
src/diagnostics.cpp
Expand All @@ -24,21 +24,20 @@ ament_auto_add_library(ekf_localizer_lib SHARED
src/ekf_module.cpp
)

target_link_libraries(ekf_localizer_lib Eigen3::Eigen)

ament_auto_add_executable(ekf_localizer src/ekf_localizer_node.cpp)

target_compile_options(ekf_localizer PUBLIC -g -Wall -Wextra -Wpedantic -Werror)
rclcpp_components_register_node(${PROJECT_NAME}
PLUGIN "EKFLocalizer"
EXECUTABLE ${PROJECT_NAME}_node
EXECUTOR SingleThreadedExecutor
)

target_link_libraries(ekf_localizer ekf_localizer_lib)
target_include_directories(ekf_localizer PUBLIC include)
target_link_libraries(${PROJECT_NAME} Eigen3::Eigen)

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

ament_add_gtest(${test_name} ${filepath})
target_link_libraries("${test_name}" ekf_localizer_lib)
target_link_libraries("${test_name}" ${PROJECT_NAME})
ament_target_dependencies(${test_name} ${${PROJECT_NAME}_FOUND_BUILD_DEPENDS})
endfunction()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ class Simple1DFilter
class EKFLocalizer : public rclcpp::Node
{
public:
EKFLocalizer(const std::string & node_name, const rclcpp::NodeOptions & options);
explicit EKFLocalizer(const rclcpp::NodeOptions & options);

private:
const std::shared_ptr<Warning> warning_;
Expand Down
2 changes: 1 addition & 1 deletion localization/ekf_localizer/launch/ekf_localizer.launch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<arg name="output_twist_name" default="ekf_twist"/>
<arg name="output_twist_with_covariance_name" default="ekf_twist_with_covariance"/>

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

<remap from="in_twist_with_covariance" to="$(var input_twist_with_cov_name)"/>
Expand Down
1 change: 1 addition & 0 deletions localization/ekf_localizer/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
<depend>kalman_filter</depend>
<depend>nav_msgs</depend>
<depend>rclcpp</depend>
<depend>rclcpp_components</depend>
<depend>std_srvs</depend>
<depend>tf2</depend>
<depend>tf2_ros</depend>
Expand Down
7 changes: 5 additions & 2 deletions localization/ekf_localizer/src/ekf_localizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@

using std::placeholders::_1;

EKFLocalizer::EKFLocalizer(const std::string & node_name, const rclcpp::NodeOptions & node_options)
: rclcpp::Node(node_name, node_options),
EKFLocalizer::EKFLocalizer(const rclcpp::NodeOptions & node_options)
: rclcpp::Node("ekf_localizer", node_options),
warning_(std::make_shared<Warning>(this)),
params_(this),
ekf_dt_(params_.ekf_dt),
Expand Down Expand Up @@ -479,3 +479,6 @@ void EKFLocalizer::serviceTriggerNode(
res->success = true;
return;
}

#include <rclcpp_components/register_node_macro.hpp>
RCLCPP_COMPONENTS_REGISTER_NODE(EKFLocalizer)
28 changes: 0 additions & 28 deletions localization/ekf_localizer/src/ekf_localizer_node.cpp

This file was deleted.

Loading