Skip to content

Commit b9876d5

Browse files
committed
Merge branch 'develop'
2 parents 7bb2cf4 + ad6e131 commit b9876d5

File tree

12 files changed

+131
-25
lines changed

12 files changed

+131
-25
lines changed

apps/rosbag2rawlog/rosbag2rawlog_main.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include <mrpt/obs/CObservationPointCloud.h>
3131
#include <mrpt/obs/CObservationRotatingScan.h>
3232
#include <mrpt/poses/CPose3DQuat.h>
33+
#include <mrpt/ros1bridge/gps.h>
3334
#include <mrpt/ros1bridge/imu.h>
3435
#include <mrpt/ros1bridge/laser_scan.h>
3536
#include <mrpt/ros1bridge/point_cloud2.h>
@@ -398,6 +399,33 @@ Obs toIMU(
398399
return {mrptObs};
399400
}
400401

402+
Obs toGPS(
403+
std::string_view msg,
404+
const rosbag::MessageInstance& rosmsg,
405+
const std::optional<mrpt::poses::CPose3D>& fixedSensorPose)
406+
{
407+
auto gps = rosmsg.instantiate<sensor_msgs::NavSatFix>();
408+
409+
auto mrptObs = mrpt::obs::CObservationGPS::Create();
410+
411+
mrptObs->sensorLabel = msg;
412+
mrptObs->timestamp = mrpt::ros1bridge::fromROS(gps->header.stamp);
413+
414+
// Convert data:
415+
mrpt::ros1bridge::fromROS(*gps, *mrptObs);
416+
417+
bool sensorPoseOK = findOutSensorPose(
418+
mrptObs->sensorPose, gps->header.frame_id, arg_base_link_frame.getValue(), fixedSensorPose);
419+
if (!sensorPoseOK)
420+
{
421+
std::cerr << "Warning: dropping one observation of type '" << msg
422+
<< "' due to missing /tf data.\n";
423+
return {};
424+
}
425+
426+
return {mrptObs};
427+
}
428+
401429
Obs toOdometry(std::string_view msg, const rosbag::MessageInstance& rosmsg)
402430
{
403431
auto odo = rosmsg.instantiate<nav_msgs::Odometry>();
@@ -676,6 +704,12 @@ class Transcriber
676704
{ return toIMU(sensorName, m, fixedSensorPose); };
677705
m_lookup[sensor.at("topic").as<std::string>()].emplace_back(callback);
678706
}
707+
else if (sensorType == "CObservationGPS")
708+
{
709+
auto callback = [=](const rosbag::MessageInstance& m)
710+
{ return toGPS(sensorName, m, fixedSensorPose); };
711+
m_lookup[sensor.at("topic").as<std::string>()].emplace_back(callback);
712+
}
679713
else if (sensorType == "CObservationOdometry")
680714
{
681715
auto callback = [=](const rosbag::MessageInstance& m) { return toOdometry(sensorName, m); };

appveyor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# version format
2-
version: 2.14.6-{branch}-build{build}
2+
version: 2.14.7-{branch}-build{build}
33

44
os: Visual Studio 2019
55

doc/source/doxygen-docs/changelog.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,16 @@
11
\page changelog Change Log
22

3+
# Version 2.14.7: UNRELEASED
4+
- Changes in apps:
5+
- rosbag2rawlog (ROS1): Implement conversion of NavSatFix -> mrpt::obs::CObservationGPS
6+
- Changes in libraries:
7+
- \ref mrpt_math_grp
8+
- mrpt::math::TBoundingBox: Renamed flag to bounding box from None to NoFlags to prevent autogenerated stubs from conflicting with python None type
9+
- \ref mrpt_opengl_grp
10+
- mrpt::opengl::Texture now caches "texture names" (OpenGL texture IDs) via image data, boosting performance of MVSim boot up time.
11+
- Build system:
12+
- `mrpt-*-config.cmake` files now enforce the search of cmake dependencies in CONFIG mode, to avoid being foolish by deprecated `FindXXX()` lying around.
13+
314
# Version 2.14.6: Released Dec 3rd, 2024
415
- Changes in libraries:
516
- \ref mrpt_gui_grp:

libs/math/include/mrpt/math/TBoundingBox.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ struct TBoundingBox_
2828
{
2929
enum class CTOR_FLAGS
3030
{
31-
None = 0,
31+
NoFlags = 0,
3232
AllowUnordered
3333
};
3434

@@ -43,7 +43,7 @@ struct TBoundingBox_
4343
TBoundingBox_(
4444
const mrpt::math::TPoint3D_<T>& Min,
4545
const mrpt::math::TPoint3D_<T>& Max,
46-
const CTOR_FLAGS f = CTOR_FLAGS::None) :
46+
const CTOR_FLAGS f = CTOR_FLAGS::NoFlags) :
4747
min(Min), max(Max)
4848
{
4949
if (f != CTOR_FLAGS::AllowUnordered)

libs/opengl/include/mrpt/opengl/Texture.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ class Texture
134134

135135
// Normally users should not need to call these, but they are exposed just in
136136
// case they are useful someday.
137-
texture_name_t getNewTextureNumber();
137+
texture_name_t getNewTextureNumber(const uint8_t* optionalRgbDataForAssociation);
138138
void releaseTextureName(const texture_name_t& t);
139139

140140
} // namespace mrpt::opengl

libs/opengl/src/CRenderizableShaderTexturedTriangles.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void CRenderizableShaderTexturedTriangles::assignImage(const CImage& img)
211211

212212
m_glTexture.unloadTexture();
213213

214-
// Make a copy:
214+
// Make a shallow copy:
215215
m_textureImage = img;
216216
m_textureImageAssigned = true;
217217

libs/opengl/src/Texture.cpp

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99

1010
#include "opengl-precomp.h" // Precompiled header
1111
//
12+
#include <mrpt/containers/bimap.h>
1213
#include <mrpt/core/get_env.h>
1314
#include <mrpt/core/lock_helper.h>
1415
#include <mrpt/opengl/Texture.h>
@@ -57,8 +58,8 @@ class TextureResourceHandler
5758
return o;
5859
}
5960

