diff --git a/source/RobotAPI/components/ArViz/ArVizStorage.cpp b/source/RobotAPI/components/ArViz/ArVizStorage.cpp index 3f4ff4644d9bd11068fd86c55820bbce98d19ebb..b02566aa0631e0f67d022adce17374fc57e5b0f9 100644 --- a/source/RobotAPI/components/ArViz/ArVizStorage.cpp +++ b/source/RobotAPI/components/ArViz/ArVizStorage.cpp @@ -482,6 +482,11 @@ void armarx::ArVizStorage::recordBatch(armarx::viz::data::RecordingBatch& batch) batch.header.lastRevision = last.revision; batch.header.firstTimestampInMicroSeconds = first.timestampInMicroseconds; batch.header.lastTimestampInMicroSeconds = last.timestampInMicroseconds; + if(firstBatch) { + batch.initialState = currentState; + firstBatch = false; + } + std::string filename = batchFileName(batch.header); std::filesystem::path filePath = recordingPath / filename; @@ -571,6 +576,7 @@ std::string armarx::ArVizStorage::startRecording(std::string const& newRecording recordingMetaData.batchHeaders.clear(); } + firstBatch = true; recordingTask = new RunningTask<ArVizStorage>(this, &ArVizStorage::record); recordingTask->start(); @@ -640,7 +646,7 @@ armarx::viz::data::RecordingBatch armarx::ArVizStorage::getRecordingBatch(std::s return result; } - if (batchIndex < 0 && batchIndex >= (long)recording->batchHeaders.size()) + if (batchIndex < 0 || batchIndex >= (long)recording->batchHeaders.size()) { ARMARX_WARNING << "Batch index is not valid. Index = " << batchIndex << "Batch count: " << recording->batchHeaders.size(); diff --git a/source/RobotAPI/components/ArViz/ArVizStorage.h b/source/RobotAPI/components/ArViz/ArVizStorage.h index 27bb6b1fcf130e23844c497a8a2a85cc1b392943..36d4d85564f5817d042b7607c11295cd527e2d69 100644 --- a/source/RobotAPI/components/ArViz/ArVizStorage.h +++ b/source/RobotAPI/components/ArViz/ArVizStorage.h @@ -110,6 +110,7 @@ namespace armarx std::vector<viz::data::TimestampedLayerUpdate> currentState; std::vector<viz::data::TimestampedLayerUpdate> history; long revision = 0; + bool firstBatch = false; // We store all interactions in here // But we curate them, so that only the last interaction with an element is reported