diff --git a/source/RobotAPI/components/armem/server/SkillsMemory/SkillsMemory.cpp b/source/RobotAPI/components/armem/server/SkillsMemory/SkillsMemory.cpp index 098fe6f1d3de321048b9a942b7ce0c7cca2814fe..6c86b6afa76fe043b4dea16affb609f7db049caf 100644 --- a/source/RobotAPI/components/armem/server/SkillsMemory/SkillsMemory.cpp +++ b/source/RobotAPI/components/armem/server/SkillsMemory/SkillsMemory.cpp @@ -30,6 +30,7 @@ #include <RobotAPI/libraries/armem/core/error.h> #include <RobotAPI/libraries/armem/core/wm/memory_definitions.h> +#include <RobotAPI/libraries/armem/server/wm/memory_definitions.h> #include <RobotAPI/libraries/armem/server/MemoryRemoteGui.h> #include <RobotAPI/libraries/armem_skills/aron_conversions.h> @@ -70,7 +71,7 @@ namespace armarx workingMemory.name() = p.memoryName; { - armarx::armem::wm::CoreSegment& c = workingMemory.addCoreSegment(p.statechartCoreSegmentName, armarx::armem::arondto::Statechart::Transition::toAronType()); + armarx::armem::server::wm::CoreSegment& c = workingMemory.addCoreSegment(p.statechartCoreSegmentName, armarx::armem::arondto::Statechart::Transition::toAronType()); c.addProviderSegment("Transitions", armarx::armem::arondto::Statechart::Transition::toAronType()); } } diff --git a/source/RobotAPI/libraries/armem/server/MemoryRemoteGui.cpp b/source/RobotAPI/libraries/armem/server/MemoryRemoteGui.cpp index 6f6abbb037eb91dbb0374ffece9921fb12c48f06..6664288a0fa5f86da4df906819cba3be385cbcb9 100644 --- a/source/RobotAPI/libraries/armem/server/MemoryRemoteGui.cpp +++ b/source/RobotAPI/libraries/armem/server/MemoryRemoteGui.cpp @@ -15,7 +15,8 @@ namespace armarx::armem::server { - MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const armem::wm::Memory& memory) const + template <class ...Args> + MemoryRemoteGui::GroupBox MemoryRemoteGui::_makeGroupBox(const armem::base::MemoryBase<Args...>& memory) const { GroupBox group; group.setLabel(makeGroupLabel("Memory", memory.name(), memory.size())); @@ -24,16 +25,15 @@ namespace armarx::armem::server { group.addChild(Label(makeNoItemsMessage("core segments"))); } - memory.forEachCoreSegment([this, &group](const armem::wm::CoreSegment & coreSegment) + memory.forEachCoreSegment([this, &group](const auto & coreSegment) { - group.addChild(makeGroupBox(coreSegment)); - return true; + group.addChild(this->makeGroupBox(coreSegment)); }); return group; } - - MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const armem::wm::CoreSegment& coreSegment) const + template <class ...Args> + MemoryRemoteGui::GroupBox MemoryRemoteGui::_makeGroupBox(const armem::base::CoreSegmentBase<Args...>& coreSegment) const { GroupBox group; group.setLabel(makeGroupLabel("Core Segment", coreSegment.name(), coreSegment.size())); @@ -42,16 +42,15 @@ namespace armarx::armem::server { group.addChild(Label(makeNoItemsMessage("provider segments"))); } - coreSegment.forEachProviderSegment([this, &group](const armem::wm::ProviderSegment & providerSegment) + coreSegment.forEachProviderSegment([this, &group](const auto & providerSegment) { - group.addChild(makeGroupBox(providerSegment)); - return true; + group.addChild(this->makeGroupBox(providerSegment)); }); return group; } - - MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const armem::wm::ProviderSegment& providerSegment) const + template <class ...Args> + MemoryRemoteGui::GroupBox MemoryRemoteGui::_makeGroupBox(const armem::base::ProviderSegmentBase<Args...>& providerSegment) const { GroupBox group; group.setLabel(makeGroupLabel("Provider Segment", providerSegment.name(), providerSegment.size())); @@ -60,16 +59,15 @@ namespace armarx::armem::server { group.addChild(Label(makeNoItemsMessage("entities"))); } - providerSegment.forEachEntity([this, &group](const armem::wm::Entity & entity) + providerSegment.forEachEntity([this, &group](const auto & entity) { - group.addChild(makeGroupBox(entity)); - return true; + group.addChild(this->makeGroupBox(entity)); }); return group; } - - MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const armem::wm::Entity& entity) const + template <class ...Args> + MemoryRemoteGui::GroupBox MemoryRemoteGui::_makeGroupBox(const armem::base::EntityBase<Args...>& entity) const { GroupBox group; group.setLabel(makeGroupLabel("Entity", entity.name(), entity.size())); @@ -82,7 +80,6 @@ namespace armarx::armem::server auto addChild = [this, &group](const armem::wm::EntitySnapshot & snapshot) { group.addChild(makeGroupBox(snapshot)); - return true; }; if (int(entity.size()) <= maxHistorySize) @@ -101,6 +98,54 @@ namespace armarx::armem::server } + MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const armem::server::wm::Memory& memory) const + { + return this->_makeGroupBox(memory); + } + + MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const armem::wm::Memory& memory) const + { + return this->_makeGroupBox(memory); + } + + + MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const armem::server::wm::CoreSegment& coreSegment) const + { + std::scoped_lock lock(coreSegment.mutex()); + return this->_makeGroupBox(coreSegment); + } + + + MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const armem::wm::CoreSegment& coreSegment) const + { + return this->_makeGroupBox(coreSegment); + } + + + MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const armem::server::wm::ProviderSegment& providerSegment) const + { + return this->_makeGroupBox(providerSegment); + } + + + MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const armem::wm::ProviderSegment& providerSegment) const + { + return this->_makeGroupBox(providerSegment); + } + + + MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const armem::wm::Entity& entity) const + { + return this->_makeGroupBox(entity); + } + + + MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const armem::server::wm::Entity& entity) const + { + return this->_makeGroupBox(entity); + } + + MemoryRemoteGui::GroupBox MemoryRemoteGui::makeGroupBox(const armem::wm::EntitySnapshot& snapshot) const { GroupBox group; diff --git a/source/RobotAPI/libraries/armem/server/MemoryRemoteGui.h b/source/RobotAPI/libraries/armem/server/MemoryRemoteGui.h index 35e82d48a4d084c73f6c0bd870488fe8201c56c7..c6aef5c51546ac203c50d38f80696b89f3b6f3b9 100644 --- a/source/RobotAPI/libraries/armem/server/MemoryRemoteGui.h +++ b/source/RobotAPI/libraries/armem/server/MemoryRemoteGui.h @@ -17,6 +17,7 @@ namespace armarx::armem::server using GroupBox = armarx::RemoteGui::Client::GroupBox; using Label = armarx::RemoteGui::Client::Label; + GroupBox makeGroupBox(const armem::wm::Memory& memory) const; GroupBox makeGroupBox(const armem::wm::CoreSegment& coreSegment) const; GroupBox makeGroupBox(const armem::wm::ProviderSegment& providerSegment) const; @@ -24,6 +25,11 @@ namespace armarx::armem::server GroupBox makeGroupBox(const armem::wm::EntitySnapshot& entitySnapshot) const; GroupBox makeGroupBox(const armem::wm::EntityInstance& instance) const; + GroupBox makeGroupBox(const armem::server::wm::Memory& memory) const; + GroupBox makeGroupBox(const armem::server::wm::CoreSegment& coreSegment) const; + GroupBox makeGroupBox(const armem::server::wm::ProviderSegment& providerSegment) const; + GroupBox makeGroupBox(const armem::server::wm::Entity& entity) const; + std::string makeGroupLabel(const std::string& term, const std::string& name, size_t size, const std::string& namePrefix = ": '", const std::string& nameSuffix = "'") const; @@ -33,6 +39,17 @@ namespace armarx::armem::server int maxHistorySize = 10; + private: + + template <class ...Args> + MemoryRemoteGui::GroupBox _makeGroupBox(const armem::base::MemoryBase<Args...>& memory) const; + template <class ...Args> + MemoryRemoteGui::GroupBox _makeGroupBox(const armem::base::CoreSegmentBase<Args...>& coreSegment) const; + template <class ...Args> + MemoryRemoteGui::GroupBox _makeGroupBox(const armem::base::ProviderSegmentBase<Args...>& providerSegment) const; + template <class ...Args> + MemoryRemoteGui::GroupBox _makeGroupBox(const armem::base::EntityBase<Args...>& entity) const; + }; diff --git a/source/RobotAPI/libraries/armem/test/ArMemMemoryTest.cpp b/source/RobotAPI/libraries/armem/test/ArMemMemoryTest.cpp index 0e51493955af7e917e4cd2ef533f0872b4b7488d..376f2ec680f92e64a5c72b496543749a303e8cc1 100644 --- a/source/RobotAPI/libraries/armem/test/ArMemMemoryTest.cpp +++ b/source/RobotAPI/libraries/armem/test/ArMemMemoryTest.cpp @@ -27,6 +27,7 @@ #include <RobotAPI/Test.h> #include <RobotAPI/libraries/armem/core/wm/memory_definitions.h> +#include <RobotAPI/libraries/armem/server/wm/memory_definitions.h> #include <RobotAPI/libraries/armem/core/longtermmemory/Memory.h> #include <RobotAPI/libraries/armem/core/diskmemory/Memory.h> #include <RobotAPI/libraries/armem/core/error.h> @@ -701,7 +702,7 @@ BOOST_AUTO_TEST_CASE(test_segment_setup) BOOST_AUTO_TEST_CASE(test_history_size_in_entity) { - armem::wm::Entity entity("entity"); + armem::server::wm::Entity entity("entity"); armem::EntityUpdate update; update.entityID.entityName = entity.name(); @@ -744,7 +745,7 @@ BOOST_AUTO_TEST_CASE(test_history_size_in_entity) BOOST_AUTO_TEST_CASE(test_history_size_in_provider_segment) { - armem::wm::ProviderSegment providerSegment("SomeRGBImageProvider"); + armem::server::wm::ProviderSegment providerSegment("SomeRGBImageProvider"); armem::EntityUpdate update; update.entityID.providerSegmentName = providerSegment.name(); diff --git a/source/RobotAPI/libraries/armem/test/ArMemQueryTest.cpp b/source/RobotAPI/libraries/armem/test/ArMemQueryTest.cpp index 32795093a9c602e694a580b962279891f2062d50..656842b3dcd23d49a84a51a04fc02143c14cada2 100644 --- a/source/RobotAPI/libraries/armem/test/ArMemQueryTest.cpp +++ b/source/RobotAPI/libraries/armem/test/ArMemQueryTest.cpp @@ -26,9 +26,9 @@ #include <RobotAPI/Test.h> #include <RobotAPI/interface/armem/query.h> -#include <RobotAPI/libraries/armem/server/query_proc/workingmemory/EntityQueryProcessor.h> #include <RobotAPI/libraries/armem/core/error.h> #include <RobotAPI/libraries/armem/core/base/detail/negative_index_semantics.h> +#include <RobotAPI/libraries/armem/server/query_proc/wm.h> #include <SimoxUtility/algorithm/get_map_keys_values.h> #include <SimoxUtility/algorithm/string.h> @@ -39,7 +39,7 @@ namespace armem = armarx::armem; namespace aron = armarx::aron; namespace query = armarx::armem::query::data; -using EntityQueryProcessor = armarx::armem::wm::query_proc::EntityQueryProcessor; +using EntityQueryProcessor = armarx::armem::server::query_proc::wm::EntityQueryProcessor; namespace ArMemQueryTest @@ -53,7 +53,7 @@ namespace ArMemQueryTest { armem::wm::Entity entity; - armem::wm::query_proc::EntityQueryProcessor processor; + armem::server::query_proc::wm::EntityQueryProcessor processor; std::vector<armem::wm::Entity> results; diff --git a/source/RobotAPI/libraries/armem_gui/MemoryViewer.cpp b/source/RobotAPI/libraries/armem_gui/MemoryViewer.cpp index bc63d69b96701b226b10c83d3b28eca3a7ea154c..5e5431e41aa6a94ba8616247ec19a5529ca9927e 100644 --- a/source/RobotAPI/libraries/armem_gui/MemoryViewer.cpp +++ b/source/RobotAPI/libraries/armem_gui/MemoryViewer.cpp @@ -5,8 +5,8 @@ #include <RobotAPI/libraries/armem/core/diskmemory/Memory.h> -#include <RobotAPI/libraries/armem/server/query_proc/diskmemory/MemoryQueryProcessor.h> -#include <RobotAPI/libraries/armem/server/query_proc/workingmemory/MemoryQueryProcessor.h> +#include <RobotAPI/libraries/armem/server/query_proc/diskmemory.h> +#include <RobotAPI/libraries/armem/server/query_proc/wm.h> #include <ArmarXGui/libraries/SimpleConfigDialog/SimpleConfigDialog.h> @@ -243,7 +243,7 @@ namespace armarx::armem::gui input.addQueryTargetToAll(armem::query::data::QueryTarget::LTM); // We use LTM as query target for the disk - armem::d_ltm::query_proc::MemoryQueryProcessor d_ltm_processor; + armem::server::query_proc::d_ltm::MemoryQueryProcessor d_ltm_processor; dMem = d_ltm_processor.process(input.toIce(), dMem); wm::Memory converted = dMem.convert(); @@ -302,7 +302,7 @@ namespace armarx::armem::gui std::stringstream ss; auto now = std::chrono::system_clock::now(); auto in_time_t = std::chrono::system_clock::to_time_t(now); - ss << "Last update: " << std::put_time(std::localtime(&in_time_t), "%Y-%m-%d %X"); + ss << "Last update: " ;// << std::put_time(std::localtime(&in_time_t), "%Y-%m-%d %X"); if (dataChanged) { diff --git a/source/RobotAPI/libraries/armem_motions/server/MotionDatabase/MDBMotions/Segment.cpp b/source/RobotAPI/libraries/armem_motions/server/MotionDatabase/MDBMotions/Segment.cpp index 67ffed4ba2e37812dc40a31a8534f1119b384282..5860b2f48f9659c7ac631e1270425f112a0efcab 100644 --- a/source/RobotAPI/libraries/armem_motions/server/MotionDatabase/MDBMotions/Segment.cpp +++ b/source/RobotAPI/libraries/armem_motions/server/MotionDatabase/MDBMotions/Segment.cpp @@ -1,8 +1,3 @@ -// STD / STL -#include <iostream> -#include <fstream> -#include <sstream> - // BaseClass #include "Segment.h" @@ -11,10 +6,16 @@ #include <RobotAPI/libraries/PriorKnowledge/motions/MotionFinder.h> #include <RobotAPI/libraries/armem/core/wm/memory_definitions.h> +#include <RobotAPI/libraries/armem/server/wm/memory_definitions.h> #include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h> #include <ArmarXCore/core/application/properties/ProxyPropertyDefinition.h> +// STD / STL +#include <iostream> +#include <fstream> +#include <sstream> + namespace armarx::armem::server::motions::mdb { diff --git a/source/RobotAPI/libraries/armem_objects/server/class/FloorVis.cpp b/source/RobotAPI/libraries/armem_objects/server/class/FloorVis.cpp index 35ce3d1cf113183ea60489a522048caa8058645e..1e9957aff7b0d093d3bd1d6e16f289d6a2a04afd 100644 --- a/source/RobotAPI/libraries/armem_objects/server/class/FloorVis.cpp +++ b/source/RobotAPI/libraries/armem_objects/server/class/FloorVis.cpp @@ -1,6 +1,7 @@ #include "FloorVis.h" #include <RobotAPI/libraries/armem/core/wm/memory_definitions.h> +#include <RobotAPI/libraries/armem/server/wm/memory_definitions.h> #include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h> #include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h> @@ -13,16 +14,19 @@ namespace armarx::armem::server::obj::clazz { } + void FloorVis::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix) { properties.define(defs, prefix); } + void FloorVis::setArViz(armarx::viz::Client arviz) { this->arviz = arviz; } + void FloorVis::updateFloorObject(const wm::CoreSegment& classCoreSegment) { viz::Layer layer = arviz.layer(properties.layerName); @@ -42,6 +46,7 @@ namespace armarx::armem::server::obj::clazz arviz.commit(layer); } + armarx::viz::Object FloorVis::makeFloorObject(const wm::Entity& classEntity) { const wm::EntityInstance& instance = classEntity.getLatestSnapshot().getInstance(0); @@ -50,6 +55,7 @@ namespace armarx::armem::server::obj::clazz return makeFloorObject(classEntity.name(), data); } + armarx::viz::Object FloorVis::makeFloorObject( const std::string& name, const arondto::ObjectClass& objectClass) @@ -61,7 +67,6 @@ namespace armarx::armem::server::obj::clazz } - void FloorVis::Properties::define(armarx::PropertyDefinitionsPtr defs, const std::string& prefix) { defs->optional(show, prefix + "Show", "Whether to show the floor."); diff --git a/source/RobotAPI/libraries/armem_objects/server/class/FloorVis.h b/source/RobotAPI/libraries/armem_objects/server/class/FloorVis.h index dcce63977438bdd0d646b50aa8e5dd9679354df8..49f8a6ddd71f5c24172ddfbbfd8e312dcea2fd3f 100644 --- a/source/RobotAPI/libraries/armem_objects/server/class/FloorVis.h +++ b/source/RobotAPI/libraries/armem_objects/server/class/FloorVis.h @@ -10,7 +10,7 @@ namespace armarx { using PropertyDefinitionsPtr = IceUtil::Handle<class PropertyDefinitionContainer>; } -namespace armarx::armem::wm +namespace armarx::armem::server::wm { class CoreSegment; class Entity; diff --git a/source/RobotAPI/libraries/armem_robot_state/common/localization/TransformHelper.cpp b/source/RobotAPI/libraries/armem_robot_state/common/localization/TransformHelper.cpp index 7990703b1bb8bd1c533e9d01f427d905f4b1eedd..a3a039a47b41de902d8a2f2e347d4045f51d1de8 100644 --- a/source/RobotAPI/libraries/armem_robot_state/common/localization/TransformHelper.cpp +++ b/source/RobotAPI/libraries/armem_robot_state/common/localization/TransformHelper.cpp @@ -263,10 +263,8 @@ namespace armarx::armem::common::robot_state::localization { const auto& agentProviderSegment = localizationCoreSegment.getProviderSegment(agent); - ARMARX_DEBUG << "Provider segments" - << simox::alg::get_keys(localizationCoreSegment.providerSegments()); - - ARMARX_DEBUG << "Entities: " << simox::alg::get_keys(agentProviderSegment.entities()); + ARMARX_DEBUG << "Provider segments" << localizationCoreSegment.getProviderSegmentNames(); + ARMARX_DEBUG << "Entities: " << agentProviderSegment.getEntityNames(); try { @@ -305,12 +303,10 @@ namespace armarx::armem::common::robot_state::localization const armem::wm::ProviderSegment& agentProviderSegment, const armem::Time& timestamp) { - ARMARX_DEBUG << "getEntity:" + entityName; const auto& entity = agentProviderSegment.getEntity(entityName); - ARMARX_DEBUG << "History (size: " << entity.history().size() << ")" - << simox::alg::get_keys(entity.history()); + ARMARX_DEBUG << "History (size: " << entity.size() << "): " << entity.getTimestamps(); // if (entity.history.empty()) // { @@ -320,23 +316,9 @@ namespace armarx::armem::common::robot_state::localization // } std::vector<::armarx::armem::robot_state::Transform> transforms; - transforms.reserve(entity.history().size()); - - // const auto entitySnapshots = simox::alg::get_values(entity.history()); - - const std::vector<wm::EntitySnapshot> entitySnapshots = {entity.getLatestSnapshot()}; - - std::transform( - entitySnapshots.begin(), - entitySnapshots.end(), - std::back_inserter(transforms), - [](const auto & entitySnapshot) - { - return convertEntityToTransform(entitySnapshot.getInstance(0)); - }); + transforms.push_back(convertEntityToTransform(entity.getLatestSnapshot().getInstance(0))); ARMARX_DEBUG << "obtaining transform"; - if (transforms.size() > 1) { // TODO(fabian.reister): remove