11#include < vortex/utils/math.hpp>
2+ #include " geometry_msgs/msg/pose_stamped.hpp"
3+ #include " geometry_msgs/msg/pose_with_covariance_stamped.hpp"
24#include " nav_msgs/msg/odometry.hpp"
35#include " rclcpp/rclcpp.hpp"
46#include " vortex_msgs/msg/reference_filter_quat.hpp"
@@ -17,8 +19,11 @@ class MessagePublisherNode : public rclcpp::Node {
1719 " nautilus/waypoint" );
1820 this ->declare_parameter <std::string>(" topics.reference_filter" ,
1921 " nautilus/reference_filter" );
20- this ->declare_parameter <std::string>(" topics.output" ,
21- " utils/odometry/euler" );
22+ this ->declare_parameter <std::string>(" topics.pose_stamped" ,
23+ " nautilus/pose_stamped" );
24+ this ->declare_parameter <std::string>(
25+ " topics.pose_with_covariance_stamped" , " nautilus/pose" );
26+ this ->declare_parameter <std::string>(" topics.output" , " utils/rpy" );
2227
2328 auto input_type = this ->get_parameter (" input_type" ).as_string ();
2429 auto output_topic = this ->get_parameter (" topics.output" ).as_string ();
@@ -61,11 +66,38 @@ class MessagePublisherNode : public rclcpp::Node {
6166 " Euler publisher [reference_filter]: %s -> %s" ,
6267 topic.c_str (), output_topic.c_str ());
6368
69+ } else if (input_type == " pose_stamped" ) {
70+ auto topic = this ->get_parameter (" topics.pose_stamped" ).as_string ();
71+ sub_ = this ->create_subscription <geometry_msgs::msg::PoseStamped>(
72+ topic, qos_profile,
73+ std::bind (&MessagePublisherNode::pose_stamped_callback, this ,
74+ std::placeholders::_1));
75+ RCLCPP_INFO (this ->get_logger (),
76+ " Euler publisher [pose_stamped]: %s -> %s" ,
77+ topic.c_str (), output_topic.c_str ());
78+
79+ } else if (input_type == " pose_with_covariance_stamped" ) {
80+ auto topic =
81+ this ->get_parameter (" topics.pose_with_covariance_stamped" )
82+ .as_string ();
83+ sub_ = this ->create_subscription <
84+ geometry_msgs::msg::PoseWithCovarianceStamped>(
85+ topic, qos_profile,
86+ std::bind (&MessagePublisherNode::
87+ pose_with_covariance_stamped_callback,
88+ this , std::placeholders::_1));
89+ RCLCPP_INFO (
90+ this ->get_logger (),
91+ " Euler publisher [pose_with_covariance_stamped]: %s -> %s" ,
92+ topic.c_str (), output_topic.c_str ());
93+
6494 } else {
65- RCLCPP_FATAL (this ->get_logger (),
66- " Unknown input_type: '%s'. Must be 'odometry', "
67- " 'waypoint', or 'reference_filter'." ,
68- input_type.c_str ());
95+ RCLCPP_FATAL (
96+ this ->get_logger (),
97+ " Unknown input_type: '%s'. Must be 'odometry', 'waypoint', "
98+ " 'reference_filter', 'pose_stamped', or "
99+ " 'pose_with_covariance_stamped'." ,
100+ input_type.c_str ());
69101 rclcpp::shutdown ();
70102 return ;
71103 }
@@ -107,10 +139,27 @@ class MessagePublisherNode : public rclcpp::Node {
107139 publish_rpy (msg->header , euler);
108140 }
109141
142+ void pose_stamped_callback (
143+ const geometry_msgs::msg::PoseStamped::SharedPtr msg) {
144+ const auto & q = msg->pose .orientation ;
145+ auto euler = convert_quat (q.w , q.x , q.y , q.z );
146+ publish_rpy (msg->header , euler);
147+ }
148+
149+ void pose_with_covariance_stamped_callback (
150+ const geometry_msgs::msg::PoseWithCovarianceStamped::SharedPtr msg) {
151+ const auto & q = msg->pose .pose .orientation ;
152+ auto euler = convert_quat (q.w , q.x , q.y , q.z );
153+ publish_rpy (msg->header , euler);
154+ }
155+
110156 using SubVariant = std::variant<
111157 rclcpp::Subscription<nav_msgs::msg::Odometry>::SharedPtr,
112158 rclcpp::Subscription<vortex_msgs::msg::Waypoint>::SharedPtr,
113- rclcpp::Subscription<vortex_msgs::msg::ReferenceFilterQuat>::SharedPtr>;
159+ rclcpp::Subscription<vortex_msgs::msg::ReferenceFilterQuat>::SharedPtr,
160+ rclcpp::Subscription<geometry_msgs::msg::PoseStamped>::SharedPtr,
161+ rclcpp::Subscription<
162+ geometry_msgs::msg::PoseWithCovarianceStamped>::SharedPtr>;
114163
115164 SubVariant sub_;
116165 rclcpp::Publisher<vortex_msgs::msg::RPY>::SharedPtr rpy_pub_;
0 commit comments