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

Add ObjectPoseClient plugin

parent a739c571
No related branches found
No related tags found
No related merge requests found
......@@ -13,6 +13,7 @@ set(SOURCES
ObjectPoseObserver.cpp
plugins/ObjectPoseProvider.cpp
plugins/ObjectPoseClient.cpp
ObjectFinder.cpp
ice_conversions.cpp
......@@ -22,6 +23,7 @@ set(HEADERS
ObjectPoseObserver.h
plugins/ObjectPoseProvider.h
plugins/ObjectPoseClient.h
ObjectFinder.h
ice_conversions.h
......
#include "ObjectPoseClient.h"
namespace armarx::plugins
{
void ObjectPoseClientPlugin::postCreatePropertyDefinitions(PropertyDefinitionsPtr& properties)
{
if (!properties->hasDefinition(makePropertyName(PROPERTY_NAME)))
{
properties->defineOptionalProperty<std::string>(
makePropertyName(PROPERTY_NAME),
"ObjectPoseObserver",
"Name of the object pose observer.");
}
}
void ObjectPoseClientPlugin::preOnInitComponent()
{
parent<Component>().usingProxyFromProperty(makePropertyName(PROPERTY_NAME));
}
void ObjectPoseClientPlugin::preOnConnectComponent()
{
parent<ObjectPoseClientPluginUser>().objectPoseObserver = createObjectPoseObserver();
}
objpose::ObjectPoseObserverInterfacePrx ObjectPoseClientPlugin::createObjectPoseObserver()
{
return parent<Component>().getTopicFromProperty<objpose::ObjectPoseObserverInterfacePrx>(makePropertyName(PROPERTY_NAME));
}
}
namespace armarx
{
ObjectPoseClientPluginUser::ObjectPoseClientPluginUser()
{
addPlugin(plugin);
}
objpose::ObjectPoseObserverInterfacePrx ObjectPoseClientPluginUser::createObjectPoseObserver()
{
return plugin->createObjectPoseObserver();
}
objpose::ObjectPoseSeq ObjectPoseClientPluginUser::getObjectPoses()
{
if (!objectPoseObserver)
{
ARMARX_WARNING << "No object pose observer.";
return {};
}
return objpose::fromIce(objectPoseObserver->getObjectPoses());
}
}
#pragma once
#include <ArmarXCore/core/Component.h>
#include <RobotAPI/interface/objectpose/ObjectPoseObserver.h>
#include "../ObjectPose.h"
namespace armarx::plugins
{
class ObjectPoseClientPlugin : public ComponentPlugin
{
public:
using ComponentPlugin::ComponentPlugin;
void postCreatePropertyDefinitions(PropertyDefinitionsPtr& properties) override;
void preOnInitComponent() override;
void preOnConnectComponent() override;
objpose::ObjectPoseObserverInterfacePrx createObjectPoseObserver();
private:
static constexpr const char* PROPERTY_NAME = "ObjectPoseTopicName";
};
}
namespace armarx
{
/**
* @brief Provides an `objpose::ObjectPoseTopicPrx objectPoseTopic` as member variable.
*/
class ObjectPoseClientPluginUser :
virtual public ManagedIceObject
{
public:
/// Allow usage like: ObjectPose::getObjects()
using ObjectPose = ObjectPoseClientPluginUser;
ObjectPoseClientPluginUser();
objpose::ObjectPoseObserverInterfacePrx createObjectPoseObserver();
objpose::ObjectPoseObserverInterfacePrx objectPoseObserver;
objpose::ObjectPoseSeq getObjectPoses();
private:
armarx::plugins::ObjectPoseClientPlugin* plugin = nullptr;
};
}
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