Local GridMap#

#include "navground/sim/state_estimations/grimap_state_estimation.h"
struct LocalGridMapStateEstimation : public navground::sim::Sensor#

A state estimation that integrates scans and optional odometry in a local grid map.

Uses one of the simplest mapping algorithms, following the implementation of the obstacle layer in nav2 local costmap, see ros-navigation/navigation2.

  1. recenter the map at the agent, setting new cells to 128 (= unknown)

  2. set the footprint of the agent to 255 (= free)

  3. using raycasting, for each lidar ranging measurement, sets the internal cells of the ray to 255 (= free), and the vertex of the ray (if contained in the map) to 0 (= occupied)

Registered properties:

Public Types

enum class FootprintType#

The type of footprint to use.

Values:

enumerator rectangular#

a rectangular area

enumerator circular#

a circular are

enumerator none#

no footprint

Public Functions

inline explicit LocalGridMapStateEstimation(std::vector<std::shared_ptr<LidarStateEstimation>> lidars = {}, std::vector<std::string> external_lidars = {}, std::shared_ptr<OdometryStateEstimation> odometry = nullptr, std::string external_odometry = "", unsigned width = default_width, unsigned height = default_height, ng_float_t resolution = default_resolution, bool include_transformation = false, FootprintType footprint = default_footprint, const std::string &name = "")#

Constructs a new instance.

Parameters:
  • lidars[in] The lidars sensor

  • external_lidars[in] The name of lidars sensor

  • odometry[in] The odometry sensor

  • external_odometry[in] The name of odometry sensor

  • width[in] The map width in pixels

  • height[in] The map height in pixels

  • resolution[in] The size of a cell in meters

  • include_transformation[in] Whether to include the transformation between map and world frames.

  • footprint[in] Which type of footprint to use.

  • name[in] The name to use as a prefix

std::optional<core::GridMap> read_gridmap(core::SensingState &state) const#

Reads a grid map from a core::SensingState.

Calls read_gridmap_with_name, passing Sensor::get_name.

Parameters:

state – The state

Returns:

A grid map or null if none was found.

std::optional<core::Pose2> read_transform(core::SensingState &state) const#

Reads a transformation from a core::SensingState.

Calls read_transform_with_name, passing Sensor::get_name.

Parameters:

state – The state

Returns:

A pose or null if none was found.

inline void set_resolution(ng_float_t value)#

Sets the size of a cell.

Parameters:

value[in] The new value in meters

inline ng_float_t get_resolution() const#

Gets the size of a cell.

Returns:

The size in meters.

inline void set_width(int value)#

Sets the width of the gridmap in cells.

Parameters:

value[in] The new number of cells.

inline int get_width() const#

Gets the width of the gridmap in cells.

Returns:

The number of cells.

inline void set_height(int value)#

Sets the height of the gridmap in cells.

Parameters:

value[in] The new number of cells.

inline int get_height() const#

Gets the height of the gridmap in cells.

Returns:

The number of cells.

inline void set_external_lidars(const std::vector<std::string> &value)#

Sets the names of the (external) lidars.

Parameters:

value[in] The new names.

inline const std::vector<std::string> &get_external_lidars() const#

Gets the names of the (external) lidars.

Returns:

A vector of names.

inline void set_lidars(const std::vector<std::shared_ptr<LidarStateEstimation>> &value)#

Sets the (internal) lidars.

Parameters:

value[in] The new lidars.

inline const std::vector<std::shared_ptr<LidarStateEstimation>> &get_lidars() const#

Gets the (external) lidars.

Returns:

A vector of lidars.

inline void set_external_odometry(const std::string &value)#

Sets the names of the (external) odometry.

Parameters:

value[in] The new name.

inline const std::string &get_external_odometry() const#

Gets the names of the (external) odometry.

Returns:

A valid name.

inline void set_odometry(const std::shared_ptr<OdometryStateEstimation> &value)#

Sets the (internal) odometry.

Parameters:

value[in] The new odometry.

inline const std::shared_ptr<OdometryStateEstimation> &get_odometry() const#

Gets the (external) odometry.

Returns:

An odometry sensor.

inline void set_include_transformation(bool value)#

Sets whether to include the transformation between map and world frames.

Parameters:

value[in] The desired value.

inline bool get_include_transformation() const#

Gets whether to include the transformation between map and world frames.

Returns:

True if it includes the transformation.

inline void set_footprint(FootprintType value)#

Sets footprint type.

Parameters:

value[in] The desired value

inline FootprintType get_footprint() const#

Gets the footprint type.

Returns:

The footprint type

inline void set_footprint_from_string(const std::string &value)#

Sets footprint type.

Parameters:

value[in] The value: one of “circular”, “rectangular”, “none”

inline std::string get_footprint_as_string() const#

Gets the footprint type: one of “circular”, “rectangular”, “none”.

Returns:

The footprint type

Public Static Functions

static std::optional<core::GridMap> read_gridmap_with_name(core::SensingState &state, const std::string &name)#

Reads a grid map from a core::SensingState.

Parameters:
  • state – The state

  • name[in] The namespace of the map

Returns:

A grid map or null if none was found.

static std::optional<core::Pose2> read_transform_with_name(core::SensingState &state, const std::string &name)#

Reads a transformation from a core::SensingState.

Parameters:
  • state – The state

  • name[in] The namespace of the transformation

Returns:

A pose or null if none was found.

Public Static Attributes

static const int default_width = 10#

The default map width in meters

static const int default_height = 10#

The default map height in meters

static const ng_float_t default_resolution = 0.1#

The default map resolution in meter per pixel

static const std::string field_name = "local_gridmap"#

The name of the buffer set by the sensor