35 #ifndef NAV_GRID_PUB_SUB_NAV_GRID_PUBLISHER_H 36 #define NAV_GRID_PUB_SUB_NAV_GRID_PUBLISHER_H 46 #include <geometry_msgs/PolygonStamped.h> 59 geometry_msgs::Point32 point;
105 template<
typename NumericType,
typename NavGr
idOfX,
typename NavGr
idOfXUpdate>
128 const std::string& nav_grid_topic =
"grid",
129 const std::string& occupancy_grid_topic =
"costmap",
130 const std::string& update_area_topic =
"update_area",
131 bool publish_updates =
true,
141 createPublishers<NavGridOfX, NavGridOfXUpdate>(
145 createPublishers<nav_msgs::OccupancyGrid, map_msgs::OccupancyGridUpdate>(
149 if (update_area_topic.length() > 0)
151 update_area_pub_ = nh.advertise<geometry_msgs::PolygonStamped>(update_area_topic, 1);
213 template<
class FullGr
idType,
class UpdateType,
class Callback>
217 if (topic.length() > 0)
219 full_grid_pub = nh.
advertise<FullGridType>(topic, 1, new_subscription_callback);
222 update_pub = nh.
advertise<UpdateType>(topic +
"_updates", 1);
233 double cycle_secs = cycle.
toSec();
234 if (cycle_secs < 0.0)
238 else if (cycle_secs == 0.0)
262 geometry_msgs::PolygonStamped polygon;
263 polygon.header.frame_id = info.
frame_id;
335 :
public GenericGridPublisher<unsigned char, nav_2d_msgs::NavGridOfChars, nav_2d_msgs::NavGridOfCharsUpdate>
343 cost_interpretation_table_ = cost_interpretation_table;
363 template<
typename NumericType>
365 :
public GenericGridPublisher<NumericType, nav_2d_msgs::NavGridOfDoubles, nav_2d_msgs::NavGridOfDoublesUpdate>
386 NumericType ignore_value_ { std::numeric_limits<NumericType>::max() };
393 #endif // NAV_GRID_PUB_SUB_NAV_GRID_PUBLISHER_H ROSMsgType toUpdate(const nav_grid::NavGrid< NumericType > &grid, const nav_core2::UIntBounds &bounds, const ros::Time &stamp)
Generic conversion from a portion of a grid of arbitrary type to an update message of arbitrary type...
nav_grid::NavGridInfo saved_info_
ros::Time last_full_publish_
map_msgs::OccupancyGridUpdate toOccupancyGridUpdate(const nav_core2::UIntBounds &bounds, const ros::Time ×tamp) override
unsigned int getMaxX() const
void setCostInterpretation(const std::vector< unsigned char > &cost_interpretation_table)
void publish(const boost::shared_ptr< M > &message) const
static std::vector< unsigned char > OCC_GRID_PUBLISHING
Scale [0, 255] down to [0, 100] (except for a few special values)
map_msgs::OccupancyGridUpdate toOccupancyGridUpdate(const nav_core2::UIntBounds &bounds, const ros::Time ×tamp) override
unsigned int getMinX() const
void publishUpdateArea(const nav_grid::NavGridInfo &info, const nav_core2::UIntBounds &bounds)
geometry_msgs::Point32 makePoint(const nav_grid::NavGridInfo &info, int x, int y)
unsigned int getMinY() const
void publish(const nav_core2::UIntBounds &bounds)
Publish the full grid or updates, as dictated by parameters passed to init.
virtual map_msgs::OccupancyGridUpdate toOccupancyGridUpdate(const nav_core2::UIntBounds &bounds, const ros::Time ×tamp)=0
void publish(const boost::shared_ptr< M const > &message) const
ros::Publisher update_area_pub_
An interface for publishing NavGridOfX/OccupancyGrid msgs and their updates periodically.
void createPublishers(ros::NodeHandle &nh, const std::string &topic, Callback new_subscription_callback, ros::Publisher &full_grid_pub, ros::Publisher &update_pub, bool publish_updates)
nav_msgs::OccupancyGrid toOccupancyGrid(const ros::Time ×tamp) override
void gridToWorld(const NavGridInfo &info, int mx, int my, double &wx, double &wy)
ros::Duration full_publish_cycle_
An interface for publishing NavGridOfChars/OccupancyGrid msgs and their updates periodically.
void init(ros::NodeHandle &nh, const std::string &nav_grid_topic="grid", const std::string &occupancy_grid_topic="costmap", const std::string &update_area_topic="update_area", bool publish_updates=true, ros::Duration full_publish_cycle=ros::Duration(0), ros::Duration update_publish_cycle=ros::Duration(0))
Initialize method for determining what gets published when.
void publish()
Publish the full grid if the full_publish_cycle allows.
GenericGridPublisher(nav_grid::NavGrid< NumericType > &data)
void publishNavUpdate(const nav_core2::UIntBounds &bounds)
ros::Publisher occ_update_pub_
nav_core2::UIntBounds update_bounds_
ros::Time last_update_publish_
bool shouldPublishUpdate() const
void setIgnoreValue(NumericType ignore_value)
void onNewSubscriptionOcc(const ros::SingleSubscriberPublisher &pub)
Publisher advertise(const std::string &topic, uint32_t queue_size, bool latch=false)
ros::Duration update_publish_cycle_
nav_msgs::OccupancyGrid toOccupancyGrid(const ros::Time ×tamp) override
void merge(const GenericBounds< unsigned int > &other)
bool shouldPublishFull() const
uint32_t getNumSubscribers() const
bool shouldPublishHelper(const ros::Time &last_publish, const ros::Duration &cycle) const
NavGridInfo getInfo() const
void publishOccUpdate(const nav_core2::UIntBounds &bounds)
virtual nav_msgs::OccupancyGrid toOccupancyGrid(const ros::Time ×tamp)=0
void onNewSubscriptionNav(const ros::SingleSubscriberPublisher &pub)
nav_grid::NavGrid< NumericType > & data_
map_msgs::OccupancyGridUpdate toOccupancyGridUpdate(const nav_grid::NavGrid< unsigned char > &grid, const nav_core2::UIntBounds &bounds, const ros::Time &stamp=ros::Time(0), const std::vector< unsigned char > cost_interpretation_table=std::vector< unsigned char >())
NavGrid<unsigned char> to OccupancyGridUpdate using cost_interpretation_table.
ros::Time synced_time_stamp_
ros::Publisher nav_update_pub_
unsigned int getMaxY() const
ROSMsgType toMsg(const nav_grid::NavGrid< NumericType > &grid, const ros::Time &stamp)
Utilities for converting NavGrid objects to NavGridOfX messages and updates.
void getExtremeValues(const nav_grid::NavGrid< NumericType > &grid, const NumericType unknown_value, NumericType &min_val, NumericType &max_val)
Retrieve the minimum and maximum values from a grid, ignoring the unknown_value.
nav_msgs::OccupancyGrid toOccupancyGrid(const nav_grid::NavGrid< unsigned char > &grid, const ros::Time &stamp=ros::Time(0), const std::vector< unsigned char > cost_interpretation_table=std::vector< unsigned char >())
NavGrid<unsigned char> to OccupancyGrid using cost_interpretation_table.
An interface for publishing NavGridOfDoubles/OccupancyGrid msgs and their updates periodically...