Skip to content
Snippets Groups Projects
Commit 050914f7 authored by Christian Dreher's avatar Christian Dreher Committed by armar-user
Browse files

Add ObjectMemoryGroup statechart group and state RequestObjects (WIP)

parent 917dcec7
No related branches found
No related tags found
1 merge request!370Request object statechart
......@@ -13,3 +13,5 @@ add_subdirectory(StatechartExecutionGroup)
add_subdirectory(ProsthesisKinestheticTeachIn)
add_subdirectory(DebugDrawerToArVizGroup)
add_subdirectory(ObjectMemoryGroup)
# Modern CMake way:
#armarx_add_statechart(ObjectMemoryGroup
# SOURCES
# ObjectMemoryGroupRemoteStateOfferer.cpp
# HEADERS
# ObjectMemoryGroupRemoteStateOfferer.h
# DEPENDENCIES
#)
# Legacy CMake way:
armarx_component_set_name("ObjectMemoryGroup")
set(COMPONENT_LIBS
ArmarXCoreInterfaces ArmarXCore ArmarXCoreStatechart ArmarXCoreObservers)
set(SOURCES
ObjectMemoryGroupRemoteStateOfferer.cpp
)
set(HEADERS
ObjectMemoryGroupRemoteStateOfferer.h
ObjectMemoryGroup.scgxml
)
armarx_generate_statechart_cmake_lists()
armarx_add_component("${SOURCES}" "${HEADERS}")
<?xml version="1.0" encoding="utf-8"?>
<StatechartGroup name="ObjectMemoryGroup" package="RobotAPI" generateContext="true">
<Proxies>
<Proxy value="RobotAPIInterfaces.MemoryNameSystem"/>
</Proxies>
<Configurations/>
<State filename="RequestObjects.xml"/>
</StatechartGroup>
#include "ObjectMemoryGroupRemoteStateOfferer.h"
namespace armarx::ObjectMemoryGroup
{
// DO NOT EDIT NEXT LINE
ObjectMemoryGroupRemoteStateOfferer::SubClassRegistry ObjectMemoryGroupRemoteStateOfferer::Registry(ObjectMemoryGroupRemoteStateOfferer::GetName(), &ObjectMemoryGroupRemoteStateOfferer::CreateInstance);
ObjectMemoryGroupRemoteStateOfferer::ObjectMemoryGroupRemoteStateOfferer(StatechartGroupXmlReaderPtr reader) :
XMLRemoteStateOfferer < ObjectMemoryGroupStatechartContext > (reader)
{}
void ObjectMemoryGroupRemoteStateOfferer::onInitXMLRemoteStateOfferer() {}
void ObjectMemoryGroupRemoteStateOfferer::onConnectXMLRemoteStateOfferer() {}
void ObjectMemoryGroupRemoteStateOfferer::onExitXMLRemoteStateOfferer() {}
// DO NOT EDIT NEXT FUNCTION
std::string ObjectMemoryGroupRemoteStateOfferer::GetName()
{
return "ObjectMemoryGroupRemoteStateOfferer";
}
// DO NOT EDIT NEXT FUNCTION
XMLStateOffererFactoryBasePtr ObjectMemoryGroupRemoteStateOfferer::CreateInstance(StatechartGroupXmlReaderPtr reader)
{
return XMLStateOffererFactoryBasePtr(new ObjectMemoryGroupRemoteStateOfferer(reader));
}
}
#pragma once
#include <ArmarXCore/statechart/xmlstates/XMLRemoteStateOfferer.h>
#include "ObjectMemoryGroupStatechartContext.generated.h"
namespace armarx::ObjectMemoryGroup
{
class ObjectMemoryGroupRemoteStateOfferer :
virtual public XMLRemoteStateOfferer < ObjectMemoryGroupStatechartContext > // Change this statechart context if you need another context (dont forget to change in the constructor as well)
{
public:
ObjectMemoryGroupRemoteStateOfferer(StatechartGroupXmlReaderPtr reader);
// inherited from RemoteStateOfferer
void onInitXMLRemoteStateOfferer() override;
void onConnectXMLRemoteStateOfferer() override;
void onExitXMLRemoteStateOfferer() override;
// static functions for AbstractFactory Method
static std::string GetName();
static XMLStateOffererFactoryBasePtr CreateInstance(StatechartGroupXmlReaderPtr reader);
static SubClassRegistry Registry;
};
}
#include "RequestObjects.h"
//#include <ArmarXCore/core/time/TimeUtil.h>
//#include <ArmarXCore/observers/variant/DatafieldRef.h>
#include <RobotAPI/libraries/armem_objects/client/instance/ObjectReader.h>
#include <RobotAPI/libraries/ArmarXObjects/ObjectID.h>
#include <RobotAPI/libraries/ArmarXObjects/ice_conversions.h>
#include "ObjectMemoryGroupStatechartContext.generated.h"
namespace armarx::ObjectMemoryGroup
{
// DO NOT EDIT NEXT LINE
RequestObjects::SubClassRegistry RequestObjects::Registry(RequestObjects::GetName(), &RequestObjects::CreateInstance);
RequestObjects::RequestObjects(const XMLStateConstructorParams& stateData):
XMLStateTemplate<RequestObjects>(stateData), RequestObjectsGeneratedBase<RequestObjects>(stateData)
{
}
void RequestObjects::onEnter()
{
// put your user code for the enter-point here
// execution time should be short (<100ms)
}
void RequestObjects::run()
{
std::vector<std::string> objectIdsString;
std::vector<armarx::ObjectID> objectIds;
for (const std::string& idString : objectIdsString)
{
}
using Reader = armarx::armem::obj::instance::Reader;
// put your user code for the execution-phase here
// runs in seperate thread, thus can do complex operations
// should check constantly whether isRunningTaskStopped() returns true
auto context = getContext<ObjectMemoryGroupStatechartContext>();
armarx::armem::client::MemoryNameSystem mns(getMemoryNameSystem(), context);
Reader reader{mns};
reader.connect();
objpose::ObjectPoseStorageInterfacePrx storage = reader.getObjectPoseStorage();
armarx::objpose::observer::RequestObjectsInput input;
input.provider = "";
input.request.objectIDs.clear();
storage->requestObjects(input);
}
//void RequestObjects::onBreak()
//{
// // put your user code for the breaking point here
// // execution time should be short (<100ms)
//}
void RequestObjects::onExit()
{
// put your user code for the exit point here
// execution time should be short (<100ms)
}
// DO NOT EDIT NEXT FUNCTION
XMLStateFactoryBasePtr RequestObjects::CreateInstance(XMLStateConstructorParams stateData)
{
return XMLStateFactoryBasePtr(new RequestObjects(stateData));
}
}
#pragma once
#include <RobotAPI/statecharts/ObjectMemoryGroup/RequestObjects.generated.h>
namespace armarx::ObjectMemoryGroup
{
class RequestObjects :
public RequestObjectsGeneratedBase < RequestObjects >
{
public:
RequestObjects(const XMLStateConstructorParams& stateData);
// inherited from StateBase
void onEnter() override;
void run() override;
// void onBreak() override;
void onExit() override;
// static functions for AbstractFactory Method
static XMLStateFactoryBasePtr CreateInstance(XMLStateConstructorParams stateData);
static SubClassRegistry Registry;
// DO NOT INSERT ANY CLASS MEMBERS,
// use stateparameters instead,
// if classmember are neccessary nonetheless, reset them in onEnter
};
}
<?xml version="1.0" encoding="utf-8"?>
<State version="1.2" name="RequestObjects" uuid="9F09FB2F-CC0C-4B8A-A716-F130E04A7230" width="800" height="600" type="Normal State">
<InputParameters/>
<OutputParameters/>
<LocalParameters/>
<Substates>
<EndState name="Failure" event="Failure" left="212.8" top="177.1" boundingSquareSize="100"/>
<EndState name="Success" event="Success" left="213.78" top="424.2" boundingSquareSize="100"/>
</Substates>
<Events>
<Event name="Failure">
<Description>Event for statechart-internal failures or optionally user-code failures</Description>
</Event>
</Events>
<StartState substateName="Success">
<ParameterMappings/>
<SupportPoints/>
</StartState>
<Transitions/>
</State>
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