diff --git a/source/VisionX/libraries/armem_human/CMakeLists.txt b/source/VisionX/libraries/armem_human/CMakeLists.txt index 7485603469c80601a7f1e4f53ae8fff39857480b..8f5cccf7c8c2d498b781925a5683a32ebad1b395 100644 --- a/source/VisionX/libraries/armem_human/CMakeLists.txt +++ b/source/VisionX/libraries/armem_human/CMakeLists.txt @@ -21,6 +21,7 @@ armarx_add_library( SOURCES aron_conversions.cpp json_conversions.cpp + memory_ids.cpp client/HumanPoseReader.cpp HEADERS @@ -28,6 +29,7 @@ armarx_add_library( aron_conversions.h forward_declarations.h json_conversions.h + memory_ids.h client/HumanPoseReader.h ARON_FILES diff --git a/source/VisionX/libraries/armem_human/forward_declarations.h b/source/VisionX/libraries/armem_human/forward_declarations.h index cf81d713a421be8de0bbc430a37571640e9a0b7d..8f59ef5ce889b98d5f0e2d738834cddbe75dd852 100644 --- a/source/VisionX/libraries/armem_human/forward_declarations.h +++ b/source/VisionX/libraries/armem_human/forward_declarations.h @@ -29,4 +29,6 @@ namespace armarx::human::arondto class Gender; class Handedness; class Profile; + + class FaceRecognition; } diff --git a/source/VisionX/libraries/armem_human/memory_ids.cpp b/source/VisionX/libraries/armem_human/memory_ids.cpp new file mode 100644 index 0000000000000000000000000000000000000000..70efb93d82e77a275b77f5f4861ea43437e17e9f --- /dev/null +++ b/source/VisionX/libraries/armem_human/memory_ids.cpp @@ -0,0 +1,43 @@ +/* + * 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/>. + * + * @package VisionX::ArmarXObjects::armem_human + * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) + * @date 2023 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#include "memory_ids.h" + + +namespace armarx +{ + + const armem::MemoryID human::MemoryID{"Human"}; + + const armem::MemoryID human::FaceRecognitionCoreSegmentID = + MemoryID.withCoreSegmentName("FaceRecognition"); + + const armem::MemoryID human::ProfileCoreSegmentID = + MemoryID.withCoreSegmentName("Profile"); + + const armem::MemoryID human::PersonInstanceCoreSegmentID = + MemoryID.withCoreSegmentName("PersonInstance"); + + const armem::MemoryID human::PoseCoreSegmentID = + MemoryID.withCoreSegmentName("Pose"); + +} // namespace armarx diff --git a/source/VisionX/libraries/armem_human/memory_ids.h b/source/VisionX/libraries/armem_human/memory_ids.h new file mode 100644 index 0000000000000000000000000000000000000000..cbaed60f28309c02bc0bea47faad2ee311d9256f --- /dev/null +++ b/source/VisionX/libraries/armem_human/memory_ids.h @@ -0,0 +1,38 @@ +/* + * 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/>. + * + * @package VisionX::ArmarXObjects::armem_human + * @author Rainer Kartmann ( rainer dot kartmann at kit dot edu ) + * @date 2023 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +#include <RobotAPI/libraries/armem/core/MemoryID.h> + + +namespace armarx::human +{ + + extern const armem::MemoryID MemoryID; + + extern const armem::MemoryID FaceRecognitionCoreSegmentID; + extern const armem::MemoryID PersonInstanceCoreSegmentID; + extern const armem::MemoryID ProfileCoreSegmentID; + extern const armem::MemoryID PoseCoreSegmentID; + +} // namespace armarx::human diff --git a/source/VisionX/libraries/armem_human/server/PersonInstanceSegment.cpp b/source/VisionX/libraries/armem_human/server/PersonInstanceSegment.cpp index 7e3403b154751d679158e0b93bd88017e9d2e3c8..e17b20ba36b9b31cddd08cf490e038c141dc624b 100644 --- a/source/VisionX/libraries/armem_human/server/PersonInstanceSegment.cpp +++ b/source/VisionX/libraries/armem_human/server/PersonInstanceSegment.cpp @@ -25,23 +25,25 @@ #include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h> #include <VisionX/libraries/armem_human/aron/PersonInstance.aron.generated.h> - +#include <VisionX/libraries/armem_human/memory_ids.h> namespace armarx::armem::server::human { - const std::string PersonInstanceSegment::CORE_SEGMENT_NAME = "PersonInstance"; + const std::string PersonInstanceSegment::CORE_SEGMENT_NAME = + armarx::human::PersonInstanceCoreSegmentID.coreSegmentName; PersonInstanceSegment::PersonInstanceSegment(armem::server::MemoryToIceAdapter& iceMemory) : - Base(iceMemory, CORE_SEGMENT_NAME, - armarx::human::arondto::PersonInstance::ToAronType(), 32) + Base(iceMemory, CORE_SEGMENT_NAME, armarx::human::arondto::PersonInstance::ToAronType(), 32) { } - void PersonInstanceSegment::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix) + void + PersonInstanceSegment::defineProperties(armarx::PropertyDefinitionsPtr defs, + const std::string& prefix) { Base::defineProperties(defs, prefix); } -} +} // namespace armarx::armem::server::human diff --git a/source/VisionX/libraries/armem_human/server/PoseSegment.cpp b/source/VisionX/libraries/armem_human/server/PoseSegment.cpp index 607e043fa242bee0f044124ca00d16d57fbfcbe4..3b4d6f5ccad100ef0c5f1de0ba6eaf98493d862a 100644 --- a/source/VisionX/libraries/armem_human/server/PoseSegment.cpp +++ b/source/VisionX/libraries/armem_human/server/PoseSegment.cpp @@ -25,22 +25,25 @@ #include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h> #include <VisionX/libraries/armem_human/aron/BODY_25Pose.aron.generated.h> +#include <VisionX/libraries/armem_human/memory_ids.h> namespace armarx::armem::server::human { - const std::string PoseSegment::CORE_SEGMENT_NAME = "Pose"; + const std::string PoseSegment::CORE_SEGMENT_NAME = + armarx::human::PoseCoreSegmentID.coreSegmentName; PoseSegment::PoseSegment(armem::server::MemoryToIceAdapter& iceMemory) : - Base(iceMemory, CORE_SEGMENT_NAME, - armarx::human::arondto::Body25Pose3D::ToAronType(), 256) + Base(iceMemory, CORE_SEGMENT_NAME, armarx::human::arondto::Body25Pose3D::ToAronType(), 256) { } - void PoseSegment::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix) + void + PoseSegment::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix) { Base::defineProperties(defs, prefix); } -} + +} // namespace armarx::armem::server::human diff --git a/source/VisionX/libraries/armem_human/server/face_recognition/Segment.cpp b/source/VisionX/libraries/armem_human/server/face_recognition/Segment.cpp index f2c805f13628233dc71e888746c70c460a7fb3b1..b220f8add04ffda69e093d0dc754fb85974cf879 100644 --- a/source/VisionX/libraries/armem_human/server/face_recognition/Segment.cpp +++ b/source/VisionX/libraries/armem_human/server/face_recognition/Segment.cpp @@ -25,30 +25,36 @@ #include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h> #include <VisionX/libraries/armem_human/aron/FaceRecognition.aron.generated.h> +#include <VisionX/libraries/armem_human/memory_ids.h> namespace armarx::armem::server::human::facerecog { - const std::string Segment::CORE_SEGMENT_NAME = "FaceRecognition"; + const std::string Segment::CORE_SEGMENT_NAME = + armarx::human::FaceRecognitionCoreSegmentID.coreSegmentName; Segment::Segment(armem::server::MemoryToIceAdapter& iceMemory) : - Base(iceMemory, CORE_SEGMENT_NAME, - armarx::human::arondto::FaceRecognition::ToAronType(), 64) + Base(iceMemory, + CORE_SEGMENT_NAME, + armarx::human::arondto::FaceRecognition::ToAronType(), + 64) { } - void Segment::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix) + void + Segment::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix) { Base::defineProperties(defs, prefix); } - void Segment::init() + void + Segment::init() { Base::init(); } -} +} // namespace armarx::armem::server::human::facerecog diff --git a/source/VisionX/libraries/armem_human/server/profile/Segment.cpp b/source/VisionX/libraries/armem_human/server/profile/Segment.cpp index 6d35f7f32bb821d8c5afc9c06629f7d72f16327e..c373c9b3c0fde0b89a0997bc8d506d20aa728b7d 100644 --- a/source/VisionX/libraries/armem_human/server/profile/Segment.cpp +++ b/source/VisionX/libraries/armem_human/server/profile/Segment.cpp @@ -24,47 +24,52 @@ #include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h> +#include <RobotAPI/libraries/armem/server/MemoryToIceAdapter.h> + #include <VisionX/libraries/armem_human/aron/Profile.aron.generated.h> +#include <VisionX/libraries/armem_human/memory_ids.h> #include "Finder.h" -#include <RobotAPI/libraries/armem/server/MemoryToIceAdapter.h> - namespace fs = std::filesystem; namespace armarx::armem::server::human::profile { - const std::string Segment::CORE_SEGMENT_NAME = "Profile"; + const std::string Segment::CORE_SEGMENT_NAME = + armarx::human::ProfileCoreSegmentID.coreSegmentName; + using Profile = armarx::human::arondto::Profile; Segment::Segment(armem::server::MemoryToIceAdapter& iceMemory) : - Base(iceMemory, CORE_SEGMENT_NAME, - armarx::human::arondto::Profile::ToAronType(), 64) + Base(iceMemory, CORE_SEGMENT_NAME, armarx::human::arondto::Profile::ToAronType(), 64) { } - Segment::Properties::PriorKnowledge::PriorKnowledge() : - packageName(Finder::DefaultPackageName) + Segment::Properties::PriorKnowledge::PriorKnowledge() : packageName(Finder::DefaultPackageName) { } - void Segment::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix) + void + Segment::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix) { Base::defineProperties(defs, prefix); - defs->optional(properties.priorKnowledge.load, prefix + "pk.load", + defs->optional(properties.priorKnowledge.load, + prefix + "pk.load", "Load profiles from prior knowledge on startup."); - defs->optional(properties.priorKnowledge.packageName, prefix + "pk.packageName", + defs->optional(properties.priorKnowledge.packageName, + prefix + "pk.packageName", "ArmarX package to load human profiles from."); } - void Segment::init() + void + Segment::init() { Base::init(); @@ -75,13 +80,15 @@ namespace armarx::armem::server::human::profile } - void Segment::loadPriorKnowledge() + void + Segment::loadPriorKnowledge() { loadPriorKnowledge(Finder::DefaultPackageName); } - void Segment::loadPriorKnowledge(const std::string& dataPackageName) + void + Segment::loadPriorKnowledge(const std::string& dataPackageName) { const armem::Time now = armem::Time::Now(); @@ -95,15 +102,16 @@ namespace armarx::armem::server::human::profile if (std::optional<Profile> profile = info.loadProfile()) { armem::EntityUpdate& update = commit.add(); - update.entityID = getCoreSegment().id() - .withProviderSegmentName(dataPackageName) - .withEntityName(info.id()); + update.entityID = getCoreSegment() + .id() + .withProviderSegmentName(dataPackageName) + .withEntityName(info.id()); update.timeCreated = update.timeSent = update.timeArrived = now; - update.instancesData = { profile->toAron() }; + update.instancesData = {profile->toAron()}; } } iceMemory.commit(commit); } -} +} // namespace armarx::armem::server::human::profile