38 #ifndef NAV2_COSTMAP_2D__COSTMAP_FILTERS__SPEED_FILTER_HPP_
39 #define NAV2_COSTMAP_2D__COSTMAP_FILTERS__SPEED_FILTER_HPP_
44 #include "nav2_costmap_2d/costmap_filters/costmap_filter.hpp"
46 #include "geometry_msgs/msg/point_stamped.hpp"
47 #include "nav2_msgs/msg/costmap_filter_info.hpp"
48 #include "nav2_msgs/msg/speed_limit.hpp"
49 #include "nav_msgs/msg/path.hpp"
50 #include "nav2_util/odometry_utils.hpp"
51 #include "nav2_util/geometry_utils.hpp"
52 #include "nav2_util/path_utils.hpp"
74 const std::string & filter_info_topic)
override;
81 int min_i,
int min_j,
int max_i,
int max_j,
82 const geometry_msgs::msg::Pose & pose)
override;
98 void filterInfoCallback(
const nav2_msgs::msg::CostmapFilterInfo::ConstSharedPtr & msg);
102 void maskCallback(
const nav_msgs::msg::OccupancyGrid::ConstSharedPtr & msg);
106 void pathCallback(
const nav_msgs::msg::Path::ConstSharedPtr & msg);
114 const geometry_msgs::msg::Pose & pose,
115 double & speed_limit);
124 const geometry_msgs::msg::Pose & robot_pose,
125 double lookahead_dist,
126 double & speed_limit);
128 nav2::Subscription<nav2_msgs::msg::CostmapFilterInfo>::SharedPtr filter_info_sub_;
129 nav2::Subscription<nav_msgs::msg::OccupancyGrid>::SharedPtr mask_sub_;
130 nav2::Subscription<nav_msgs::msg::Path>::SharedPtr path_sub_;
132 nav2::Publisher<nav2_msgs::msg::SpeedLimit>::SharedPtr speed_limit_pub_;
133 nav2::Publisher<geometry_msgs::msg::PointStamped>::SharedPtr lookahead_pub_;
135 nav_msgs::msg::OccupancyGrid::ConstSharedPtr filter_mask_;
136 nav_msgs::msg::Path::ConstSharedPtr current_path_;
139 std::shared_ptr<nav2_util::OdomSmoother> odom_smoother_;
141 std::string global_frame_;
143 double base_, multiplier_;
145 double speed_limit_, speed_limit_prev_;
148 double held_lookahead_dist_;
149 size_t lookahead_start_idx_;
150 bool enable_path_lookahead_;
152 double min_lookahead_;
153 double max_lookahead_;
A 2D costmap provides a mapping between points in the world and their associated "costs".
: CostmapFilter basic class. It is inherited from Layer in order to avoid hidden problems when the sh...
Reads in a speed restriction mask and enables a robot to dynamically adjust speed based on pose in ma...
void resetFilter() override
Reset the costmap filter / topic / info.
bool getSpeedLimitFromLookahead(const geometry_msgs::msg::Pose &robot_pose, double lookahead_dist, double &speed_limit)
Get the speed limit from the path lookahead.
void filterInfoCallback(const nav2_msgs::msg::CostmapFilterInfo::ConstSharedPtr &msg)
Callback for the filter information.
bool getSpeedLimitAtPose(const geometry_msgs::msg::Pose &pose, double &speed_limit)
Look up the speed limit at a single pose in the costmap's global frame.
SpeedFilter()
A constructor.
void process(nav2_costmap_2d::Costmap2D &master_grid, int min_i, int min_j, int max_i, int max_j, const geometry_msgs::msg::Pose &pose) override
Process the keepout layer at the current pose / bounds / grid.
void pathCallback(const nav_msgs::msg::Path::ConstSharedPtr &msg)
Callback for the planned path used by path lookahead.
void maskCallback(const nav_msgs::msg::OccupancyGrid::ConstSharedPtr &msg)
Callback for the filter mask.
void initializeFilter(const std::string &filter_info_topic) override
Initialize the filter and subscribe to the info topic.
bool isActive()
If this filter is active.