Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
jlblancoc committed Nov 22, 2023
2 parents cbe133f + 9fe58d9 commit 3901411
Show file tree
Hide file tree
Showing 177 changed files with 3,330 additions and 701 deletions.
2 changes: 1 addition & 1 deletion apps/RawLogViewer/CFormRawMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ CFormRawMap::CFormRawMap(wxWindow* parent, wxWindowID)
"MULTIMETRIC MAP CONFIGURATION\n; "
"====================================================\n[map]\n; "
"Creation of maps:\noccupancyGrid_count = 0\ngasGrid_count = "
"0\nlandmarksMap_count = 0\nbeaconMap_count = 0\npointsMap_count = "
"0\nbeaconMap_count = 0\npointsMap_count = "
"1\nheightMap_count = 0\ncolourPointsMap_count=0\n\n; "
"====================================================\n; MULTIMETRIC "
"MAP: PointsMap #00\n; "
Expand Down
4 changes: 2 additions & 2 deletions apps/benchmarking-image-features/src/place_recognition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ int PlaceRecognition::predictLabel2(

} // iterates over each key-point in the training images / dataset

} // end of outter loop iterates over each key-point
} // end of outer loop iterates over each key-point

for (int i = 0; i < feats_size; i++)
cout << labels[i] << " ";
Expand Down Expand Up @@ -207,7 +207,7 @@ int PlaceRecognition::predictLabel(
}
}
} // iterates over each key-point in the training images / dataset
} // end of outter loop iterates over each key-point
} // end of outer loop iterates over each key-point

for (int i = 0; i < feats_size; i++)
cout << labels[i] << " ";
Expand Down
29 changes: 17 additions & 12 deletions apps/observations2map/observations2map_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <mrpt/maps/COccupancyGridMap2D.h>
#include <mrpt/maps/CSimpleMap.h>
#include <mrpt/serialization/CArchive.h>
#include <mrpt/system/filesystem.h>
#include <mrpt/system/os.h>

using namespace mrpt;
Expand Down Expand Up @@ -61,8 +62,7 @@ int main(int argc, char** argv)
cout << " Default: INI_FILE_SECTION_NAME = MappingApplication"
<< endl;
cout << "Push any key to exit..." << endl;
os::getch();
return -1;
return 1;
}

string configFile = std::string(argv[1]);
Expand All @@ -87,7 +87,7 @@ int main(int argc, char** argv)
metricMap.setListOfMaps(mapCfg);

// Build metric maps:
cout << "Building metric maps...";
cout << "Building metric maps..." << std::endl;

metricMap.loadFromProbabilisticPosesAndObservations(simplemap);

Expand All @@ -97,20 +97,25 @@ int main(int argc, char** argv)
// ---------------------------
metricMap.saveMetricMapRepresentationToFile(outprefix);

// grid maps:
for (unsigned int i = 0;
i < metricMap.countMapsByClass<COccupancyGridMap2D>(); i++)
// And as binary serialized files:
// -------------------------------------
for (unsigned int i = 0; i < metricMap.maps.size(); i++)
{
using namespace std::string_literals;
const auto str = outprefix + "_gridmap_no"s +
mrpt::format("%02u", i) + ".gridmap"s;
cout << "Saving gridmap #" << i << " to " << str << endl;

const auto& m = metricMap.maps.at(i);

const auto str = outprefix + mrpt::format("_%02u_", i) +
mrpt::system::fileNameStripInvalidChars(
m->GetRuntimeClass()->className) +
".bin"s;

std::cout << "Saving map #" << i << " to " << str << std::endl;

CFileGZOutputStream fo(str);
mrpt::serialization::archiveFrom(fo)
<< *metricMap.mapByClass<COccupancyGridMap2D>(i);
mrpt::serialization::archiveFrom(fo) << m;

cout << "done." << endl;
cout << "Done." << endl;
}

