Skip to content
Closed
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
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,9 @@
#include "nav_2d_msgs/msg/twist2_d_stamped.hpp"
#include "nav_msgs/msg/odometry.hpp"
#include "nav2_util/lifecycle_node.hpp"
#include "rclcpp/rclcpp.hpp"
#include "nav2_util/node_utils.hpp"
#include "rclcpp/rclcpp.hpp"
#include "rclcpp/subscription_options.hpp"

namespace nav_2d_utils
{
Expand All @@ -70,11 +71,15 @@ class OdomSubscriber

std::string odom_topic;
nh->get_parameter_or("odom_topic", odom_topic, default_topic);

rclcpp::SubscriptionOptions sub_options;
sub_options.qos_overriding_options = rclcpp::QosOverridingOptions::with_default_policies();
odom_sub_ =
nh->create_subscription<nav_msgs::msg::Odometry>(
odom_topic,
rclcpp::SystemDefaultsQoS(),
std::bind(&OdomSubscriber::odomCallback, this, std::placeholders::_1));
std::bind(&OdomSubscriber::odomCallback, this, std::placeholders::_1),
sub_options);
}

inline nav_2d_msgs::msg::Twist2D getTwist() {return odom_vel_.velocity;}
Expand Down
13 changes: 11 additions & 2 deletions nav2_util/src/odometry_utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <string>

#include "nav2_util/odometry_utils.hpp"
#include "rclcpp/subscription_options.hpp"

using namespace std::chrono; // NOLINT
using namespace std::chrono_literals; // NOLINT
Expand All @@ -30,10 +31,14 @@ OdomSmoother::OdomSmoother(
: received_odom_(false), odom_history_duration_(rclcpp::Duration::from_seconds(filter_duration))
{
auto node = parent.lock();

rclcpp::SubscriptionOptions sub_options;
sub_options.qos_overriding_options = rclcpp::QosOverridingOptions::with_default_policies();
odom_sub_ = node->create_subscription<nav_msgs::msg::Odometry>(
odom_topic,
rclcpp::SystemDefaultsQoS(),
std::bind(&OdomSmoother::odomCallback, this, std::placeholders::_1));
std::bind(&OdomSmoother::odomCallback, this, std::placeholders::_1),
sub_options);

odom_cumulate_.twist.twist.linear.x = 0;
odom_cumulate_.twist.twist.linear.y = 0;
Expand All @@ -50,10 +55,14 @@ OdomSmoother::OdomSmoother(
: odom_history_duration_(rclcpp::Duration::from_seconds(filter_duration))
{
auto node = parent.lock();

rclcpp::SubscriptionOptions sub_options;
sub_options.qos_overriding_options = rclcpp::QosOverridingOptions::with_default_policies();
odom_sub_ = node->create_subscription<nav_msgs::msg::Odometry>(
odom_topic,
rclcpp::SystemDefaultsQoS(),
std::bind(&OdomSmoother::odomCallback, this, std::placeholders::_1));
std::bind(&OdomSmoother::odomCallback, this, std::placeholders::_1),
sub_options);

odom_cumulate_.twist.twist.linear.x = 0;
odom_cumulate_.twist.twist.linear.y = 0;
Expand Down
Loading