#ifndef MAP_GENERATOR_H_INCLUDED_
#define MAP_GENERATOR_H_INCLUDED_

#include <cstdio>
#include "ros/ros.h"
#include "ros/console.h"
#include "nav_msgs/GetMap.h"
#include "tf2/LinearMath/Matrix3x3.h"
#include "geometry_msgs/Quaternion.h"


namespace map_server
{
  /**
   * @brief Map generation node.
   */
  class MapGenerator
  {
  public:
    MapGenerator(ros::NodeHandle nh, const std::string& mapname, const std::string map_topic, 
                  int threshold_occupied = 65, int threshold_free = 25);
                  
    MapGenerator(const std::string& mapname, const std::string map_topic, 
                  int threshold_occupied = 65, int threshold_free = 25);
    virtual ~MapGenerator() {}
    virtual bool  waitingGenerator(double tolerance = 2.0);
    bool isMapSaved() {return saved_map_;}

  private:

    void mapCallback(const nav_msgs::OccupancyGridConstPtr& map);

    std::string mapname_;
    ros::Subscriber map_sub_;
    bool saved_map_;
    int threshold_occupied_;
    int threshold_free_;
  };


} // namespace map_server

#endif // MAP_GENERATOR_H_INCLUDED_