return 0;
Expand Down
6 changes: 3 additions & 3 deletions apps/robot-map-gui/gui/configWidget/CConfigWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -211,11 +211,11 @@ TSetOfMetricMapInitializers CConfigWidget::config()
for (auto& map : it.second)
{
const std::string sMapName = map->getName().toStdString();
TMetricMapInitializer* mi = mmr.factoryMapDefinition(sMapName);
auto mi = mmr.factoryMapDefinition(sMapName);
ASSERT_(mi);

map->updateConfiguration(mi);
mapCfg.push_back(TMetricMapInitializer::Ptr(mi));
map->updateConfiguration(mi.get());
mapCfg.push_back(mi);
++index;
}
}
Expand Down
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# version format
version: 2.11.2-{branch}-build{build}
version: 2.11.3-{branch}-build{build}

os: Visual Studio 2019

Expand Down
23 changes: 23 additions & 0 deletions doc/source/doxygen-docs/changelog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
\page changelog Change Log

# Version 2.11.3: Released Nov 21st, 2023
- Changes in libraries:
- \ref mrpt_core_grp
- Add the `[[nodiscard]]` attribute to all functions returning a value in `<mrpt/core/bits_math.h>`
- \ref mrpt_maps_grp
- mrpt::maps::COccupancyGridMap3D::insertObservation() now also handles mrpt::obs::CObservationPointCloud
- New virtual interface mrpt::maps::NearestNeighborsCapable, implemented in:
- All mrpt::maps::CPointsMap classes
- All classes derived from mrpt::maps::CVoxelMapOccupancyBase
- mrpt::maps::COccupancyGridMap2D
- mrpt::maps::COccupancyGridMap2D
- New virtual method mrpt::maps::CMetricMap::boundingBox()
- mrpt::maps::TMetricMapInitializer now returns `shared_ptr`s instead of plain pointers.
- mrpt::maps::TSetOfMetricMapInitializers::loadFromConfigFile() now throws if it finds a `*_count` entry with an unknown map class name.
- \ref mrpt_math_grp
- New template mrpt::math::confidenceIntervalsFromHistogram()
- \ref mrpt_obs_grp
- mrpt::maps::CMetricMap::loadFromSimpleMap() now automatically calls mrpt::obs::CObservation::load() and mrpt::obs::CObservation::unload() for all observations, so it works with lazy-load datasets.
- BUG FIXES:
- Fix compilation errors if using the `MCP_SAVE()` macro with class enum types.
- Fix wrong cloud pose in CPointsMap::insertObservation() when inserting an mrpt::obs::CObservationPointCloud.
- Fix potential data race in mrpt::WorkerThreadsPool::pendingTasks()

# Version 2.11.2: Released Oct 25th, 2023
- Changes in libraries:
- \ref mrpt_gui_grp
Expand Down
16 changes: 16 additions & 0 deletions libs/config/include/mrpt/config/CConfigFileBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,26 @@ class CConfigFileBase
/** Returns a list with all the section names. */
virtual void getAllSections(std::vector<std::string>& sections) const = 0;

/** Returns, by value, a list with all the section names. */
std::vector<std::string> sections() const
{
std::vector<std::string> ret;
getAllSections(ret);
return ret;
}

/** Returs a list with all the keys into a section */
virtual void getAllKeys(
const std::string& section, std::vector<std::string>& keys) const = 0;

/** Returs, by value, a list with all the keys into a section */
std::vector<std::string> keys(const std::string& section) const
{
std::vector<std::string> keys;
getAllKeys(section, keys);
return keys;
}

/** Checks if a given section exists (name is case insensitive)
* \sa keyExists() */
bool sectionExists(const std::string& section_name) const;
Expand Down
5 changes: 4 additions & 1 deletion libs/config/src/CConfigFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ struct CConfigFile::Impl
};

