An interface for publishing NavGridOfX/OccupancyGrid msgs and their updates periodically.
More...
|
template<class FullGridType , class UpdateType , class Callback > |
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) |
|
void | onNewSubscriptionNav (const ros::SingleSubscriberPublisher &pub) |
|
void | onNewSubscriptionOcc (const ros::SingleSubscriberPublisher &pub) |
|
void | publishNav () |
|
void | publishNavUpdate (const nav_core2::UIntBounds &bounds) |
|
void | publishOcc () |
|
void | publishOccUpdate (const nav_core2::UIntBounds &bounds) |
|
void | publishUpdateArea (const nav_grid::NavGridInfo &info, const nav_core2::UIntBounds &bounds) |
|
bool | shouldPublishFull () const |
|
bool | shouldPublishHelper (const ros::Time &last_publish, const ros::Duration &cycle) const |
|
bool | shouldPublishUpdate () const |
|
virtual nav_msgs::OccupancyGrid | toOccupancyGrid (const ros::Time ×tamp)=0 |
|
virtual map_msgs::OccupancyGridUpdate | toOccupancyGridUpdate (const nav_core2::UIntBounds &bounds, const ros::Time ×tamp)=0 |
|
template<typename NumericType, typename NavGridOfX, typename NavGridOfXUpdate>
class nav_grid_pub_sub::GenericGridPublisher< NumericType, NavGridOfX, NavGridOfXUpdate >
An interface for publishing NavGridOfX/OccupancyGrid msgs and their updates periodically.
This class can potentially publish on five different messages on five topics
- NavGridOfX / grid
- NavGridOfXUpdate / grid_update
- OccupancyGrid / costmap
- OccupancyGridUpdate / costmap_updates
- PolygonStamped / update_area (where X is either Chars or Doubles) These names can be overridden, and if you wish to not publish a portion, you can set the topic name to the empty string in the init method.
The main reason for the two types of publishers (NavGridOfX vs OccupancyGrid) is that the standard usage for OccupancyGrid has been that values are ranged [0, 100] with -1/255 reserved for unknown. Implementing classes need to find a way to convert the full range of values to fit that range. NavGridOfChars does not follow that convention, so all values are used, and NavGridOfDoubles does not need to limit to the 256 values of OccupancyGrid. However, there are legacy applications that like the OccupancyGrid message, so we maintain the ability to publish both.
Full Grid vs. Update Publishing: If you just call publish() with no params, this class will only publish the full grid messages (NavGridOfX/OccupancyGrid). If you call publish(...) with the bounds parameter, this class will publish the full grid messages if publish_updates was set to false during init or the NavGridInfo has changed (i.e. the size/origin/resolution/frame has changed). Otherwise, it will publish the update messages (NavGridOfXUpdate/OccupancyGridUpdate) and the update_area polygon.
How often the full grid is published is controlled by the full_publish_cycle and how often you call one of the publish methods.
- If the full_publish_cycle is 0, which is the default, the full grid will be published every time you call publish.
- If the full_publish_cycle is negative, you can avoid publishing all together.
- Otherwise, the full grid will only be published when publish is called if
full_publish_cycle
time has passed since the last full grid publish.
- Note that full grids may also be published when attempting to publish an update but the grid info has changed You can control how often updates are published with similar logic and the update_publish_cycle argument. If the update_publish_cycle is positive, the Bounds from successive calls will be merged so the resulting update will cover the superset of all the bounds.
Definition at line 106 of file nav_grid_publisher.h.
template<typename NumericType, typename NavGridOfX, typename NavGridOfXUpdate>
Initialize method for determining what gets published when.
- Parameters
-
nh | NodeHandle used for creating publishers |
grid | Data source |
nav_grid_topic | Topic to publish the NavGridOfX on. If empty, don't publish that message. |
occupancy_grid_topic | Topic to publish the OccupancyGrid on. If empty, don't publish that message. |
update_area_topic | Topic to publish the update area polygon on. If empty, don't publish that message. |
publish_updates | If true, publishes _update topics. If false, always publish full grid. |
full_publish_cycle | If positive, limits how often the full grid is published. If negative, never publishes. |
update_publish_cycle | If positive, limits how often the update is published. If negative, never publishes. |
Note: We use the callback functions for when the publisher gets a new subscription to ensure the new subscriber gets the most up to date data. If we just latched the topic, several updates may have occurred between the first whole grid publication and the new subscription, so it would have out-of-date information.
Definition at line 127 of file nav_grid_publisher.h.
template<typename NumericType, typename NavGridOfX, typename NavGridOfXUpdate>
Publish the full grid or updates, as dictated by parameters passed to init.
The bounds provided are of the form [min, max] i.e. the maximum is included in the range. If either range is empty, that indicates none of the grid has been updated, but we still may want to publish some of the data.
Definition at line 174 of file nav_grid_publisher.h.