Skip to content

Commit f2ae1af

Browse files
feat(pose2twist): componentize Pose2Twist (#7113)
* remove unusing main func file Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> * mod to componentize and use glog Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> * change log output from log to both Signed-off-by: a-maumau <maumaumaumaumaumaumaumaumaumau@gmail.com> * style(pre-commit): autofix --------- 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 583cd85 commit f2ae1af

File tree

6 files changed

+14
-34
lines changed

6 files changed

+14
-34
lines changed

localization/pose2twist/CMakeLists.txt

+7-2
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ project(pose2twist)
44
find_package(autoware_cmake REQUIRED)
55
autoware_package()
66

7-
ament_auto_add_executable(pose2twist
8-
src/pose2twist_node.cpp
7+
ament_auto_add_library(${PROJECT_NAME} SHARED
98
src/pose2twist_core.cpp
109
)
1110

11+
rclcpp_components_register_node(${PROJECT_NAME}
12+
PLUGIN "Pose2Twist"
13+
EXECUTABLE ${PROJECT_NAME}_node
14+
EXECUTOR SingleThreadedExecutor
15+
)
16+
1217
ament_auto_package(
1318
INSTALL_TO_SHARE
1419
launch

localization/pose2twist/include/pose2twist/pose2twist_core.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
class Pose2Twist : public rclcpp::Node
2525
{
2626
public:
27-
Pose2Twist();
27+
explicit Pose2Twist(const rclcpp::NodeOptions & options);
2828
~Pose2Twist() = default;
2929

3030
private:

localization/pose2twist/launch/pose2twist.launch.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<arg name="input_pose_topic" default="/localization/pose_estimator/pose" description=""/>
33
<arg name="output_twist_topic" default="/estimate_twist" description=""/>
44

5-
<node pkg="pose2twist" exec="pose2twist" name="pose2twist" output="log">
5+
<node pkg="pose2twist" exec="pose2twist_node" output="both">
66
<remap from="pose" to="$(var input_pose_topic)"/>
77
<remap from="twist" to="$(var output_twist_topic)"/>
88
</node>

localization/pose2twist/package.xml

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
<depend>geometry_msgs</depend>
2121
<depend>rclcpp</depend>
22+
<depend>rclcpp_components</depend>
2223
<depend>tf2_geometry_msgs</depend>
2324
<depend>tier4_debug_msgs</depend>
2425

localization/pose2twist/src/pose2twist_core.cpp

+4-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <cstddef>
2525
#include <functional>
2626

27-
Pose2Twist::Pose2Twist() : Node("pose2twist_core")
27+
Pose2Twist::Pose2Twist(const rclcpp::NodeOptions & options) : rclcpp::Node("pose2twist", options)
2828
{
2929
using std::placeholders::_1;
3030

@@ -129,3 +129,6 @@ void Pose2Twist::callbackPose(geometry_msgs::msg::PoseStamped::SharedPtr pose_ms
129129
angular_z_msg.data = twist_msg.twist.angular.z;
130130
angular_z_pub_->publish(angular_z_msg);
131131
}
132+
133+
#include <rclcpp_components/register_node_macro.hpp>
134+
RCLCPP_COMPONENTS_REGISTER_NODE(Pose2Twist)

localization/pose2twist/src/pose2twist_node.cpp

-29
This file was deleted.

0 commit comments

Comments
 (0)