Skip to content
Snippets Groups Projects
Commit 4a7f7738 authored by Rainer Kartmann's avatar Rainer Kartmann
Browse files

Add ObjectPoseClient

parent 319f8983
No related branches found
No related tags found
No related merge requests found
......@@ -16,6 +16,7 @@ set(LIB_FILES
ObjectInfo.cpp
ObjectFinder.cpp
ObjectPose.cpp
ObjectPoseClient.cpp
json_conversions.cpp
ice_conversions.cpp
......@@ -33,6 +34,7 @@ set(LIB_HEADERS
ObjectInfo.h
ObjectFinder.h
ObjectPose.h
ObjectPoseClient.h
json_conversions.h
ice_conversions.h
......
#include "ObjectPoseClient.h"
namespace armarx::objpose
{
ObjectPoseClient::ObjectPoseClient()
{
}
ObjectPoseClient::ObjectPoseClient(
const ObjectPoseStorageInterfacePrx& objectPoseStorage,
const ObjectFinder& finder) :
objectFinder(finder)
{
this->connect(objectPoseStorage);
}
void
ObjectPoseClient::connect(
const ObjectPoseStorageInterfacePrx& objectPoseStorage)
{
this->objectPoseStorage = objectPoseStorage;
}
bool
ObjectPoseClient::isConnected() const
{
return bool(objectPoseStorage);
}
ObjectPoseSeq
ObjectPoseClient::fetchObjectPoses()
{
if (not objectPoseStorage)
{
ARMARX_WARNING << "No object pose observer.";
return {};
}
return fromIce(objectPoseStorage->getObjectPoses());
}
ObjectPoseMap ObjectPoseClient::fetchObjectPosesAsMap()
{
ObjectPoseMap map;
for (auto& pose : fetchObjectPoses())
{
map.emplace(pose.objectID, std::move(pose));
}
return map;
}
const ObjectPoseStorageInterfacePrx&
ObjectPoseClient::getObjectPoseStorage() const
{
return objectPoseStorage;
}
const ObjectFinder&
ObjectPoseClient::getObjectFinder() const
{
return objectFinder;
}
}
#pragma once
#include <RobotAPI/interface/objectpose/ObjectPoseStorageInterface.h>
#include <RobotAPI/libraries/ArmarXObjects/ObjectFinder.h>
#include <RobotAPI/libraries/ArmarXObjects/ObjectPose.h>
namespace armarx::objpose
{
/**
* @brief Provides access to the `armarx::objpose::ObjectPoseStorageInterface`
* (aka the object memory).
*/
class ObjectPoseClient
{
public:
ObjectPoseClient();
ObjectPoseClient(const ObjectPoseStorageInterfacePrx& objectPoseStorage,
const ObjectFinder& finder = {});
void connect(const ObjectPoseStorageInterfacePrx& objectPoseStorage);
bool isConnected() const;
ObjectPoseSeq
fetchObjectPoses();
ObjectPoseMap
fetchObjectPosesAsMap();
const ObjectPoseStorageInterfacePrx&
getObjectPoseStorage() const;
const ObjectFinder&
getObjectFinder() const;
public:
ObjectPoseStorageInterfacePrx objectPoseStorage;
ObjectFinder objectFinder;
};
}
......@@ -55,6 +55,13 @@ namespace armarx
return plugin->createObjectPoseStorage();
}
objpose::ObjectPoseClient ObjectPoseClientPluginUser::getClient() const
{
return objpose::ObjectPoseClient(objectPoseStorage, getObjectFinder());
}
objpose::ObjectPoseSeq ObjectPoseClientPluginUser::getObjectPoses()
{
if (!objectPoseStorage)
......
......@@ -5,6 +5,7 @@
#include <RobotAPI/interface/objectpose/ObjectPoseStorageInterface.h>
#include <RobotAPI/libraries/ArmarXObjects/ObjectFinder.h>
#include <RobotAPI/libraries/ArmarXObjects/ObjectPose.h>
#include <RobotAPI/libraries/ArmarXObjects/ObjectPoseClient.h>
namespace armarx::plugins
......@@ -73,6 +74,10 @@ namespace armarx
objpose::ObjectPoseStorageInterfacePrx createObjectPoseStorage();
objpose::ObjectPoseStorageInterfacePrx objectPoseStorage;
objpose::ObjectPoseClient getClient() const;
objpose::ObjectPoseSeq getObjectPoses();
plugins::ObjectPoseClientPlugin& getObjectPoseClientPlugin();
......
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