16 #ifndef NAV2_UTIL__TWIST_SUBSCRIBER_HPP_
17 #define NAV2_UTIL__TWIST_SUBSCRIBER_HPP_
24 #include "geometry_msgs/msg/twist.hpp"
25 #include "geometry_msgs/msg/twist_stamped.hpp"
26 #include "rclcpp/parameter_service.hpp"
27 #include "rclcpp/qos.hpp"
29 #include "nav2_ros_common/lifecycle_node.hpp"
30 #include "nav2_ros_common/node_utils.hpp"
80 template<
typename TwistCallbackT,
81 typename TwistStampedCallbackT
84 nav2::LifecycleNode::SharedPtr node,
85 const std::string & topic,
86 TwistCallbackT && TwistCallback,
87 TwistStampedCallbackT && TwistStampedCallback,
91 is_stamped_ = node->declare_or_get_parameter(
"enable_stamped_cmd_vel",
true);
95 std::forward<TwistStampedCallbackT>(TwistStampedCallback),
98 twist_sub_ = node->create_subscription<geometry_msgs::msg::Twist>(
100 std::forward<TwistCallbackT>(TwistCallback),
113 template<
typename TwistStampedCallbackT>
115 nav2::LifecycleNode::SharedPtr node,
116 const std::string & topic,
117 TwistStampedCallbackT && TwistStampedCallback,
121 is_stamped_ = node->declare_or_get_parameter(
"enable_stamped_cmd_vel",
true);
125 std::forward<TwistStampedCallbackT>(TwistStampedCallback),
128 throw std::invalid_argument(
129 "enable_stamped_cmd_vel must be true when using this constructor!");
137 nav2::Subscription<geometry_msgs::msg::Twist>::SharedPtr
twist_sub_ {
nullptr};
A QoS profile for standard reliable topics with a history of 10 messages.
A simple wrapper on a Twist subscriber that receives either geometry_msgs::msg::TwistStamped or geome...
TwistSubscriber(nav2::LifecycleNode::SharedPtr node, const std::string &topic, TwistStampedCallbackT &&TwistStampedCallback, const rclcpp::QoS &qos=nav2::qos::StandardTopicQoS())
A constructor that only supports TwistStamped.
bool is_stamped_
The user-configured value for ROS parameter enable_stamped_cmd_vel.
nav2::Subscription< geometry_msgs::msg::Twist >::SharedPtr twist_sub_
The subscription when using Twist.
nav2::Subscription< geometry_msgs::msg::TwistStamped >::SharedPtr twist_stamped_sub_
The subscription when using TwistStamped.
TwistSubscriber(nav2::LifecycleNode::SharedPtr node, const std::string &topic, TwistCallbackT &&TwistCallback, TwistStampedCallbackT &&TwistStampedCallback, const rclcpp::QoS &qos=nav2::qos::StandardTopicQoS())
A constructor that supports either Twist and TwistStamped.