Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • sw/armarx/robot-api
  • uwkce_singer/robot-api
  • untcg_hofmann/robot-api
  • ulqba_korosakov/RobotAPI
4 results
Show changes
Showing
with 76 additions and 56 deletions
......@@ -12,7 +12,7 @@
namespace armarx::armem::server::ltm::disk
{
EntitySnapshot::EntitySnapshot(const std::filesystem::path& p, const MemoryID& id, const std::shared_ptr<Processors>& filters, const DiskMemoryItem::MemoryEncodingMode mode, const unsigned long e) :
EntitySnapshot::EntitySnapshot(const std::filesystem::path& p, const MemoryID& id /* UNESCAPED */, const std::shared_ptr<Processors>& filters, const DiskMemoryItem::MemoryEncodingMode mode, const unsigned long e) :
EntitySnapshotBase(id, filters),
DiskMemoryItem(p, EscapeSegmentName(id.memoryName),
std::filesystem::path(EscapeSegmentName(id.coreSegmentName))
......@@ -29,6 +29,7 @@ namespace armarx::armem::server::ltm::disk
{
auto mPath = getMemoryBasePathForMode(currentMode, currentExport);
auto relPath = getRelativePathForMode(currentMode);
if (!util::checkIfBasePathExists(mPath) || !util::checkIfFolderExists(mPath, relPath))
{
return;
......@@ -82,10 +83,10 @@ namespace armarx::armem::server::ltm::disk
{
//ARMARX_INFO << "Convert data for entity " << id();
auto datafilecontent = util::readDataFromFile(mPath, relDataPath);
auto dataaron = dictConverter.convert(datafilecontent, "");
auto dataaron = dictConverter.convert(datafilecontent, {}, "");
datadict = aron::data::Dict::DynamicCastAndCheck(dataaron);
// check for special members
// check for special members TODO: only allowed for direct children?
for (const auto& [key, m] : datadict->getElements())
{
for (auto& [t, f] : processors->converters)
......@@ -98,7 +99,7 @@ namespace armarx::armem::server::ltm::disk
std::string mode = simox::alg::remove_suffix(simox::alg::remove_prefix(filename, key), f->suffix);
auto memberfilecontent = util::readDataFromFile(mPath, relMemberPath);
auto memberaron = f->convert(memberfilecontent, mode);
auto memberaron = f->convert(memberfilecontent, armarx::aron::Path(datadict->getPath(), std::vector<std::string>{key}), mode);
datadict->setElement(key, memberaron);
break;
}
......@@ -115,7 +116,7 @@ namespace armarx::armem::server::ltm::disk
if (std::find(allFilesInIndexFolder.begin(), allFilesInIndexFolder.end(), metadataFilename) != allFilesInIndexFolder.end())
{
auto metadatafilecontent = util::readDataFromFile(mPath, relMetadataPath);
auto metadataaron = dictConverter.convert(metadatafilecontent, "");
auto metadataaron = dictConverter.convert(metadatafilecontent, {}, "");
metadatadict = aron::data::Dict::DynamicCastAndCheck(metadataaron);
}
else
......
......@@ -71,6 +71,7 @@ namespace armarx::armem::server::ltm::disk
{
MemoryEncodingMode mode = i == 0 ? MemoryEncodingMode::FILESYSTEM : defaultExportEncodingMode;
auto mPath = getMemoryBasePathForMode(mode, i);
if (util::checkIfBasePathExists(mPath))
{
for (const auto& subdirName : util::getAllDirectories(mPath, getRelativePathForMode(mode)))
......
......@@ -10,7 +10,7 @@
namespace armarx::armem::server::ltm::disk
{
ProviderSegment::ProviderSegment(const std::filesystem::path& p, const MemoryID& id, const std::shared_ptr<Processors>& filters, const DiskMemoryItem::MemoryEncodingMode mode, const unsigned long e) :
ProviderSegment::ProviderSegment(const std::filesystem::path& p, const MemoryID& id /* UNESCAPED */, const std::shared_ptr<Processors>& filters, const DiskMemoryItem::MemoryEncodingMode mode, const unsigned long e) :
ProviderSegmentBase(id, filters),
DiskMemoryItem(p, EscapeSegmentName(id.memoryName), std::filesystem::path(EscapeSegmentName(id.coreSegmentName)) / EscapeSegmentName(id.providerSegmentName)),
currentMode(mode),
......@@ -22,6 +22,7 @@ namespace armarx::armem::server::ltm::disk
{
auto mPath = getMemoryBasePathForMode(currentMode, currentExport);
auto relPath = getRelativePathForMode(currentMode);
if (!util::checkIfBasePathExists(mPath) || !util::checkIfFolderExists(mPath, relPath))
{
return false;
......@@ -30,7 +31,7 @@ namespace armarx::armem::server::ltm::disk
for (const auto& subdirName : util::getAllDirectories(mPath, relPath))
{
std::string segmentName = UnescapeSegmentName(subdirName);
Entity c(memoryParentPath, id().withEntityName(subdirName), processors, currentMode, currentExport);
Entity c(memoryParentPath, id().withEntityName(segmentName), processors, currentMode, currentExport);
func(c);
}
return true;
......
......@@ -2,6 +2,8 @@
#include "../../base/EntityQueryProcessorBase.h"
#include <ArmarXCore/core/logging/Logging.h>
namespace armarx::armem::server::query_proc::ltm::detail
{
......@@ -27,6 +29,7 @@ namespace armarx::armem::server::query_proc::ltm::detail
protected:
// default addResultSnapshot method. Always copies the data
void addResultSnapshot(ResultEntityT& result, const EntitySnapshotT& snapshot) const override
{
ResultSnapshotT s;
......
......@@ -2,6 +2,7 @@
#include "../../base/EntityQueryProcessorBase.h"
#include <ArmarXCore/core/logging/Logging.h>
namespace armarx::armem::server::query_proc::wm::detail
{
......@@ -32,7 +33,12 @@ namespace armarx::armem::server::query_proc::wm::detail
protected:
void addResultSnapshot(ResultEntityT& result, const EntitySnapshotT& snapshot) const override
{
result.addSnapshot(snapshot);
snapshot.forEachInstance([](const typename EntitySnapshotT::EntityInstanceT& instance)
{
instance.metadata().access();
});
EntitySnapshotT copy = snapshot;
result.addSnapshot(std::move(copy));
}
};
}
......@@ -53,15 +53,21 @@ namespace armarx::armem::server::query_proc::wm::detail
bool withData = (dataMode == armem::query::DataMode::WithData);
if (withData)
{
result.addSnapshot(server::wm::EntitySnapshot{ snapshot });
Base::addResultSnapshot(result, snapshot);
}
else
{
// 1. access real data
snapshot.forEachInstance([](const server::wm::EntityInstance& i)
{
i.metadata().access();
});
// 2. create copy and remove data from copy
server::wm::EntitySnapshot copy = snapshot;
copy.forEachInstance([](server::wm::EntityInstance & i)
{
i.data() = nullptr;
return true;
});
result.addSnapshot(std::move(copy));
}
......
......@@ -123,7 +123,7 @@ namespace ArMemLTMTest
}
update.entityID = armem::MemoryID::fromString(memoryName + "/TestCoreSegment/TestProvider/TestEntity");
update.instancesData = q;
update.timeCreated = armem::Time::Now();
update.referencedTime = armem::Time::Now();
BOOST_CHECK_NO_THROW(providerSegment.update(update));
BOOST_CHECK_EQUAL(providerSegment.size(), 1);
}
......
......@@ -653,7 +653,7 @@ struct CopyMoveCtorsOpsTest : public CopyMoveCtorsOpsTestBase
{
armem::EntityUpdate update;
update.entityID = armem::MemoryID("M", "C", "P", "E", armem::Time(armem::Duration::MicroSeconds(123000)), 0);
update.timeCreated = update.entityID.timestamp;
update.referencedTime = update.entityID.timestamp;
update.instancesData.emplace_back();
in.update(update);
}
......@@ -814,7 +814,7 @@ BOOST_AUTO_TEST_CASE(test_segment_setup)
std::make_shared<aron::data::Dict>(),
std::make_shared<aron::data::Dict>()
};
update.timeCreated = armem::Time(armem::Duration::MilliSeconds(1000));
update.referencedTime = armem::Time(armem::Duration::MilliSeconds(1000));
BOOST_CHECK_NO_THROW(providerSegment.update(update));
BOOST_CHECK_EQUAL(providerSegment.size(), 1);
......@@ -824,25 +824,25 @@ BOOST_AUTO_TEST_CASE(test_segment_setup)
wm::Entity& entity = providerSegment.getEntity("image");
BOOST_CHECK_EQUAL(entity.name(), "image");
BOOST_CHECK_EQUAL(entity.size(), 1);
BOOST_CHECK(entity.hasSnapshot(update.timeCreated));
BOOST_CHECK(entity.hasSnapshot(update.referencedTime));
wm::EntitySnapshot& entitySnapshot = entity.getSnapshot(update.timeCreated);
wm::EntitySnapshot& entitySnapshot = entity.getSnapshot(update.referencedTime);
BOOST_CHECK_EQUAL(entitySnapshot.size(), update.instancesData.size());
// Another update (on memory).
update.instancesData = { std::make_shared<aron::data::Dict>() };
update.timeCreated = armem::Time(armem::Duration::MilliSeconds(2000));
update.referencedTime = armem::Time(armem::Duration::MilliSeconds(2000));
memory.update(update);
BOOST_CHECK_EQUAL(entity.size(), 2);
BOOST_CHECK(entity.hasSnapshot(update.timeCreated));
BOOST_CHECK_EQUAL(entity.getSnapshot(update.timeCreated).size(), update.instancesData.size());
BOOST_CHECK(entity.hasSnapshot(update.referencedTime));
BOOST_CHECK_EQUAL(entity.getSnapshot(update.referencedTime).size(), update.instancesData.size());
// A third update (on entity).
update.instancesData = { std::make_shared<aron::data::Dict>() };
update.timeCreated = armem::Time(armem::Duration::MilliSeconds(3000));
update.referencedTime = armem::Time(armem::Duration::MilliSeconds(3000));
entity.update(update);
BOOST_CHECK_EQUAL(entity.size(), 3);
......@@ -858,11 +858,11 @@ BOOST_AUTO_TEST_CASE(test_history_size_in_entity)
update.entityID.entityName = entity.name();
// With unlimited history.
update.timeCreated = armem::Time(armem::Duration::MilliSeconds(1000));
update.referencedTime = armem::Time(armem::Duration::MilliSeconds(1000));
entity.update(update);
update.timeCreated = armem::Time(armem::Duration::MilliSeconds(2000));
update.referencedTime = armem::Time(armem::Duration::MilliSeconds(2000));
entity.update(update);
update.timeCreated = armem::Time(armem::Duration::MilliSeconds(3000));
update.referencedTime = armem::Time(armem::Duration::MilliSeconds(3000));
entity.update(update);
BOOST_CHECK_EQUAL(entity.size(), 3);
......@@ -874,7 +874,7 @@ BOOST_AUTO_TEST_CASE(test_history_size_in_entity)
BOOST_CHECK(entity.hasSnapshot(armem::Time(armem::Duration::MilliSeconds(3000))));
update.timeCreated = armem::Time(armem::Duration::MilliSeconds(4000));
update.referencedTime = armem::Time(armem::Duration::MilliSeconds(4000));
entity.update(update);
BOOST_CHECK_EQUAL(entity.size(), 2);
BOOST_CHECK(not entity.hasSnapshot(armem::Time(armem::Duration::MilliSeconds(2000))));
......@@ -884,7 +884,7 @@ BOOST_AUTO_TEST_CASE(test_history_size_in_entity)
// Disable maximum history size.
entity.setMaxHistorySize(-1);
update.timeCreated = armem::Time(armem::Duration::MilliSeconds(5000));
update.referencedTime = armem::Time(armem::Duration::MilliSeconds(5000));
entity.update(update);
BOOST_CHECK_EQUAL(entity.size(), 3);
BOOST_CHECK(entity.hasSnapshot(armem::Time(armem::Duration::MilliSeconds(3000))));
......@@ -907,15 +907,15 @@ BOOST_AUTO_TEST_CASE(test_history_size_in_provider_segment)
{
update.entityID.entityName = name;
update.timeCreated = armem::Time(armem::Duration::MilliSeconds(1000));
update.referencedTime = armem::Time(armem::Duration::MilliSeconds(1000));
providerSegment.update(update);
update.timeCreated = armem::Time(armem::Duration::MilliSeconds(2000));
update.referencedTime = armem::Time(armem::Duration::MilliSeconds(2000));
providerSegment.update(update);
update.timeCreated = armem::Time(armem::Duration::MilliSeconds(3000));
update.referencedTime = armem::Time(armem::Duration::MilliSeconds(3000));
providerSegment.update(update);
}
update.entityID.entityName = entityNames.back();
update.timeCreated = armem::Time(armem::Duration::MilliSeconds(4000));
update.referencedTime = armem::Time(armem::Duration::MilliSeconds(4000));
providerSegment.update(update);
BOOST_CHECK_EQUAL(providerSegment.getEntity("A").size(), 3);
......@@ -939,11 +939,11 @@ BOOST_AUTO_TEST_CASE(test_history_size_in_provider_segment)
providerSegment.setMaxHistorySize(2);
update.entityID.entityName = "C";
update.timeCreated = armem::Time(armem::Duration::MilliSeconds(1000));
update.referencedTime = armem::Time(armem::Duration::MilliSeconds(1000));
providerSegment.update(update);
update.timeCreated = armem::Time(armem::Duration::MilliSeconds(2000));
update.referencedTime = armem::Time(armem::Duration::MilliSeconds(2000));
providerSegment.update(update);
update.timeCreated = armem::Time(armem::Duration::MilliSeconds(3000));
update.referencedTime = armem::Time(armem::Duration::MilliSeconds(3000));
providerSegment.update(update);
// Check correctly inherited history size.
......@@ -958,7 +958,7 @@ BOOST_AUTO_TEST_CASE(test_history_size_in_provider_segment)
for (const std::string& name : entityNames)
{
update.entityID.entityName = name;
update.timeCreated = armem::Time(armem::Duration::MilliSeconds(5000));
update.referencedTime = armem::Time(armem::Duration::MilliSeconds(5000));
providerSegment.update(update);
BOOST_CHECK_EQUAL(providerSegment.getEntity(name).getMaxHistorySize(), -1);
BOOST_CHECK_EQUAL(providerSegment.getEntity(name).size(), 3);
......
......@@ -75,7 +75,7 @@ BOOST_AUTO_TEST_CASE(test_forEach)
EntityUpdate update;
update.entityID = eid;
update.timeCreated = sid.timestamp;
update.referencedTime = sid.timestamp;
for (size_t i = 0; i <= s; ++i)
{
const MemoryID iid = sid.withInstanceIndex(int(i));
......
......@@ -127,7 +127,7 @@ namespace armarx::armem::grasping::segment
{
EntityUpdate& update = commit.add();
update.entityID = providerID.withEntityName(info.id().str());
update.entityID.timestamp = update.timeArrived = update.timeCreated = update.timeSent = now;
update.entityID.timestamp = update.arrivedTime = update.referencedTime = update.sentTime = now;
update.instancesData =
{
......
......@@ -391,7 +391,7 @@ namespace armarx::armem::gui
entityUpdate.entityID = memId;
entityUpdate.confidence = 1.0;
entityUpdate.instancesData = {aron};
entityUpdate.timeCreated = now;
entityUpdate.referencedTime = now;
it->second.commit(comm);
}
}
......
......@@ -50,6 +50,7 @@ namespace armarx::armem::gui::instance
treeItemMetadata->addChild(new QTreeWidgetItem({"Time Created"}));
treeItemMetadata->addChild(new QTreeWidgetItem({"Time Sent"}));
treeItemMetadata->addChild(new QTreeWidgetItem({"Time Arrived"}));
treeItemMetadata->addChild(new QTreeWidgetItem({"Time Last Accessed"}));
QList<QTreeWidgetItem*> items = {treeItemInstanceID, treeItemMetadata};
tree->insertTopLevelItems(0, items);
......@@ -110,9 +111,10 @@ namespace armarx::armem::gui::instance
std::vector<std::string> items =
{
std::to_string(metadata.confidence),
armem::toDateTimeMilliSeconds(metadata.timeCreated),
armem::toDateTimeMilliSeconds(metadata.timeSent),
armem::toDateTimeMilliSeconds(metadata.timeArrived)
armem::toDateTimeMilliSeconds(metadata.referencedTime),
armem::toDateTimeMilliSeconds(metadata.sentTime),
armem::toDateTimeMilliSeconds(metadata.arrivedTime),
armem::toDateTimeMilliSeconds(metadata.lastAccessedTime) + " (" + std::to_string(metadata.numAccessed) + " times total)"
};
ARMARX_CHECK_EQUAL(static_cast<size_t>(treeItemMetadata->childCount()), items.size());
int i = 0;
......
......@@ -83,7 +83,7 @@ namespace armarx::armem::laser_scans::client
dict->addElement("scan", toAron(laserScan));
update.instancesData = {dict};
update.timeCreated = timestamp;
update.referencedTime = timestamp;
ARMARX_DEBUG << "Committing " << update << " at time " << timestamp;
armem::EntityUpdateResult updateResult = memoryWriter.commit(update);
......
......@@ -76,9 +76,9 @@ namespace armarx::armem::server::motions::mdb::segment
auto& snapshot = entity.addSnapshot(op->createdDate);
armem::wm::EntityInstance& instance = snapshot.addInstance();
instance.metadata().timeCreated = op->createdDate;
instance.metadata().timeSent = Time::Now();
instance.metadata().timeArrived = Time::Now();
instance.metadata().referencedTime = op->createdDate;
instance.metadata().sentTime = Time::Now();
instance.metadata().arrivedTime = Time::Now();
instance.metadata().confidence = 1.0;
instance.data() = op->toAron();
}
......
......@@ -87,9 +87,9 @@ namespace armarx::armem::server::motions::mps::segment
ss << "Found valid instance at: " << pathToInfoJson << ". The motionID is: ";
armem::wm::EntityInstance instance;
instance.metadata().timeCreated = armem::Time::Now(); //op->createdDate;
instance.metadata().timeSent = armem::Time::Now();
instance.metadata().timeArrived = armem::Time::Now();
instance.metadata().referencedTime = armem::Time::Now(); //op->createdDate;
instance.metadata().sentTime = armem::Time::Now();
instance.metadata().arrivedTime = armem::Time::Now();
instance.metadata().confidence = 1.0;
if(taskspace)
......
......@@ -154,7 +154,7 @@ namespace armarx::armem::articulated_object
toAron(aronArticulatedObjectDescription, obj.description);
update.instancesData = {aronArticulatedObjectDescription.toAron()};
update.timeCreated = timestamp;
update.referencedTime = timestamp;
ARMARX_DEBUG << "Committing " << update << " at time " << timestamp;
armem::EntityUpdateResult updateResult = memoryWriter.commit(update);
......@@ -233,7 +233,7 @@ namespace armarx::armem::articulated_object
objectInstance.pose.objectID = cs;
update.instancesData = {objectInstance.toAron()};
update.timeCreated = timestamp;
update.referencedTime = timestamp;
ARMARX_DEBUG << "Committing " << update << " at time " << timestamp;
armem::EntityUpdateResult updateResult = memoryWriter.commit(update);
......
......@@ -82,7 +82,7 @@ namespace armarx::armem::attachment
toAron(aronAttachment, attachment);
update.instancesData = {aronAttachment.toAron()};
update.timeCreated = timestamp;
update.referencedTime = timestamp;
ARMARX_DEBUG << "Committing " << update << " at time " << timestamp;
armem::EntityUpdateResult updateResult = memoryWriter.commit(update);
......@@ -126,7 +126,7 @@ namespace armarx::armem::attachment
toAron(aronAttachment, attachment);
update.instancesData = {aronAttachment.toAron()};
update.timeCreated = timestamp;
update.referencedTime = timestamp;
ARMARX_DEBUG << "Committing " << update << " at time " << timestamp;
armem::EntityUpdateResult updateResult = memoryWriter.commit(update);
......
......@@ -64,8 +64,8 @@ namespace armarx::armem::obj::instance
e.entityID.coreSegmentName = properties.coreSegmentName;
e.entityID.providerSegmentName = provider;
e.entityID.entityName = inst.pose.objectID.dataset + "/" + inst.pose.objectID.className + "/" + inst.pose.objectID.instanceName;
e.timeCreated = t;
e.timeSent = armem::Time::Now();
e.referencedTime = t;
e.sentTime = armem::Time::Now();
e.instancesData = { inst.toAron() };
auto res = memoryWriter.commit(c);
......
......@@ -95,7 +95,7 @@ namespace armarx::armem::server::obj::clazz
EntityUpdate& update = commit.add();
update.entityID = providerID.withEntityName(info.id().str());
update.timeArrived = update.timeCreated = update.timeSent = now;
update.arrivedTime = update.referencedTime = update.sentTime = now;
arondto::ObjectClass objectClass = objectClassFromInfo(info);
update.instancesData =
......
......@@ -335,8 +335,8 @@ namespace armarx::armem::server::obj::instance
providerName.empty() ? pose.providerName : providerName);
update.entityID = providerID.withEntityName(pose.objectID.str());
update.timeArrived = now;
update.timeCreated = pose.timestamp;
update.arrivedTime = now;
update.referencedTime = pose.timestamp;
update.confidence = pose.confidence;
arondto::ObjectInstance dto;
......@@ -781,7 +781,7 @@ namespace armarx::armem::server::obj::instance
armem::Commit commit;
armem::EntityUpdate & update = commit.add();
update.entityID = objectEntity->id();
update.timeCreated = now;
update.referencedTime = now;
{
arondto::ObjectInstance updated = data;
toAron(updated.pose.attachment, info);
......@@ -889,7 +889,7 @@ namespace armarx::armem::server::obj::instance
armem::Commit commit;
armem::EntityUpdate & update = commit.add();
update.entityID = entity.id();
update.timeCreated = now;
update.referencedTime = now;
{
arondto::ObjectInstance updated;
if (commitAttachedPose and data.pose.attachmentValid)
......