#ifndef MOVE_BASE_CONVERT_DATA_H
#define MOVE_BASE_CONVERT_DATA_H

#include <robot_costmap_2d/costmap_2d_robot.h>
#include <robot_nav_msgs/OccupancyGrid.h>
#include <robot_map_msgs/OccupancyGridUpdate.h>

namespace move_base
{
  class ConvertData
  {
  public:
    ConvertData(robot_costmap_2d::Costmap2DROBOT* costmap, std::string global_frame, bool always_send_full_costmap = false);
    ~ConvertData();

    /** @brief Update data for publication. */
    void updateCostmap(robot_nav_msgs::OccupancyGrid &grid, robot_map_msgs::OccupancyGridUpdate &update, bool &is_updated);

    void updateFootprint(robot_geometry_msgs::PolygonStamped &footprint);

  private:
    /** @brief Prepare grid_ message for publication. */
    void prepareGrid();

    /** @brief Include the given bounds in the changed-rectangle. */
    void updateBounds(unsigned int x0, unsigned int xn, unsigned int y0, unsigned int yn);

    robot_costmap_2d::Costmap2DROBOT* costmap_;
    std::string global_frame_;
    unsigned int x0_, xn_, y0_, yn_;
    double saved_origin_x_, saved_origin_y_;
    bool always_send_full_costmap_;
    robot_nav_msgs::OccupancyGrid grid_;
    static char* cost_translation_table_;  ///< Translate from 0-255 values in costmap to -1 to 100 values in message.
  };
}
#endif