60-
/// Return [textureName, textureUnit]
61-
texture_name_t generateTextureID()
61+
/// Return textureName
62+
texture_name_t generateTextureID(const uint8_t* rgbDataForAssociation)
6263
{
6364
#if MRPT_HAS_OPENGL_GLUT || MRPT_HAS_EGL
6465
auto lck = mrpt::lockHelper(m_texturesMtx);
@@ -71,6 +72,8 @@ class TextureResourceHandler
7172
CHECK_OPENGL_ERROR_IN_DEBUG();
7273
m_textureReservedFrom[textureID] = std::this_thread::get_id();
7374

75+
if (rgbDataForAssociation) m_textureToRGBdata.insert(textureID, rgbDataForAssociation);
76+
7477
if (MRPT_OPENGL_VERBOSE)
7578
std::cout << "[mrpt generateTextureID] textureName:" << textureID << std::endl;
7679

@@ -80,6 +83,21 @@ class TextureResourceHandler
8083
#endif
8184
}
8285

86+
std::optional<texture_name_t> checkIfTextureAlreadyExists(const mrpt::img::CImage& rgb)
87+
{
88+
#if MRPT_HAS_OPENGL_GLUT || MRPT_HAS_EGL
89+
auto lck = mrpt::lockHelper(m_texturesMtx);
90+
91+
auto it = m_textureToRGBdata.getInverseMap().find(rgb.asCvMatRef().data);
92+
if (it != m_textureToRGBdata.getInverseMap().end())
93+
return it->second;
94+
else
95+
return {};
96+
#else
97+
return {};
98+
#endif
99+
}
100+
83101
void releaseTextureID(unsigned int texName)
84102
{
85103
#if MRPT_HAS_OPENGL_GLUT || MRPT_HAS_EGL
@@ -109,19 +127,36 @@ class TextureResourceHandler
109127
void processDestroyQueue()
110128
{
111129
#if MRPT_HAS_OPENGL_GLUT || MRPT_HAS_EGL
112-
if (auto itLst = m_destroyQueue.find(std::this_thread::get_id()); itLst != m_destroyQueue.end())
130+
if (auto itLst = m_destroyQueue.find(std::this_thread::get_id());
131+
itLst != m_destroyQueue.end() && !itLst->second.empty())
113132
{
114133
auto& lst = itLst->second;
134+
135+
// Delete in OpenGL:
115136
glDeleteTextures(lst.size(), lst.data());
116137
CHECK_OPENGL_ERROR_IN_DEBUG();
138+
139+
// delete in rgb data container too:
140+
for (const auto id : lst)
141+
{
142+
if (m_textureToRGBdata.hasKey(id)) m_textureToRGBdata.erase_by_key(id);
143+
}
144+
145+
if (MRPT_OPENGL_VERBOSE)
146+
{
147+
std::cout << "[mrpt processDestroyQueue] threadId=" << std::this_thread::get_id()
148+
<< " destroyed " << lst.size() << "\n";
149+
}
117150
lst.clear();
151+
m_destroyQueue.erase(itLst);
118152
}
119-
if (MRPT_OPENGL_VERBOSE)
153+
if (!m_destroyQueue.empty() && MRPT_OPENGL_VERBOSE)
120154
{
121155
std::cout << "[mrpt processDestroyQueue] threadId=" << std::this_thread::get_id()
122-
<< ". At output: ";
156+
<< ". Remaining at output: ";
123157
for (const auto& lst : m_destroyQueue)
124-
std::cout << "[" << lst.first << "]=" << lst.second.size() << " ";
158+
std::cout << "[" << lst.first << "]=" << lst.second.size() << " textures ";
159+
std::cout << "\n";
125160
}
126161
#endif
127162
}
@@ -130,14 +165,20 @@ class TextureResourceHandler
130165
std::mutex m_texturesMtx;
131166
std::map<GLuint, std::thread::id> m_textureReservedFrom;
132167
std::map<std::thread::id, std::vector<GLuint>> m_destroyQueue;
168+
mrpt::containers::bimap<GLuint, const uint8_t*> m_textureToRGBdata;
133169
GLint m_maxTextureUnits;
134170
#endif
135171
};
136172

