Skip to content
Snippets Groups Projects
Commit f5506e56 authored by Fabian Tërnava's avatar Fabian Tërnava
Browse files

add andres fix for the object instance reader

parent 950e3b2f
No related branches found
No related tags found
1 merge request!476update list of servers whenever the mns reconnects
Pipeline #20939 passed
......@@ -26,25 +26,34 @@ namespace armarx::armem::obj::instance
{
const std::string prefix = propertyPrefix;
def->optional(p.memoryName, prefix + "MemoryName");
def->optional(properties.memoryName, prefix + "MemoryName");
}
void
Reader::connect(armem::client::MemoryNameSystem& memoryNameSystem)
{
// Wait for the memory to become available and add it as dependency.
ARMARX_IMPORTANT << "Waiting for memory '" << p.memoryName << "' ...";
ARMARX_IMPORTANT << "Waiting for memory '" << properties.memoryName << "' ...";
try
{
// simply wait until memory is ready. Do nothing with reader but get prx
auto r = memoryNameSystem.useReader(p.memoryName);
auto r = memoryNameSystem.useReader(properties.memoryName);
// cast MemoryPrx to objPoseStoragePrx --> NOT WORKING DUE TO SOME ICE CACHING OR SO.
// Explanation:
// When the readingPrx disconnects and reconnects, the cast fails as it uses internally
// a ice_isA call which results in connection refused. The reason is, that for some
// reason the mns thinks that the reconnected prx is similar to the old info
// (check ice_identity) so it returnes the cached prx in its server map. Could be fixed
// by always querying the mns component for new proxies, but this may slow the system
// down.
//this->objPoseStorage =
// objpose::ObjectPoseStorageInterfacePrx::uncheckedCast(r.readingPrx);
// Current fix: Get prx from mns:
this->readingPrx = r.readingPrx;
ARMARX_INFO << "Connected to Memory '" << properties.memoryName << "'";
// cast MemoryPrx to objPoseStoragePrx
this->objPoseStorage =
objpose::ObjectPoseStorageInterfacePrx::uncheckedCast(r.readingPrx);
ARMARX_IMPORTANT << "Connected to Memory and ObjectPoseStorage '" << p.memoryName
<< "'";
}
catch (const armem::error::CouldNotResolveMemoryServer& e)
{
......@@ -58,7 +67,7 @@ namespace armarx::armem::obj::instance
const armarx::core::time::Duration& until)
{
std::map<std::string, bool> ret;
auto providers = objPoseStorage->getAvailableProvidersInfo();
auto providers = getObjectPoseStorage()->getAvailableProvidersInfo();
for (const auto& [k, p] : providers)
{
// TODO: check supported objects?
......@@ -81,7 +90,7 @@ namespace armarx::armem::obj::instance
req.request.objectIDs = {requestObject};
req.request.relativeTimeoutMS = until.toMilliSeconds();
auto requestResult = objPoseStorage->requestObjects(req);
auto requestResult = getObjectPoseStorage()->requestObjects(req);
if (requestResult.results.count(requestObject))
{
......@@ -95,7 +104,7 @@ namespace armarx::armem::obj::instance
{
// TODO: Shall we throw an exception if no instance index is set?
auto objectPoses = objPoseStorage->getObjectPoses();
auto objectPoses = getObjectPoseStorage()->getObjectPoses();
for (const auto& pose : objectPoses)
{
ObjectID oid;
......@@ -114,7 +123,7 @@ namespace armarx::armem::obj::instance
Reader::queryLatestObjectInstances()
{
std::map<std::string, objpose::ObjectPose> ret;
auto objectPoses = objPoseStorage->getObjectPoses();
auto objectPoses = getObjectPoseStorage()->getObjectPoses();
for (const auto& pose : objectPoses)
{
ObjectID oid;
......@@ -128,7 +137,7 @@ namespace armarx::armem::obj::instance
Reader::queryLatestObjectInstances(const ObjectID& classId)
{
std::map<std::string, objpose::ObjectPose> ret;
auto objectPoses = objPoseStorage->getObjectPoses();
auto objectPoses = getObjectPoseStorage()->getObjectPoses();
for (const auto& pose : objectPoses)
{
ObjectID oid;
......
......@@ -34,6 +34,7 @@
// The object pose provider. As long as the provider is not connected to armem we need the second proxy
#include <RobotAPI/interface/objectpose/ObjectPoseProvider.h>
#include <RobotAPI/interface/objectpose/ObjectPoseStorageInterface.h>
#include <RobotAPI/interface/armem/server/MemoryInterface.h>
namespace armarx::armem::obj::instance
{
......@@ -71,21 +72,22 @@ namespace armarx::armem::obj::instance
Properties
getProperties()
{
return this->p;
return this->properties;
}
objpose::ObjectPoseStorageInterfacePrx
getObjectPoseStorage() const
{
return objPoseStorage;
// TODO: see problem in source file. This performs a ice_isA every time this method is called
return objpose::ObjectPoseStorageInterfacePrx::checkedCast(this->readingPrx);
}
private:
Properties p;
Properties properties;
const std::string propertyPrefix = "mem.obj.instance.";
objpose::ObjectPoseStorageInterfacePrx objPoseStorage;
armarx::armem::server::ReadingMemoryInterfacePrx readingPrx;
};
......
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