102 lines
3.1 KiB
C#
102 lines
3.1 KiB
C#
/*
|
|
* Copyright 2018 The Cartographer Authors
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
using System.Collections.Generic;
|
|
using System.Text.Json.Serialization;
|
|
using System.Text.Json;
|
|
|
|
namespace CartographerSharp.Models.Mapping;
|
|
|
|
/// <summary>
|
|
/// Protocol buffer representation of a 2D grid.
|
|
/// </summary>
|
|
public struct Grid2D
|
|
{
|
|
/// <summary>
|
|
/// Cell box for known cells.
|
|
/// </summary>
|
|
public struct CellBox
|
|
{
|
|
[JsonPropertyName("max_x")]
|
|
public int MaxX { get; set; }
|
|
|
|
[JsonPropertyName("max_y")]
|
|
public int MaxY { get; set; }
|
|
|
|
[JsonPropertyName("min_x")]
|
|
public int MinX { get; set; }
|
|
|
|
[JsonPropertyName("min_y")]
|
|
public int MinY { get; set; }
|
|
|
|
public CellBox(int maxX, int maxY, int minX, int minY)
|
|
{
|
|
MaxX = maxX;
|
|
MaxY = maxY;
|
|
MinX = minX;
|
|
MinY = minY;
|
|
}
|
|
}
|
|
|
|
[JsonPropertyName("limits")]
|
|
public MapLimits Limits { get; set; }
|
|
|
|
/// <summary>
|
|
/// These values are actually int16s, but protos don't have a native int16 type.
|
|
/// </summary>
|
|
[JsonPropertyName("cells")]
|
|
public List<int> Cells { get; set; }
|
|
|
|
[JsonPropertyName("known_cells_box")]
|
|
public CellBox KnownCellsBox { get; set; }
|
|
|
|
/// <summary>
|
|
/// Grid type - oneof probability_grid_2d or tsdf_2d.
|
|
/// Using JsonPolymorphic for oneof support in System.Text.Json.
|
|
/// </summary>
|
|
[JsonPropertyName("probability_grid_2d")]
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
public ProbabilityGrid? ProbabilityGrid2D { get; set; }
|
|
|
|
[JsonPropertyName("tsdf_2d")]
|
|
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
|
|
public TSDF2D? Tsdf2D { get; set; }
|
|
|
|
[JsonPropertyName("min_correspondence_cost")]
|
|
public double MinCorrespondenceCost { get; set; }
|
|
|
|
[JsonPropertyName("max_correspondence_cost")]
|
|
public double MaxCorrespondenceCost { get; set; }
|
|
|
|
public Grid2D(
|
|
MapLimits limits,
|
|
List<int>? cells = null,
|
|
CellBox knownCellsBox = default,
|
|
ProbabilityGrid? probabilityGrid2D = null,
|
|
TSDF2D? tsdf2D = null,
|
|
double minCorrespondenceCost = 0.0,
|
|
double maxCorrespondenceCost = 0.0)
|
|
{
|
|
Limits = limits;
|
|
Cells = cells ?? new List<int>();
|
|
KnownCellsBox = knownCellsBox;
|
|
ProbabilityGrid2D = probabilityGrid2D;
|
|
Tsdf2D = tsdf2D;
|
|
MinCorrespondenceCost = minCorrespondenceCost;
|
|
MaxCorrespondenceCost = maxCorrespondenceCost;
|
|
}
|
|
}
|