173+
std::optional<texture_name_t> checkIfTextureAlreadyExists(const mrpt::img::CImage& rgb)
174+
{
175+
return TextureResourceHandler::Instance().checkIfTextureAlreadyExists(rgb);
176+
}
177+
137178
/// Returns: [texture name, texture unit]
138-
texture_name_t mrpt::opengl::getNewTextureNumber()
179+
texture_name_t mrpt::opengl::getNewTextureNumber(const uint8_t* optionalRgbDataForAssociation)
139180
{
140-
return TextureResourceHandler::Instance().generateTextureID();
181+
return TextureResourceHandler::Instance().generateTextureID(optionalRgbDataForAssociation);
141182
}
142183

143184
void mrpt::opengl::releaseTextureName(const texture_name_t& t)
@@ -247,6 +288,21 @@ void Texture::internalAssignImage_2D(
247288
in_rgb->forceLoad(); // just in case they are lazy-load imgs
248289
if (in_alpha) in_alpha->forceLoad();
249290

291+
// Check if we already have this texture loaded in GPU and avoid creating
292+
// duplicated texture ID:
293+
const auto existingTextureId = checkIfTextureAlreadyExists(*in_rgb);
294+
if (existingTextureId.has_value())
295+
{
296+
get() = existingTextureId.value();
297+
get()->unit = textureUnit;
298+
299+
if (MRPT_OPENGL_VERBOSE)
300+
std::cout << "[mrpt internalAssignImage_2D] Reusing existing textureName:" << get()->name
301+
<< "\n";
302+
303+
return;
304+
}
305+
250306
mrpt::img::CImage rgb;
251307

252308
switch (in_rgb->getPixelDepth())
@@ -290,7 +346,7 @@ void Texture::internalAssignImage_2D(
290346
if (in_alpha) alpha = mrpt::img::CImage(*in_alpha, mrpt::img::SHALLOW_COPY);
291347

292348
// allocate texture names:
293-
get() = getNewTextureNumber();
349+
get() = getNewTextureNumber(in_rgb->asCvMatRef().data);
294350
get()->unit = textureUnit;
295351

296352
// activate the texture unit first before binding texture
@@ -536,7 +592,7 @@ void Texture::assignCubeImages(const std::array<mrpt::img::CImage, 6>& imgs, int
536592
}
537593

538594
// allocate texture "name" (ID):
539-
get() = getNewTextureNumber();
595+
get() = getNewTextureNumber(nullptr); /* no cached img for cube textures */
540596

541597
// activate the texture unit first before binding texture
542598
bindAsCubeTexture();

libs/slam/CMakeLists.txt

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@ list(APPEND slam_EXTRA_SRCS_NAME
1111
"slam" "slam" "slam-headers")
1212

1313
if(CMAKE_MRPT_HAS_TBB)
14-
set(tbb_dep TBB)
15-
else()
16-
set(tbb_dep "")
14+
set(EXTRA_CONFIG_CMDS
15+
"find_dependency(TBB CONFIG)")
1716
endif()
1817

1918
#---------------------------------------------
@@ -25,8 +24,6 @@ define_mrpt_lib(
2524
# Dependencies
2625
mrpt-vision
2726
mrpt-maps
28-
# Other imported targets:
29-
${tbb_dep} # find_package() lib name
3027
)
3128

3229
if(BUILD_mrpt-slam)

parse-files/mrpt-xxx-config.cmake.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ if(NOT "${CMAKE_CURRENT_LIST_DIR}/../" IN_LIST CMAKE_PREFIX_PATH)
3434
endif()
3535
cmake_policy(POP)
3636

37+
# Prefer config instead of the old FindXXX() files
38+
set(_BCK_CMAKE_FIND_PACKAGE_PREFER_CONFIG ${CMAKE_FIND_PACKAGE_PREFER_CONFIG})
39+
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG TRUE)
40+
3741
# Search for dependencies first:
3842
set(_deps "@ALL_DEPS_LIST@")
3943
foreach(_dep ${_deps}) # NO quotes for the list to be a CMake list!
@@ -47,5 +51,9 @@ foreach(_dep ${_deps}) # NO quotes for the list to be a CMake list!
4751
endforeach()
4852
@EXTRA_CONFIG_CMDS@
4953

54+
# Restore user's settings:
55+
set(CMAKE_FIND_PACKAGE_PREFER_CONFIG ${_BCK_CMAKE_FIND_PACKAGE_PREFER_CONFIG})
56+
unset(_BCK_CMAKE_FIND_PACKAGE_PREFER_CONFIG)
57+
5058
# Include targets for this library:
5159
include(${CMAKE_CURRENT_LIST_DIR}/mrpt-@[email protected])

python/src/mrpt/math/TBoundingBox.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void bind_mrpt_math_TBoundingBox(std::function< pybind11::module &(std::string c
4444
cl.def( pybind11::init( [](mrpt::math::TBoundingBox_<double> const &o){ return new mrpt::math::TBoundingBox_<double>(o); } ) );
4545

4646
pybind11::enum_<mrpt::math::TBoundingBox_<double>::CTOR_FLAGS>(cl, "CTOR_FLAGS", "")
47-
.value("None", mrpt::math::TBoundingBox_<double>::CTOR_FLAGS::None)
47+
.value("NoFlags", mrpt::math::TBoundingBox_<double>::CTOR_FLAGS::NoFlags)
4848
.value("AllowUnordered", mrpt::math::TBoundingBox_<double>::CTOR_FLAGS::AllowUnordered);
4949

5050
cl.def_readwrite("min", &mrpt::math::TBoundingBox_<double>::min);
@@ -70,7 +70,7 @@ void bind_mrpt_math_TBoundingBox(std::function< pybind11::module &(std::string c
7070
cl.def( pybind11::init( [](mrpt::math::TBoundingBox_<float> const &o){ return new mrpt::math::TBoundingBox_<float>(o); } ) );
7171

7272
pybind11::enum_<mrpt::math::TBoundingBox_<float>::CTOR_FLAGS>(cl, "CTOR_FLAGS", "")
73-
.value("None", mrpt::math::TBoundingBox_<float>::CTOR_FLAGS::None)
73+
.value("NoFlags", mrpt::math::TBoundingBox_<float>::CTOR_FLAGS::NoFlags)
7474
.value("AllowUnordered", mrpt::math::TBoundingBox_<float>::CTOR_FLAGS::AllowUnordered);
7575

7676
cl.def_readwrite("min", &mrpt::math::TBoundingBox_<float>::min);

0 commit comments

Comments
 (0)