fixed double compression of user_data

This commit is contained in:
matlabbe
2026-09-26 14:03:35 -07:00
parent 49108d9f80
commit e107b6bc8e
4 changed files with 52 additions and 6 deletions
+8 -4
View File
@@ -3167,11 +3167,11 @@ TEST(MemoryTest, UpdateKeepsUserDataThatArrivesCompressed)
}
}
TEST(MemoryTest, UpdateReusesTheGivenCompressedScanUnlessItFiltersIt)
TEST(MemoryTest, UpdateReusesTheGivenCompressedData)
{
// A scan given both raw and compressed is not compressed again: the compressed copy
// given is stored as is, sharing its buffer -- but only while Memory has not filtered
// the scan, since a filtered scan no longer matches the compressed one given.
// Data given both raw and compressed is not compressed again: the compressed copy
// given is stored as is, sharing its buffer. For the scan, only while Memory has not
// filtered it, since a filtered scan no longer matches the compressed one given.
cv::Mat points(1, 10, CV_32FC3);
for(int i = 0; i < points.cols; ++i)
{
@@ -3196,6 +3196,8 @@ TEST(MemoryTest, UpdateReusesTheGivenCompressedScanUnlessItFiltersIt)
const LaserScan compressedScan(compressData2(points), points.cols, 10.0f, LaserScan::kXYZ);
data.setLaserScan(compressedScan);
data.setLaserScan(LaserScan(points, points.cols, 10.0f, LaserScan::kXYZ), false);
data.setUserData(points.t()); // raw, several rows: compressed by setUserData()
ASSERT_FALSE(data.userDataCompressed().empty());
ASSERT_FALSE(data.laserScanRaw().isEmpty());
ASSERT_FALSE(data.laserScanCompressed().isEmpty());
@@ -3203,6 +3205,8 @@ TEST(MemoryTest, UpdateReusesTheGivenCompressedScanUnlessItFiltersIt)
const Signature * s = memory.getSignature(memory.getLastSignatureId());
ASSERT_NE(s, nullptr);
EXPECT_EQ(s->sensorData().userDataCompressed().data, data.userDataCompressed().data);
const LaserScan & stored = s->sensorData().laserScanCompressed();
ASSERT_FALSE(stored.isEmpty());
if(std::string(downsample) == "1")