diff --git a/source/RobotAPI/statecharts/CMakeLists.txt b/source/RobotAPI/statecharts/CMakeLists.txt index 006016c5daa24d555c8a5d9537b8bfbbd0c96229..33340476f9568dce65fbd43bcd3f745f80df32f6 100644 --- a/source/RobotAPI/statecharts/CMakeLists.txt +++ b/source/RobotAPI/statecharts/CMakeLists.txt @@ -13,3 +13,5 @@ add_subdirectory(StatechartExecutionGroup) add_subdirectory(ProsthesisKinestheticTeachIn) add_subdirectory(DebugDrawerToArVizGroup) + +add_subdirectory(ObjectMemoryGroup) diff --git a/source/RobotAPI/statecharts/ObjectMemoryGroup/CMakeLists.txt b/source/RobotAPI/statecharts/ObjectMemoryGroup/CMakeLists.txt new file mode 100644 index 0000000000000000000000000000000000000000..f86bfcaea30cb170e21e2c0687a7fd25b5ae0314 --- /dev/null +++ b/source/RobotAPI/statecharts/ObjectMemoryGroup/CMakeLists.txt @@ -0,0 +1,27 @@ +# 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}") diff --git a/source/RobotAPI/statecharts/ObjectMemoryGroup/ObjectMemoryGroup.scgxml b/source/RobotAPI/statecharts/ObjectMemoryGroup/ObjectMemoryGroup.scgxml new file mode 100644 index 0000000000000000000000000000000000000000..90e06380aac081c202bee6f38e0c8d8dca3421e4 --- /dev/null +++ b/source/RobotAPI/statecharts/ObjectMemoryGroup/ObjectMemoryGroup.scgxml @@ -0,0 +1,9 @@ +<?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> + diff --git a/source/RobotAPI/statecharts/ObjectMemoryGroup/ObjectMemoryGroupRemoteStateOfferer.cpp b/source/RobotAPI/statecharts/ObjectMemoryGroup/ObjectMemoryGroupRemoteStateOfferer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1324dfff62f4a6ec3df04e61d451f062125a50c8 --- /dev/null +++ b/source/RobotAPI/statecharts/ObjectMemoryGroup/ObjectMemoryGroupRemoteStateOfferer.cpp @@ -0,0 +1,29 @@ +#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)); + } +} diff --git a/source/RobotAPI/statecharts/ObjectMemoryGroup/ObjectMemoryGroupRemoteStateOfferer.h b/source/RobotAPI/statecharts/ObjectMemoryGroup/ObjectMemoryGroupRemoteStateOfferer.h new file mode 100644 index 0000000000000000000000000000000000000000..882627aec09b55c16b4b0f07fe313c0138392368 --- /dev/null +++ b/source/RobotAPI/statecharts/ObjectMemoryGroup/ObjectMemoryGroupRemoteStateOfferer.h @@ -0,0 +1,26 @@ +#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; + + + }; +} diff --git a/source/RobotAPI/statecharts/ObjectMemoryGroup/RequestObjects.cpp b/source/RobotAPI/statecharts/ObjectMemoryGroup/RequestObjects.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c2d0a05c91ce1760d5ca4d8f5ce44012296690fe --- /dev/null +++ b/source/RobotAPI/statecharts/ObjectMemoryGroup/RequestObjects.cpp @@ -0,0 +1,77 @@ +#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)); + } +} diff --git a/source/RobotAPI/statecharts/ObjectMemoryGroup/RequestObjects.h b/source/RobotAPI/statecharts/ObjectMemoryGroup/RequestObjects.h new file mode 100644 index 0000000000000000000000000000000000000000..4390865434749d591d6082df003c55e3b8560cd6 --- /dev/null +++ b/source/RobotAPI/statecharts/ObjectMemoryGroup/RequestObjects.h @@ -0,0 +1,27 @@ +#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 + }; +} diff --git a/source/RobotAPI/statecharts/ObjectMemoryGroup/RequestObjects.xml b/source/RobotAPI/statecharts/ObjectMemoryGroup/RequestObjects.xml new file mode 100644 index 0000000000000000000000000000000000000000..b3c13fed955c21a9e632ec57a012d6d2d3807e27 --- /dev/null +++ b/source/RobotAPI/statecharts/ObjectMemoryGroup/RequestObjects.xml @@ -0,0 +1,21 @@ +<?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> +