Skip to content
Snippets Groups Projects
Commit 0ecf19f4 authored by alissa's avatar alissa
Browse files

Created Grasp Memory Server (WIP)

parent 7396de35
No related branches found
No related tags found
2 merge requests!195Add GraspMemory,!135Resolve "Add Grasp (Affordance) Memory"
This commit is part of merge request !135. Comments created here will be created in the context of that merge request.
......@@ -3,6 +3,7 @@ add_subdirectory(server/ExampleMemory)
add_subdirectory(server/GeneralPurposeMemory)
add_subdirectory(server/RobotSensorMemory)
add_subdirectory(server/SkillsMemory)
add_subdirectory(server/GraspMemory)
# memory server addons
......
armarx_component_set_name("GraspMemory")
set(COMPONENT_LIBS
ArmarXCore ArmarXCoreInterfaces # for DebugObserverInterface
ArmarXGuiComponentPlugins
RobotAPICore RobotAPIInterfaces armem
# RobotAPIComponentPlugins # for ArViz and other plugins
${IVT_LIBRARIES}
)
set(SOURCES
GraspMemory.cpp
)
set(HEADERS
GraspMemory.h
)
armarx_add_component("${SOURCES}" "${HEADERS}")
#generate the application
armarx_generate_and_add_component_executable()
#include "GraspMemory.h"
#include <ArmarXCore/core/exceptions/local/ExpressionException.h>
#include <SimoxUtility/algorithm/string.h>
#include <RobotAPI/libraries/armem/core/error.h>
#include <RobotAPI/libraries/armem/server/MemoryRemoteGui.h>
#include <RobotAPI/libraries/GraspingUtility/aron/GraspAffordance.aron.generated.h>
namespace armarx
{
armarx::PropertyDefinitionsPtr GraspMemory::createPropertyDefinitions()
{
armarx::PropertyDefinitionsPtr defs = new ComponentPropertyDefinitions(getConfigIdentifier());
defs->topic(debugObserver);
defs->optional(p.memoryName, "memory.Name", "Name of this memory server.");
p.core._defaultSegmentsStr = simox::alg::join(p.core.defaultCoreSegments, ", ");
defs->optional(p.core._defaultSegmentsStr, "core.DefaultSegments",
"Core segments to add on start up (just as Grasp).");
defs->optional(p.core.addOnUsage, "core.AddOnUsage",
"If enabled, core segments are added when required by a new provider segment."
"This will usually be off for most memory servers.");
return defs;
}
std::string GraspMemory::getDefaultName() const
{
return "GraspMemory";
}
void GraspMemory::onInitComponent()
{
memory.name() = p.memoryName;
// Usually, the memory server will specify a number of core segments with a specific aron type.
memory.addCoreSegment("GraspAffordance", armarx::grasping::arondto::GraspCandidate::toInitialAronType());
// For illustration purposes, we add more segments (without types).
bool trim = true;
p.core.defaultCoreSegments = simox::alg::split(p.core._defaultSegmentsStr, ",", trim);
p.core._defaultSegmentsStr.clear();
memory.addCoreSegments(p.core.defaultCoreSegments);
}
void GraspMemory::onConnectComponent()
{
RemoteGui__createTab();
RemoteGui_startRunningTask();
}
void GraspMemory::onDisconnectComponent()
{
}
void GraspMemory::onExitComponent()
{
}
// WRITING
armem::data::AddSegmentsResult GraspMemory::addSegments(const armem::data::AddSegmentsInput& input, const Ice::Current&)
{
// This function is overloaded to trigger the remote gui rebuild.
armem::data::AddSegmentsResult result = ComponentPluginUser::addSegments(input, p.core.addOnUsage);
tab.rebuild = true;
return result;
}
armem::data::CommitResult GraspMemory::commit(const armem::data::Commit& commit, const Ice::Current&)
{
// This function is overloaded to trigger the remote gui rebuild.
armem::data::CommitResult result = ComponentPluginUser::commit(commit);
tab.rebuild = true;
return result;
}
// READING
// Inherited from Plugin
// REMOTE GUI
void GraspMemory::RemoteGui__createTab()
{
using namespace armarx::RemoteGui::Client;
{
std::scoped_lock lock(memoryMutex);
tab.memoryGroup = armem::server::MemoryRemoteGui().makeGroupBox(memory);
}
VBoxLayout root = {tab.memoryGroup, VSpacer()};
RemoteGui_createTab(getName(), root, &tab);
}
void GraspMemory::RemoteGui_update()
{
if (tab.rebuild.exchange(false))
{
RemoteGui__createTab();
}
}
}
#pragma once
#include <ArmarXCore/core/Component.h>
#include <ArmarXCore/interface/observers/ObserverInterface.h>
#include <ArmarXGui/libraries/ArmarXGuiComponentPlugins/LightweightRemoteGuiComponentPlugin.h>
#include <RobotAPI/libraries/RobotAPIComponentPlugins/ArVizComponentPlugin.h>
#include <RobotAPI/libraries/armem/server/ComponentPlugin.h>
namespace armarx
{
/**
* @defgroup Component-ExampleMemory ExampleMemory
* @ingroup RobotAPI-Components
* A description of the component ExampleMemory.
*
* @class ExampleMemory
* @ingroup Component-ExampleMemory
* @brief Brief description of class ExampleMemory.
*
* Detailed description of class ExampleMemory.
*/
class GraspMemory :
virtual public armarx::Component
, virtual public armem::server::ComponentPluginUser
, virtual public LightweightRemoteGuiComponentPluginUser
// , virtual public armarx::ArVizComponentPluginUser
{
public:
/// @see armarx::ManagedIceObject::getDefaultName()
std::string getDefaultName() const override;
// WritingInterface interface
public:
armem::data::AddSegmentsResult addSegments(const armem::data::AddSegmentsInput& input, const Ice::Current&) override;
armem::data::CommitResult commit(const armem::data::Commit& commit, const Ice::Current&) override;
// LightweightRemoteGuiComponentPluginUser interface
public:
void RemoteGui__createTab();
void RemoteGui_update() override;
protected:
armarx::PropertyDefinitionsPtr createPropertyDefinitions() override;
void onInitComponent() override;
void onConnectComponent() override;
void onDisconnectComponent() override;
void onExitComponent() override;
private:
armarx::DebugObserverInterfacePrx debugObserver;
struct Properties
{
std::string memoryName = "Grasp";
struct CoreSegments
{
std::vector<std::string> defaultCoreSegments = { "GraspModality", "GraspConcept" };
std::string _defaultSegmentsStr;
bool addOnUsage = false;
};
CoreSegments core;
};
Properties p;
struct RemoteGuiTab : RemoteGui::Client::Tab
{
std::atomic_bool rebuild = false;
RemoteGui::Client::GroupBox memoryGroup;
};
RemoteGuiTab tab;
};
}
......@@ -91,7 +91,7 @@
</ObjectChild>
</Object>
<Object name='armarx::objpose::arondto::GraspCandidate'>
<Object name='armarx::grasping::arondto::GraspCandidate'>
<ObjectChild key='graspPose'>
<EigenMatrix rows="4" cols="4" type="float" />
......@@ -156,7 +156,7 @@
</Object>
<Object name='armarx::objpose::arondto::BimanualGraspCandidate'>
<Object name='armarx::grasping::arondto::BimanualGraspCandidate'>
<ObjectChild key='graspPoseRight'>
<EigenMatrix rows="4" cols="4" type="float" />
......
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