// copied from mrpt-io to avoid lib dependency:
static std::string local_file_get_contents(const std::string& fileName)
namespace
{
std::string local_file_get_contents(const std::string& fileName)
{
// Credits: https://stackoverflow.com/a/2602258/1631514
// Note: Add "binary" to make sure the "tellg" file size matches the actual
Expand All @@ -57,6 +59,7 @@ static std::string local_file_get_contents(const std::string& fileName)
t.read(&buffer[0], size);
return buffer;
}
} // namespace

/*---------------------------------------------------------------
Constructor
Expand Down
8 changes: 4 additions & 4 deletions libs/config/src/CConfigFileMemory_unittest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ TEST(CConfigFileMemory, readwrite)

TEST(CConfigFileMemory, Sections)
{
std::vector<std::string> sections;
mrpt::config::CConfigFileMemory second;
second.write("one", "name", "val");
second.write("two", "names", "value");
second.getAllSections(sections);

const std::vector<std::string> sections = second.sections();
EXPECT_EQ(2U, sections.size());
if (sections.size() == 2)
{ // avoid potential crash if fails
Expand All @@ -40,11 +40,11 @@ TEST(CConfigFileMemory, Sections)

TEST(CConfigFileMemory, Names)
{
std::vector<std::string> names;
mrpt::config::CConfigFileMemory third;
third.write("sec", "name", "val");
third.write("sec", "names", "value");
third.getAllKeys("sec", names);

const std::vector<std::string> names = third.keys("sec");
EXPECT_EQ(2U, names.size());
if (names.size() == 2)
{ // avoid potential crash if fails
Expand Down
22 changes: 17 additions & 5 deletions libs/containers/include/mrpt/containers/yaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,22 @@ std::ostream& operator<<(std::ostream& o, const yaml& p);
MCP_LOAD_OPT(Yaml__, Var__); \
Var__ = mrpt::DEG2RAD(Var__)

namespace internal
{
// We need to implement this as a template for the "if constexpr()" false branch
// not to be evaluated for enums, which would lead to build errors.
template <typename T, typename YAML_T>
void impl_mcp_save(YAML_T& y, const T& var, const char* varName)
{
using enum_t = std::remove_cv_t<T>;

if constexpr (std::is_enum_v<enum_t>)
y[varName] = mrpt::typemeta::TEnumType<enum_t>::value2name(var);
else
y[varName] = var;
}
} // namespace internal

/** Macro to store a variable into a mrpt::containers::yaml (initials MCP)
* dictionary, using as "key" the name of the variable.
*
Expand All @@ -931,11 +947,7 @@ std::ostream& operator<<(std::ostream& o, const yaml& p);
* values. Note that this requires enums to implement mrpt::typemeta::TEnumType.
*/
#define MCP_SAVE(Yaml__, Var__) \
if constexpr (std::is_enum_v<decltype(Var__)>) \
Yaml__[#Var__] = mrpt::typemeta::TEnumType< \
std::remove_cv_t<decltype(Var__)>>::value2name(Var__); \
else \
Yaml__[#Var__] = Var__;
mrpt::containers::internal::impl_mcp_save(Yaml__, Var__, #Var__);

#define MCP_SAVE_DEG(Yaml__, Var__) Yaml__[#Var__] = mrpt::RAD2DEG(Var__);

Expand Down
37 changes: 27 additions & 10 deletions libs/containers/src/yaml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,9 @@ bool yaml::internalPrintNodeAsYAML(
THROW_EXCEPTION("Should never reach here");
}

static std::string shortenComment(const std::optional<std::string>& c)
namespace
{
std::string shortenComment(const std::optional<std::string>& c)
{
if (!c.has_value()) return {"[none]"};

Expand All @@ -439,6 +441,7 @@ static std::string shortenComment(const std::optional<std::string>& c)
else
return {c.value()};
}
} // namespace

void yaml::internalPrintDebugStructure(
const node_t& p, std::ostream& o, int indent)
Expand Down Expand Up @@ -499,7 +502,9 @@ void yaml::internalPrintDebugStructure(
THROW_EXCEPTION("Should never reach here");
}

static void internalPrintRightComment(std::ostream& o, const std::string& c)
namespace
{
void internalPrintRightComment(std::ostream& o, const std::string& c)
{
if (c.find('\n') == std::string::npos)
{
Expand All @@ -511,6 +516,7 @@ static void internalPrintRightComment(std::ostream& o, const std::string& c)
s.erase(std::remove(s.begin(), s.end(), '\n'), s.end());
o << " # " << s << "\n";
}
} // namespace

bool yaml::internalPrintAsYAML(
const std::monostate&, std::ostream& o, const InternalPrintState& ps,
Expand Down Expand Up @@ -637,7 +643,7 @@ bool yaml::internalPrintStringScalar(
const std::string sInd(ps.indent + 2, ' ');

// representation of empty *string*
const static std::string emptyStr = "''";
const thread_local std::string emptyStr = "''";
const std::string& s = sIn.empty() ? emptyStr : sIn;

const bool hasFinalNL = !s.empty() && s.back() == '\n';
Expand Down Expand Up @@ -770,7 +776,9 @@ yaml yaml::FromText(const std::string& yamlTextBlock)
}

// TODO: Allow users to add custom filters?
static yaml::scalar_t textToScalar(const std::string& s)
namespace
{
yaml::scalar_t textToScalar(const std::string& s)
{
// tag:yaml.org,2002:null
// https://yaml.org/spec/1.2/spec.html#id2803362
Expand All @@ -780,10 +788,13 @@ static yaml::scalar_t textToScalar(const std::string& s)

return {s};
}
} // namespace

#if MRPT_HAS_FYAML
static std::optional<yaml::node_t> recursiveParse(struct fy_parser* p);

namespace
{
std::optional<yaml::node_t> recursiveParse(struct fy_parser* p);
}
static bool MRPT_YAML_PARSER_VERBOSE =
mrpt::get_env<bool>("MRPT_YAML_PARSER_VERBOSE", false);

Expand All @@ -796,7 +807,9 @@ static bool MRPT_YAML_PARSER_VERBOSE =
} \
} while (0)

static std::optional<std::string> extractComment(
namespace
{
std::optional<std::string> extractComment(
struct fy_token* t, enum fy_comment_placement cp)
{
std::array<char, 2048> str;
Expand All @@ -813,7 +826,7 @@ static std::optional<std::string> extractComment(
return c;
}

static void parseTokenCommentsAndMarks(struct fy_token* tk, yaml::node_t& n)
void parseTokenCommentsAndMarks(struct fy_token* tk, yaml::node_t& n)
{
if (!tk) return;

Expand All @@ -839,7 +852,7 @@ static void parseTokenCommentsAndMarks(struct fy_token* tk, yaml::node_t& n)
}
}

static std::optional<yaml::node_t> recursiveParse(struct fy_parser* p)
std::optional<yaml::node_t> recursiveParse(struct fy_parser* p)
{
MRPT_START

Expand Down Expand Up @@ -993,6 +1006,7 @@ static std::optional<yaml::node_t> recursiveParse(struct fy_parser* p)
#undef PARSER_DBG_OUT
MRPT_END
}
} // namespace
#endif

void yaml::loadFromText(const std::string& yamlTextBlock)
Expand Down Expand Up @@ -1037,7 +1051,9 @@ yaml yaml::FromStream(std::istream& i)
}

// Replicated from mrpt::io to avoid dependency to that module:
static std::string local_file_get_contents(const std::string& fileName)
namespace
{
std::string local_file_get_contents(const std::string& fileName)
{
// Credits: https://stackoverflow.com/a/2602258/1631514
// Note: Add "binary" to make sure the "tellg" file size matches the
Expand All @@ -1055,6 +1071,7 @@ static std::string local_file_get_contents(const std::string& fileName)
t.read(&buffer[0], size);
return buffer;
}
} // namespace

void yaml::loadFromFile(const std::string& fileName)
{
Expand Down
Loading

0 comments on commit 3901411

Please sign in to comment.