25 proto::GridOptions2D options;
26 const std::string grid_type_string =
27 parameter_dictionary->
GetString(
"grid_type");
28 proto::GridOptions2D_GridType grid_type;
29 CHECK(proto::GridOptions2D_GridType_Parse(grid_type_string, &grid_type))
30 <<
"Unknown GridOptions2D_GridType kind: " << grid_type_string;
31 options.set_grid_type(grid_type);
32 options.set_resolution(parameter_dictionary->
GetDouble(
"resolution"));
37 float max_correspondence_cost)
39 correspondence_cost_cells_(
40 limits_.cell_limits().num_x_cells * limits_.cell_limits().num_y_cells,
42 min_correspondence_cost_(min_correspondence_cost),
43 max_correspondence_cost_(max_correspondence_cost) {
49 if (proto.has_known_cells_box()) {
50 const auto& box = proto.known_cells_box();
52 Eigen::AlignedBox2i(Eigen::Vector2i(box.min_x(), box.min_y()),
53 Eigen::Vector2i(box.max_x(), box.max_y()));
56 for (
const auto& cell : proto.cells()) {
57 CHECK_LE(cell, std::numeric_limits<uint16>::max());
60 if (proto.min_correspondence_cost() == 0.f &&
61 proto.max_correspondence_cost() == 0.f) {
63 <<
"proto::Grid2D: max_correspondence_cost and min_correspondence_cost " 64 "are initialized with 0 indicating an older version of the " 65 "protobuf format. Loading default values.";
104 *offset = Eigen::Array2i::Zero();
128 const int offset = x_offset + stride * y_offset;
134 new_cells[offset + j + i * stride] =
148 proto::Grid2D result;
152 result.mutable_cells()->Add(cell);
154 CHECK(
update_indices().empty()) <<
"Serializing a grid during an update is " 155 "not supported. Finish the update first.";
157 auto*
const box = result.mutable_known_cells_box();
virtual void GrowLimits(const Eigen::Vector2f &point)
const Eigen::Vector2d & max() const
std::string GetString(const std::string &key)
float ValueToCorrespondenceCost(const uint16 value)
Grid2D(const MapLimits &limits, float min_correspondence_cost, float max_correspondence_cost)
double resolution() const
constexpr float kMaxCorrespondenceCost
float max_correspondence_cost_
double GetDouble(const std::string &key)
virtual proto::Grid2D ToProto() const
Eigen::AlignedBox2i known_cells_box_
const Eigen::AlignedBox2i & known_cells_box() const
const std::vector< uint16 > & correspondence_cost_cells() const
void ComputeCroppedLimits(Eigen::Array2i *const offset, CellLimits *const limits) const
bool Contains(const Eigen::Array2i &cell_index) const
float GetCorrespondenceCost(const Eigen::Array2i &cell_index) const
bool IsKnown(const Eigen::Array2i &cell_index) const
Eigen::Array2i GetCellIndex(const Eigen::Vector2f &point) const
const std::vector< int > & update_indices() const
float min_correspondence_cost_
const MapLimits & limits() const
proto::MapLimits ToProto(const MapLimits &map_limits)
constexpr uint16 kUpdateMarker
int ToFlatIndex(const Eigen::Array2i &cell_index) const
constexpr uint16 kUnknownCorrespondenceValue
std::vector< uint16 > correspondence_cost_cells_
constexpr float kMinCorrespondenceCost
std::vector< int > update_indices_
const CellLimits & cell_limits() const
proto::GridOptions2D CreateGridOptions2D(common::LuaParameterDictionary *const parameter_dictionary)