Skip to content
Snippets Groups Projects
Commit b699f510 authored by Timo Birr's avatar Timo Birr :rage:
Browse files

Merge branch 'master' of git.h2t.iar.kit.edu:sw/armarx/robot-api

parents 60cc7e21 a2dee547
No related branches found
No related tags found
No related merge requests found
Pipeline #21595 failed
...@@ -36,10 +36,10 @@ namespace armarx::armem::obj::clazz ...@@ -36,10 +36,10 @@ namespace armarx::armem::obj::clazz
{ {
armem::client::query::Builder builder; armem::client::query::Builder builder;
auto& entities = builder.coreSegments() auto& entities = builder.coreSegments()
.withName(properties().coreSegmentName) .withName(properties().coreSegmentName)
.providerSegments() .providerSegments()
.all() .all()
.entities(); .entities();
for (const ObjectID& objectID : objectIDs) for (const ObjectID& objectID : objectIDs)
{ {
...@@ -67,6 +67,40 @@ namespace armarx::armem::obj::clazz ...@@ -67,6 +67,40 @@ namespace armarx::armem::obj::clazz
return objectClasses; return objectClasses;
} }
std::map<ObjectID, armem::clazz::ObjectClass>
ClassReader::getAllObjectClasses()
{
armem::client::query::Builder builder;
// clang-format off
builder
.coreSegments().withName(properties().coreSegmentName)
.providerSegments().all()
.entities().all()
.snapshots().latest();
// clang-format on
const armem::client::QueryResult result = memoryReader().query(builder);
if (not result.success)
{
throw armem::error::QueryFailed(result.errorMessage);
}
std::map<ObjectID, armem::clazz::ObjectClass> objectClasses;
result.memory.forEachInstance(
[&objectClasses](const armem::wm::EntityInstance& instance) -> bool
{
const ObjectID classID = ObjectID::FromString(instance.id().entityName);
auto aron = instance.dataAs<armarx::armem::arondto::ObjectClass>();
armarx::armem::clazz::fromAron(aron, objectClasses[classID]);
return true;
});
return objectClasses;
}
std::string std::string
ClassReader::propertyPrefix() const ClassReader::propertyPrefix() const
{ {
......
...@@ -46,6 +46,8 @@ namespace armarx::armem::obj::clazz ...@@ -46,6 +46,8 @@ namespace armarx::armem::obj::clazz
std::map<armarx::ObjectID, armem::clazz::ObjectClass> std::map<armarx::ObjectID, armem::clazz::ObjectClass>
getObjectClasses(const std::vector<armarx::ObjectID>& objectIDs); getObjectClasses(const std::vector<armarx::ObjectID>& objectIDs);
std::map<armarx::ObjectID, armem::clazz::ObjectClass> getAllObjectClasses();
protected: protected:
std::string propertyPrefix() const final; std::string propertyPrefix() const final;
Properties defaultProperties() const final; Properties defaultProperties() const final;
......
...@@ -10,6 +10,7 @@ ...@@ -10,6 +10,7 @@
#include <ArmarXCore/core/exceptions/local/ExpressionException.h> #include <ArmarXCore/core/exceptions/local/ExpressionException.h>
#include <ArmarXCore/core/logging/Logging.h> #include <ArmarXCore/core/logging/Logging.h>
#include <ArmarXCore/core/time/Clock.h> #include <ArmarXCore/core/time/Clock.h>
#include <ArmarXCore/core/time/Duration.h>
#include "RobotAPI/libraries/armem_robot_state/client/common/constants.h" #include "RobotAPI/libraries/armem_robot_state/client/common/constants.h"
#include "RobotAPI/libraries/armem_robot_state/common/localization/types.h" #include "RobotAPI/libraries/armem_robot_state/common/localization/types.h"
...@@ -49,11 +50,14 @@ namespace armarx::armem::robot_state ...@@ -49,11 +50,14 @@ namespace armarx::armem::robot_state
{ {
transformReader.connect(memoryNameSystem); transformReader.connect(memoryNameSystem);
armarx::Clock::WaitFor(armarx::Duration::MilliSeconds(200));
// Wait for the memory to become available and add it as dependency. // Wait for the memory to become available and add it as dependency.
ARMARX_INFO << "RobotReader: Waiting for memory '" << constants::memoryName << "' ..."; ARMARX_INFO << "RobotReader: Waiting for memory '" << constants::memoryName << "' ...";
try try
{ {
memoryReader = memoryNameSystem.useReader(constants::memoryName); // memoryReader = memoryNameSystem.useReader(constants::memoryName);
memoryReader = transformReader.getMemoryReader();
ARMARX_INFO << "RobotReader: Connected to memory '" << constants::memoryName << "'"; ARMARX_INFO << "RobotReader: Connected to memory '" << constants::memoryName << "'";
} }
catch (const armem::error::CouldNotResolveMemoryServer& e) catch (const armem::error::CouldNotResolveMemoryServer& e)
......
...@@ -58,6 +58,8 @@ namespace armarx::armem::robot_state::client::localization ...@@ -58,6 +58,8 @@ namespace armarx::armem::robot_state::client::localization
void registerPropertyDefinitions(::armarx::PropertyDefinitionsPtr& def) override; void registerPropertyDefinitions(::armarx::PropertyDefinitionsPtr& def) override;
armem::client::Reader getMemoryReader(){return memoryReader;}
private: private:
armem::client::Reader memoryReader; armem::client::Reader memoryReader;
mutable std::mutex memoryReaderMutex; mutable std::mutex memoryReaderMutex;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment