From 5cdf21e69090348714a2c954a81d0f1425d0c84e Mon Sep 17 00:00:00 2001 From: Rainer Kartmann <rainer.kartmann@kit.edu> Date: Wed, 21 Jul 2021 14:36:32 +0200 Subject: [PATCH] Remove unused files --- .../armem/server/ObjectMemory/ObjectMemory.h | 2 - .../libraries/armem_objects/CMakeLists.txt | 12 +- .../articulated_object_class/Segment.cpp | 186 ------------------ .../server/articulated_object_class/Segment.h | 112 ----------- .../articulated_object_instance/Segment.cpp | 175 ---------------- .../articulated_object_instance/Segment.h | 112 ----------- 6 files changed, 1 insertion(+), 598 deletions(-) delete mode 100644 source/RobotAPI/libraries/armem_objects/server/articulated_object_class/Segment.cpp delete mode 100644 source/RobotAPI/libraries/armem_objects/server/articulated_object_class/Segment.h delete mode 100644 source/RobotAPI/libraries/armem_objects/server/articulated_object_instance/Segment.cpp delete mode 100644 source/RobotAPI/libraries/armem_objects/server/articulated_object_instance/Segment.h diff --git a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h index 5ef38a94b..b90406be3 100644 --- a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h +++ b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h @@ -38,8 +38,6 @@ #include <RobotAPI/libraries/armem_objects/server/class/Segment.h> #include <RobotAPI/libraries/armem_objects/server/instance/SegmentAdapter.h> -#include <RobotAPI/libraries/armem_objects/server/articulated_object_instance/Segment.h> -#include <RobotAPI/libraries/armem_objects/server/articulated_object_class/Segment.h> #include <RobotAPI/libraries/armem_objects/server/attachments/Segment.h> diff --git a/source/RobotAPI/libraries/armem_objects/CMakeLists.txt b/source/RobotAPI/libraries/armem_objects/CMakeLists.txt index 54eb919e1..ab26b1f8a 100644 --- a/source/RobotAPI/libraries/armem_objects/CMakeLists.txt +++ b/source/RobotAPI/libraries/armem_objects/CMakeLists.txt @@ -16,6 +16,7 @@ armarx_add_library( RobotAPI::Core RobotAPI::armem RobotAPI::armem_robot + HEADERS aron_conversions.h aron_forward_declarations.h @@ -32,11 +33,6 @@ armarx_add_library( server/instance/Visu.h server/instance/ArticulatedObjectVisu.h - # server/articulated_object_class/Segment.h - # server/articulated_object_instance/Segment.h - # server/articulated_object/SegmentAdapter.h - # server/articulated_object_instance/Visu.h - server/attachments/Segment.h client/articulated_object/Reader.h @@ -64,12 +60,6 @@ armarx_add_library( server/instance/Visu.cpp server/instance/ArticulatedObjectVisu.cpp - server/articulated_object_class/Segment.cpp - - # server/articulated_object_instance/Segment.cpp - # server/articulated_object/SegmentAdapter.cpp - # server/articulated_object_instance/Visu.cpp - server/attachments/Segment.cpp client/articulated_object/Reader.cpp diff --git a/source/RobotAPI/libraries/armem_objects/server/articulated_object_class/Segment.cpp b/source/RobotAPI/libraries/armem_objects/server/articulated_object_class/Segment.cpp deleted file mode 100644 index 354ac2efc..000000000 --- a/source/RobotAPI/libraries/armem_objects/server/articulated_object_class/Segment.cpp +++ /dev/null @@ -1,186 +0,0 @@ -#include "Segment.h" - -#include <SimoxUtility/algorithm/get_map_keys_values.h> -#include <sstream> - -#include <ArmarXCore/core/time/TimeUtil.h> -#include "ArmarXCore/core/logging/Logging.h" - -#include "RobotAPI/libraries/aron/common/aron_conversions.h" - -#include <RobotAPI/libraries/armem/core/aron_conversions.h> -#include <RobotAPI/libraries/armem/core/workingmemory/visitor.h> -#include "RobotAPI/libraries/armem/core/MemoryID.h" -#include <RobotAPI/libraries/armem/client/Writer.h> -#include <RobotAPI/libraries/armem/client/query/Builder.h> -#include <RobotAPI/libraries/armem/client/query/query_fns.h> -#include <RobotAPI/libraries/armem/server/MemoryToIceAdapter.h> - -#include "RobotAPI/libraries/armem_robot/robot_conversions.h" -#include <RobotAPI/libraries/armem_robot/aron/Robot.aron.generated.h> -#include <RobotAPI/libraries/armem_robot/aron_conversions.h> - - -namespace armarx::armem::server::obj::articulated_object_class -{ - - Segment::Segment(armem::server::MemoryToIceAdapter& memoryToIceAdapter, std::mutex& memoryMutex) : - iceMemory(memoryToIceAdapter), - memoryMutex(memoryMutex) - { - Logging::setTag("ArticulatedObjectInstanceSegment"); - } - - Segment::~Segment() = default; - - void Segment::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix) - { - defs->optional(p.coreClassSegmentName, prefix + "CoreSegmentName", "Name of the object instance core segment."); - defs->optional(p.maxHistorySize, prefix + "MaxHistorySize", "Maximal size of object poses history (-1 for infinite)."); - - defs->optional(p.objectsPackage, prefix + "ObjectsPackage", "Name of the objects package to load from."); - defs->optional(p.loadFromObjectsPackage, prefix + "LoadFromObjectsPackage", - "If true, load the objects from the objects package on startup."); - - } - - void Segment::init() - { - ARMARX_CHECK_NOT_NULL(iceMemory.workingMemory); - - coreSegment = &iceMemory.workingMemory->addCoreSegment(p.coreClassSegmentName, arondto::RobotDescription::toAronType()); - coreSegment->setMaxHistorySize(p.maxHistorySize); - - if (p.loadFromObjectsPackage) - { - loadByObjectFinder(p.objectsPackage); - } - } - - - void Segment::connect() - { - } - - - void Segment::loadByObjectFinder(const std::string& package) - { - ObjectFinder finder(package); - - const auto knownArticulatedObjectDescriptions = finder.findAllArticulatedObjectsByDataset(true); - ARMARX_DEBUG << "Found " << knownArticulatedObjectDescriptions.size() << " articulated objects"; - - loadObjectsIntoMemory(knownArticulatedObjectDescriptions, package); - } - - void Segment::loadObjectsIntoMemory(const std::unordered_map<std::string, std::vector<armem::articulated_object::ArticulatedObjectDescription>>& datasets, const std::string& package) - { - const Time now = TimeUtil::GetTime(); - - const MemoryID providerID = coreSegment->id().withProviderSegmentName(package); - coreSegment->addProviderSegment(providerID.providerSegmentName); - - // ARMARX_INFO << "Loading up to " << infos.size() << " object classes from '" - // << objectFinder.getPackageName() << "' ..."; - Commit commit; - - for (const auto& [datasetName, descriptions] : datasets) - { - - for (const armem::articulated_object::ArticulatedObjectDescription& desc : descriptions) - { - EntityUpdate& update = commit.updates.emplace_back(); - update.entityID = providerID.withEntityName(desc.name); - update.timeArrived = update.timeCreated = update.timeSent = now; - - arondto::RobotDescription aronRobotDescription; - toAron(aronRobotDescription, desc); - // TODO toAron(aronRobotDescription.timestamp, now); - - update.instancesData = { aronRobotDescription.toAron()}; - } - - ARMARX_INFO << "Loaded " << commit.updates.size() << " articulated object classes from '" - << package << "' in dataset '" << datasetName << "'."; - } - iceMemory.commit(commit); - } - - - - std::unordered_map<armem::MemoryID, ::armarx::armem::articulated_object::ArticulatedObjectDescription> Segment::getKnownObjectClasses() const - { - std::unordered_map<armem::MemoryID, ::armarx::armem::articulated_object::ArticulatedObjectDescription> objects; - - for (const auto& [_, provSeg] : iceMemory.workingMemory->getCoreSegment(p.coreClassSegmentName)) - { - for (const auto& [name, entity] : provSeg.entities()) - { - for (const auto& snapshot : simox::alg::get_values(entity.history())) - { - const auto& entityInstance = snapshot.getInstance(0); - const auto description = robot::convertRobotDescription(entityInstance); - - if (not description) - { - ARMARX_WARNING << "Could not convert entity instance to 'RobotDescription'"; - continue; - } - - ARMARX_DEBUG << "Key is " << armem::MemoryID(snapshot.id()); - - objects.emplace(armem::MemoryID(snapshot.id()), *description); - } - } - } - - ARMARX_INFO << deactivateSpam(10) << "Number of known articulated object classes: " << objects.size(); - - return objects; - } - - - - // void Segment::RemoteGui::setup(const Segment& data) - // { - // using namespace armarx::RemoteGui::Client; - - // maxHistorySize.setValue(std::max(1, int(data.p.maxHistorySize))); - // maxHistorySize.setRange(1, 1e6); - // infiniteHistory.setValue(data.p.maxHistorySize == -1); - // discardSnapshotsWhileAttached.setValue(data.p.discardSnapshotsWhileAttached); - - // GridLayout grid; - // int row = 0; - // grid.add(Label("Max History Size"), {row, 0}).add(maxHistorySize, {row, 1}); - // row++; - // grid.add(Label("Infinite History Size"), {row, 0}).add(infiniteHistory, {row, 1}); - // row++; - // grid.add(Label("Discard Snapshots while Attached"), {row, 0}).add(discardSnapshotsWhileAttached, {row, 1}); - // row++; - - // group.setLabel("Data"); - // group.addChild(grid); - // } - - // void Segment::RemoteGui::update(Segment& data) - // { - // if (infiniteHistory.hasValueChanged() || maxHistorySize.hasValueChanged() - // || discardSnapshotsWhileAttached.hasValueChanged()) - // { - // std::scoped_lock lock(data.memoryMutex); - - // if (infiniteHistory.hasValueChanged() || maxHistorySize.hasValueChanged()) - // { - // data.p.maxHistorySize = infiniteHistory.getValue() ? -1 : maxHistorySize.getValue(); - // if (data.coreSegment) - // { - // data.coreSegment->setMaxHistorySize(long(data.p.maxHistorySize)); - // } - // } - - // data.p.discardSnapshotsWhileAttached = discardSnapshotsWhileAttached.getValue(); - // } - // } - -} // namespace armarx::armem::server::obj::articulated_object_class diff --git a/source/RobotAPI/libraries/armem_objects/server/articulated_object_class/Segment.h b/source/RobotAPI/libraries/armem_objects/server/articulated_object_class/Segment.h deleted file mode 100644 index e2a7bbc6f..000000000 --- a/source/RobotAPI/libraries/armem_objects/server/articulated_object_class/Segment.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * This file is part of ArmarX. - * - * ArmarX is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * ArmarX is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * @author Fabian Reister ( fabian dot reister at kit dot edu ) - * @date 2021 - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -#include <string> -#include <optional> -#include <mutex> -#include <unordered_map> - -#include <ArmarXCore/core/logging/Logging.h> -#include "ArmarXCore/core/application/properties/PropertyDefinitionContainer.h" - -// #include "ArmarXGui/libraries/RemoteGui/Client/Widgets.h" - -#include "RobotAPI/components/ArViz/Client/Client.h" - -#include "RobotAPI/libraries/armem/core/MemoryID.h" -#include "RobotAPI/libraries/armem_objects/types.h" - -#include <RobotAPI/libraries/ArmarXObjects/ObjectFinder.h> - -namespace armarx::armem -{ - namespace server - { - class MemoryToIceAdapter; - } - - namespace wm - { - class CoreSegment; - } -} // namespace armarx::armem - - -namespace armarx::armem::server::obj::articulated_object_class -{ - class Visu; - - class Segment : public armarx::Logging - { - public: - Segment(server::MemoryToIceAdapter& iceMemory, - std::mutex& memoryMutex); - - virtual ~Segment(); - - void connect(viz::Client arviz); - - void defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix = ""); - - void init(); - - std::unordered_map<armem::MemoryID, ::armarx::armem::articulated_object::ArticulatedObjectDescription> getKnownObjectClasses() const; - - - private: - void loadByObjectFinder(const std::string& package); - void loadObjectsIntoMemory(const std::unordered_map<std::string, std::vector<armem::articulated_object::ArticulatedObjectDescription>>& datasets, const std::string& package); - - server::MemoryToIceAdapter& iceMemory; - wm::CoreSegment* coreSegment = nullptr; - std::mutex& memoryMutex; - - struct Properties - { - std::string coreClassSegmentName = "ArticulatedObjectClass"; - int64_t maxHistorySize = -1; - - std::string objectsPackage = ObjectFinder::DefaultObjectsPackageName; - bool loadFromObjectsPackage = true; - }; - Properties p; - - // std::unique_ptr<Visu> visu; - - public: - - // struct RemoteGui - // { - // armarx::RemoteGui::Client::GroupBox group; - - // armarx::RemoteGui::Client::IntSpinBox maxHistorySize; - // armarx::RemoteGui::Client::CheckBox infiniteHistory; - // armarx::RemoteGui::Client::CheckBox discardSnapshotsWhileAttached; - - // void setup(const Segment& data); - // void update(Segment& data); - // }; - - }; - -} // namespace armarx::armem::server::obj::articulated_object_class diff --git a/source/RobotAPI/libraries/armem_objects/server/articulated_object_instance/Segment.cpp b/source/RobotAPI/libraries/armem_objects/server/articulated_object_instance/Segment.cpp deleted file mode 100644 index dba8c91a8..000000000 --- a/source/RobotAPI/libraries/armem_objects/server/articulated_object_instance/Segment.cpp +++ /dev/null @@ -1,175 +0,0 @@ -#include "Segment.h" - -#include <sstream> - -#include <SimoxUtility/algorithm/get_map_keys_values.h> - -#include <ArmarXCore/core/time/TimeUtil.h> -#include <ArmarXCore/core/exceptions/local/ExpressionException.h> - -#include <RobotAPI/libraries/core/remoterobot/RemoteRobot.h> - -#include <RobotAPI/libraries/aron/common/aron_conversions.h> - -#include <RobotAPI/libraries/armem/core/aron_conversions.h> -#include <RobotAPI/libraries/armem/client/Writer.h> -#include <RobotAPI/libraries/armem/client/query/Builder.h> -#include <RobotAPI/libraries/armem/client/query/query_fns.h> -#include <RobotAPI/libraries/armem/aron/MemoryID.aron.generated.h> - -#include <RobotAPI/libraries/armem_robot/aron/Robot.aron.generated.h> -#include <RobotAPI/libraries/armem_robot/aron/RobotDescription.aron.generated.h> -#include <RobotAPI/libraries/armem_robot/aron_conversions.h> -#include <RobotAPI/libraries/armem_robot/robot_conversions.h> - -#include <RobotAPI/libraries/armem_objects/server/articulated_object_class/Segment.h> - -#include "Visu.h" - - -namespace armarx::armem::server::obj::articulated_object_instance -{ - - Segment::Segment(armem::server::MemoryToIceAdapter& memoryToIceAdapter, std::mutex& memoryMutex) : - iceMemory(memoryToIceAdapter), - memoryMutex(memoryMutex) - { - Logging::setTag("ArticulatedObjectInstanceSegment"); - } - - Segment::~Segment() = default; - - void Segment::defineProperties(armarx::PropertyDefinitionsPtr& defs, const std::string& prefix) - { - defs->optional(p.coreInstanceSegmentName, prefix + "CoreSegmentName", "Name of the object instance core segment."); - defs->optional(p.maxHistorySize, prefix + "MaxHistorySize", "Maximal size of object poses history (-1 for infinite)."); - } - - void Segment::init() - { - ARMARX_CHECK_NOT_NULL(iceMemory.workingMemory); - - coreSegment = &iceMemory.workingMemory->addCoreSegment(p.coreInstanceSegmentName, arondto::Robot::toAronType()); - coreSegment->setMaxHistorySize(p.maxHistorySize); - - } - - void Segment::connect(viz::Client arviz) - { - this->visu = std::make_unique<Visu>(arviz, *this); - visu->init(); - } - - void Segment::setArticulatedObjectClassSegment(const articulated_object_class::Segment& segment) - { - classSegment = &segment; - } - - ::armarx::armem::articulated_object::ArticulatedObjects Segment::getArticulatedObjects() const - { - ARMARX_CHECK_NOT_NULL(classSegment); - const auto knownObjectClasses = classSegment->getKnownObjectClasses(); - - ARMARX_DEBUG << "Class segment has " << knownObjectClasses.size() << " known articulated objects"; - - const auto escape = [](std::string & v) - { - v = simox::alg::replace_all(v, "/", "\\/"); - }; - - const auto resolveDescriptionLink = [&](auto & articulatedObject, const auto & aronDescriptionLink) -> bool - { - armem::MemoryID descriptionLink; - fromAron(aronDescriptionLink, descriptionLink); - - escape(descriptionLink.providerSegmentName); - - ARMARX_DEBUG << "Lookup key is " << descriptionLink; - - // const auto keys = simox::alg::get_keys(knownObjectClasses); - // ARMARX_DEBUG << "Known keys " << keys; - - const auto it = knownObjectClasses.find(descriptionLink); - if (it == knownObjectClasses.end()) - { - ARMARX_WARNING << "Unknown object class " << descriptionLink - << "Known classes are " << simox::alg::get_keys(knownObjectClasses); - return false; - } - - articulatedObject.description = it->second; - return true; - }; - - ::armarx::armem::articulated_object::ArticulatedObjects objects; - for (const auto& [_, provSeg] : iceMemory.workingMemory->getCoreSegment(p.coreInstanceSegmentName)) - { - for (const auto& [_, entity] : provSeg.entities()) - { - const auto& entityInstance = entity.getLatestSnapshot().getInstance(0); - - arondto::Robot aronArticulatedObject; - aronArticulatedObject.fromAron(entityInstance.data()); - - armem::articulated_object::ArticulatedObject articulatedObject; - fromAron(aronArticulatedObject, articulatedObject); - - // resolve memory link for description - const arondto::MemoryID& aronDescriptionLink = aronArticulatedObject.description; - if (not resolveDescriptionLink(articulatedObject, aronDescriptionLink)) - { - continue; - } - - objects.push_back(articulatedObject); - } - } - - return objects; - } - - - - // void Segment::RemoteGui::setup(const Segment& data) - // { - // using namespace armarx::RemoteGui::Client; - - // maxHistorySize.setValue(std::max(1, int(data.p.maxHistorySize))); - // maxHistorySize.setRange(1, 1e6); - // infiniteHistory.setValue(data.p.maxHistorySize == -1); - // discardSnapshotsWhileAttached.setValue(data.p.discardSnapshotsWhileAttached); - - // GridLayout grid; - // int row = 0; - // grid.add(Label("Max History Size"), {row, 0}).add(maxHistorySize, {row, 1}); - // row++; - // grid.add(Label("Infinite History Size"), {row, 0}).add(infiniteHistory, {row, 1}); - // row++; - // grid.add(Label("Discard Snapshots while Attached"), {row, 0}).add(discardSnapshotsWhileAttached, {row, 1}); - // row++; - - // group.setLabel("Data"); - // group.addChild(grid); - // } - - // void Segment::RemoteGui::update(Segment& data) - // { - // if (infiniteHistory.hasValueChanged() || maxHistorySize.hasValueChanged() - // || discardSnapshotsWhileAttached.hasValueChanged()) - // { - // std::scoped_lock lock(data.memoryMutex); - - // if (infiniteHistory.hasValueChanged() || maxHistorySize.hasValueChanged()) - // { - // data.p.maxHistorySize = infiniteHistory.getValue() ? -1 : maxHistorySize.getValue(); - // if (data.coreSegment) - // { - // data.coreSegment->setMaxHistorySize(long(data.p.maxHistorySize)); - // } - // } - - // data.p.discardSnapshotsWhileAttached = discardSnapshotsWhileAttached.getValue(); - // } - // } - -} // namespace armarx::armem::server::obj::articulated_object_instance diff --git a/source/RobotAPI/libraries/armem_objects/server/articulated_object_instance/Segment.h b/source/RobotAPI/libraries/armem_objects/server/articulated_object_instance/Segment.h deleted file mode 100644 index 2d50be817..000000000 --- a/source/RobotAPI/libraries/armem_objects/server/articulated_object_instance/Segment.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * This file is part of ArmarX. - * - * ArmarX is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License version 2 as - * published by the Free Software Foundation. - * - * ArmarX is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - * - * @author Fabian Reister ( fabian dot reister at kit dot edu ) - * @date 2021 - * @copyright http://www.gnu.org/licenses/gpl-2.0.txt - * GNU General Public License - */ - -#pragma once - -#include <cstdint> -#include <map> -#include <string> -#include <optional> -#include <mutex> - -#include "ArmarXCore/core/application/properties/PropertyDefinitionContainer.h" - -#include "ArmarXGui/libraries/RemoteGui/Client/Widgets.h" - -#include <RobotAPI/interface/core/RobotState.h> - -#include <RobotAPI/libraries/armem/core/workingmemory/Memory.h> -#include <RobotAPI/libraries/armem/server/MemoryToIceAdapter.h> - -#include "RobotAPI/components/ArViz/Client/Client.h" - -#include "RobotAPI/libraries/armem_objects/types.h" - - -namespace armarx::armem::server::obj::articulated_object_class -{ - class Segment; -} - -namespace armarx::armem::server::obj::articulated_object_instance -{ - class Visu; - - class Segment : public armarx::Logging - { - public: - - struct CommitStats - { - int numUpdated = 0; - }; - - - Segment(server::MemoryToIceAdapter& iceMemory, - std::mutex& memoryMutex); - - virtual ~Segment(); - - void connect(viz::Client arviz); - - void defineProperties(armarx::PropertyDefinitionsPtr& defs, const std::string& prefix = ""); - - void init(); - - void setArticulatedObjectClassSegment(const articulated_object_class::Segment& segment); - - ::armarx::armem::articulated_object::ArticulatedObjects getArticulatedObjects() const; - - private: - - server::MemoryToIceAdapter& iceMemory; - wm::CoreSegment* coreSegment = nullptr; - std::mutex& memoryMutex; - - articulated_object_class::Segment const* classSegment; - - - struct Properties - { - std::string coreInstanceSegmentName = "ArticulatedObjectInstance"; - int64_t maxHistorySize = -1; - }; - Properties p; - - std::unique_ptr<Visu> visu; - - public: - - // struct RemoteGui - // { - // armarx::RemoteGui::Client::GroupBox group; - - // armarx::RemoteGui::Client::IntSpinBox maxHistorySize; - // armarx::RemoteGui::Client::CheckBox infiniteHistory; - // armarx::RemoteGui::Client::CheckBox discardSnapshotsWhileAttached; - - // void setup(const Segment& data); - // void update(Segment& data); - // }; - - }; - -} // namespace armarx::armem::server::obj::articulated_object_instance -- GitLab