32 "mrpt::maps::CReflectivityGridMap2D,reflectivityMap",
41 const std::string& sectionNamePrefix)
44 const std::string sSectCreation =
45 sectionNamePrefix + string(
"_creationOpts");
52 insertionOpts.loadFromConfigFile(
53 source, sectionNamePrefix +
string(
"_insertOpts"));
57 std::ostream&
out)
const 65 this->insertionOpts.dumpToTextStream(
out);
91 double x_min,
double x_max,
double y_min,
double y_max,
double resolution)
92 : CDynamicGrid<int8_t>(x_min, x_max, y_min, y_max, resolution),
119 robotPose2D =
CPose2D(*robotPose);
120 robotPose3D = (*robotPose);
141 sensor_pose.
composeFrom(robotPose3D, o.sensorPose);
151 const double new_x_min = std::min(
m_x_min, sensor_pose.
x());
152 const double new_y_min = std::min(
m_y_min, sensor_pose.
y());
153 const double new_x_max = std::min(
m_x_max, sensor_pose.
x());
154 const double new_y_max = std::min(
m_y_max, sensor_pose.
y());
158 new_x_min, new_x_max, new_y_min, new_y_max, default_cell,
162 cell =
cellByPos(sensor_pose.
x(), sensor_pose.
y());
165 cell !=
nullptr,
"cell==nullptr even after resizing grid!?");
168 const int cell_old =
static_cast<int>(*cell);
169 int cell_new = cell_old +
static_cast<int>(logodd_observation);
173 *cell =
static_cast<cell_t>(cell_new);
232 const auto n =
static_cast<uint32_t
>(
m_map.size());
234 if (n)
out.WriteBuffer(&
m_map[0], n);
276 std::ostream&
out)
const 278 out <<
"\n----------- [CReflectivityGridMap2D::TInsertionOptions] " 291 [[maybe_unused]]
const std::string& section)
300 const std::string& filNamePrefix)
const 310 CImage& img,
bool verticalFlip,
bool forceRGB)
const 316 unsigned char* destPtr;
317 for (
unsigned int y = 0; y <
m_size_y; y++)
323 for (
unsigned int x = 0; x <
m_size_x; x++)
333 unsigned char* destPtr;
334 for (
unsigned int y = 0; y <
m_size_y; y++)
340 for (
unsigned int x = 0; x <
m_size_x; x++)
362 std::make_shared<opengl::CTexturedPlane>();
371 unsigned char* destPtr_color;
372 unsigned char* destPtr_trans;
374 for (
unsigned int y = 0; y <
m_size_y; y++)
376 destPtr_color = imgColor(0, y);
377 destPtr_trans = imgTrans(0, y);
378 for (
unsigned int x = 0; x <
m_size_x; x++)
381 *destPtr_color++ = cell255;
383 int8_t auxC = (int8_t)((
signed short)cell255) - 128;
384 *destPtr_trans++ = auxC > 0 ? (auxC << 1) : ((-auxC) << 1);
388 outObj->assignImage(imgColor, imgTrans);
389 outSetOfObj->insert(outObj);
Virtual base for specifying the kind and parameters of one map (normally, to be inserted into mrpt::m...
Parameters for CMetricMap::compute3DMatchingRatio()
std::vector< int8_t > m_map
The cells.
void keep_min(T &var, const K test_val)
If the second argument is below the first one, set the first argument to this lower value...
float compute3DMatchingRatio(const mrpt::maps::CMetricMap *otherMap, const mrpt::poses::CPose3D &otherMapPose, const TMatchingRatioParams ¶ms) const override
See docs in base class: in this class this always returns 0.
void dumpToTextStream(std::ostream &out) const override
This method should clearly display all the contents of the structure in textual form, sending it to a std::ostream.
void fill(const int8_t &value)
Fills all the cells with the same value.
bool internal_insertObservation(const mrpt::obs::CObservation &obs, const mrpt::poses::CPose3D *robotPose=nullptr) override
Internal method called by insertObservation()
CReflectivityGridMap2D(double x_min=-2, double x_max=2, double y_min=-2, double y_max=2, double resolution=0.1)
Constructor.
uint8_t serializeGetVersion() const override
Must return the current versioning number of the object.
bool enableSaveAs3DObject
(Default=true) If false, calling CMetricMap::getAs3DObject() will have no effects ...
#define IMPLEMENTS_SERIALIZABLE(class_name, base, NameSpace)
To be added to all CSerializable-classes implementation files.
void dumpToTextStream_map_specific(std::ostream &out) const override
mrpt::vision::TStereoCalibParams params
Declares a class derived from "CObservation" that encapsules a single short-range reflectivity measur...
int8_t cell_t
The type of cells.
TMapGenericParams genericMapParams
Common params to all maps.
void dyngridcommon_writeToStream(STREAM &out) const
void saveMetricMapRepresentationToFile(const std::string &filNamePrefix) const override
This virtual method saves the map to a file "filNamePrefix"+< some_file_extension >...
A 2D grid map representing the reflectivity of the environment (for example, measured with an IR prox...
void serializeFrom(mrpt::serialization::CArchive &in, uint8_t serial_version) override
Pure virtual method for reading (deserializing) from an abstract archive.
#define MRPT_THROW_UNKNOWN_SERIALIZATION_VERSION(__V)
For use in CSerializable implementations.
This class allows loading and storing values and vectors of different types from a configuration text...
This base provides a set of functions for maths stuff.
cell_t p2l(const float p)
Scales a real valued probability in [0,1] to an integer representation of: log(p)-log(1-p) in the val...
void getAs3DObject(mrpt::opengl::CSetOfObjects::Ptr &outObj) const override
Returns a 3D object representing the map.
void resize(std::size_t width, std::size_t height, TImageChannels nChannels, PixelDepth depth=PixelDepth::D8U)
Changes the size of the image, erasing previous contents (does NOT scale its current content...
void composeFrom(const CPose3D &A, const CPose3D &B)
Makes "this = A (+) B"; this method is slightly more efficient than "this= A + B;" since it avoids th...
static constexpr int8_t CELLTYPE_MIN
int8_t * cellByPos(double x, double y)
Returns a pointer to the contents of a cell given by its coordinates, or nullptr if it is out of the ...
static constexpr int8_t CELLTYPE_MAX
virtual void resize(double new_x_min, double new_x_max, double new_y_min, double new_y_max, const int8_t &defaultValueNewCells, double additionalMarginMeters=2.0)
Changes the size of the grid, maintaining previous contents.
This namespace contains representation of robot actions and observations.
void loadFromConfigFile(const mrpt::config::CConfigFileBase &source, const std::string §ion) override
This method load the options from a ".ini"-like file or memory-stored string list.
string iniFile(myDataDir+string("benchmark-options.ini"))
#define IS_CLASS(obj, class_name)
True if the given reference to object (derived from mrpt::rtti::CObject) is of the given class...
double internal_computeObservationLikelihood(const mrpt::obs::CObservation &obs, const mrpt::poses::CPose3D &takenFrom) override
Internal method called by computeObservationLikelihood()
#define ASSERTMSG_(f, __ERROR_MSG)
Defines an assertion mechanism.
double x() const
Common members of all points & poses classes.
bool isEmpty() const override
Returns true if the map is empty/no observation has been inserted.
#define ASSERT_ABOVEEQ_(__A, __B)
void dyngridcommon_readFromStream(STREAM &in, bool cast_from_float=false)
Classes for 2D/3D geometry representation, both of single values and probability density distribution...
void keep_max(T &var, const K test_val)
If the second argument is above the first one, set the first argument to this higher value...
#define LOADABLEOPTS_DUMP_VAR(variableName, variableType)
Macro for dumping a variable to a stream, within the method "dumpToTextStream(out)" (Variable types a...
return_t square(const num_t x)
Inline function for the square of a number.
#define MRPT_LOAD_CONFIG_VAR( variableName, variableType, configFileObject, sectionNameStr)
An useful macro for loading variables stored in a INI-like file under a key with the same name that t...
void loadFromConfigFile_map_specific(const mrpt::config::CConfigFileBase &source, const std::string §ionNamePrefix) override
Load all map-specific params.
mrpt::maps::CReflectivityGridMap2D::TInsertionOptions insertionOptions
This is the global namespace for all Mobile Robot Programming Toolkit (MRPT) libraries.
#define MAP_DEFINITION_REGISTER(_CLASSNAME_STRINGS, _CLASSNAME_WITH_NS)
Registers one map class into TMetricMapInitializer factory.
Virtual base class for "archives": classes abstracting I/O streams.
uint8_t l2p_255(const cell_t l)
Scales an integer representation of the log-odd into a linear scale [0,255], using p=exp(l)/(1+exp(l)...
Declares a virtual base class for all metric maps storage classes.
A class used to store a 2D pose, including the 2D coordinate point and a heading (phi) angle...
A class used to store a 3D pose (a 3D translation + a rotation in 3D).
mrpt::vision::TStereoCalibResults out
Declares a class that represents any robot's observation.
void internal_clear() override
Internal method called by clear()
bool saveToTextFile(const std::string &fileName) const
Saves a float representation of the grid (via "cell2float()") to a text file.
int16_t channel
The reflectivity channel for this map.
size_t ReadBuffer(void *Buffer, size_t Count)
Reads a block of bytes from the stream into Buffer.
void serializeTo(mrpt::serialization::CArchive &out) const override
Pure virtual method for writing (serializing) to an abstract archive.
#define ASSERT_BELOWEQ_(__A, __B)
static CLogOddsGridMapLUT< cell_t > m_logodd_lut
Lookup tables for log-odds.
mrpt::maps::CReflectivityGridMap2D::TInsertionOptions insertionOpts
void getAsImage(mrpt::img::CImage &img, bool verticalFlip=false, bool forceRGB=false) const
Returns the grid as a 8-bit graylevel image, where each pixel is a cell (output image is RGB only if ...
float l2p(const cell_t l)
Scales an integer representation of the log-odd into a real valued probability in [0...
static mrpt::maps::CMetricMap * internal_CreateFromMapDefinition(const mrpt::maps::TMetricMapInitializer &def)
double min_x
See CReflectivityGridMap2DOptions::CReflectivityGridMap2DOptions.
TInsertionOptions()
Default values loader.
One static instance of this struct should exist in any class implementing CLogOddsGridMap2D to hold t...
A class for storing images as grayscale or RGB bitmaps.