<commit_before>/*
 * GridMap.hpp
 *
 *  Created on: Jul 14, 2014
 *      Author: <NAME>
 *	 Institute: ETH Zurich, Autonomous Systems Lab
 */

#pragma once

#include <vector>
#include <unordered_map>

// Eigen
#include <Eigen/Core>
#include <grid_map_core/BufferRegion.hpp>
#include "common.hpp"
#include "SubmapGeometry.hpp"

namespace cost_map {

class SubmapGeometry;

/*!
 * Grid map managing multiple overlaying maps holding float values.
 * Data structure implemented as two-dimensional circular buffer so map
 * can be moved efficiently.
 *
 * Data is defined with string keys. Examples are:
 * - "elevation"
 * - "variance"
 * - "color"
 * - "quality"
 * - "surface_normal_x", "surface_normal_y", "surface_normal_z"
 * etc.
 */
class CostMap
{
public:
  /*!
   * Constructor.
   * @param layers a vector of strings containing the definition/description of the data layer.
   */
  CostMap(const std::vector<std::string>& layers);

  /*!
   * Emtpy constructor.
   */
  CostMap();

  /*!
   * Destructor.
   */
  virtual ~CostMap();

  /*!
   * Set the geometry of the grid map. Clears all the data.
   * @param length the side lengths in x, and y-direction of the grid map [m].
   * @param resolution the cell size in [m/cell].
   * @param position the 2d position of the grid map in the grid map frame [m].
   */
  void setGeometry(const Length& length, const double resolution,
                   const Position& position = Position::Zero());

  /*!
   * Set the geometry of the grid map from submap geometry information.
   * @param geometry the submap geometry information.
   */
  void setGeometry(const SubmapGeometry& geometry);

  /*!
   * Add a new empty data layer.
   * @param layer the name of the layer.
   * @value value the value to initialize the cells with.
   */
  void add(const std::string& layer, const DataType value = NO_INFORMATION);

  /*!
   * Add a new data layer (if the layer already exists, overwrite its data, otherwise add layer and data).
   * @param layer the name of the layer.
   * @param data the data to be added.
   */
  void add(const std::string& layer, const Matrix& data);

  /*!
   * Checks if data layer exists.
   * @param layer the name of the layer.
   * @return true if layer exists, false otherwise.
   */
  bool exists(const std::string& layer) const;

  /*!
   * Returns the grid map data for a layer as matrix.
   * @param layer the name of the layer to be returned.
   * @return grid map data as matrix.
   * @throw std::out_of_range if no map layer with name `layer` is present.<commit_msg>[cost_map_core] method for updating the position<commit_after>/*
 * GridMap.hpp
 *
 *  Created on: Jul 14, 2014
 *      Author: <NAME>
 *	 Institute: ETH Zurich, Autonomous Systems Lab
 */

#pragma once

#include <vector>
#include <unordered_map>

// Eigen
#include <Eigen/Core>
#include <grid_map_core/BufferRegion.hpp>
#include "common.hpp"
#include "SubmapGeometry.hpp"

namespace cost_map {

class SubmapGeometry;

/*!
 * Grid map managing multiple overlaying maps holding float values.
 * Data structure implemented as two-dimensional circular buffer so map
 * can be moved efficiently.
 *
 * Data is defined with string keys. Examples are:
 * - "elevation"
 * - "variance"
 * - "color"
 * - "quality"
 * - "surface_normal_x", "surface_normal_y", "surface_normal_z"
 * etc.
 */
class CostMap
{
public:
  /*!
   * Constructor.
   * @param layers a vector of strings containing the definition/description of the data layer.
   */
  CostMap(const std::vector<std::string>& layers);

  /*!
   * Emtpy constructor.
   */
  CostMap();

  /*!
   * Destructor.
   */
  virtual ~CostMap();

  /*!
   * Set the geometry of the grid map. Clears all the data.
   * @param length the side lengths in x, and y-direction of the grid map [m].
   * @param resolution the cell size in [m/cell].
   * @param position the 2d position of the grid map in the grid map frame [m].
   */
  void setGeometry(const Length& length, const double resolution,
                   const Position& position = Position::Zero());

  /*!
   * Set the geometry of the grid map from submap geometry information.
   * @param geometry the submap geometry information.
   */
  void setGeometry(const SubmapGeometry& geometry);

  /*!
   * Set the position of the grid map.
   * @param position the 2d position of the grid map in the grid map frame [m].
   */
  void setPosition(const Position& position) { position_ = position; }

  /*!
   * Add a new empty data layer.
   * @param layer the name of the layer.
   * @value value the value to initialize the cells with.
   */
  void add(const std::string& layer, const DataType value = NO_INFORMATION);

  /*!
   * Add a new data layer (if the layer already exists, overwrite its data, otherwise add layer and data).
   * @param layer the name of the layer.
   * @param data the data to be added.
   */
  void add(const std::string& layer, const Matrix& data);

  /*!
   * Checks if data layer exists.
   * @param layer the name of the layer.
   * @return true if layer exists, false otherwise.
   */
  bool exists(const std::string& layer) const;

  /*!
   * Returns the grid map data for a layer as matrix.
   * @param layer the name of the layer to be returned.
   * @return grid map data as matrix.
   * @throw std::out_of_range if no map layer with name `layer` is present.
{'fraction_non_alphanumeric': 0.10539123923624111, 'fraction_numerical': 0.0028079371022089105, 'mean_word_length': 3.0755148741418763, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4547240', 'n_tokens_mistral': 1610, 'n_tokens_neox': 1560, 'n_words': 646}