diff --git a/scenarios/memory_to_debug_observer/config/MemoryToDebugObserver.cfg b/scenarios/memory_to_debug_observer/config/MemoryToDebugObserver.cfg index a230049a091bc90361567f1e56dd87f98101412f..b55058e92b04b70190bedc2ecfcd4a675a843557 100644 --- a/scenarios/memory_to_debug_observer/config/MemoryToDebugObserver.cfg +++ b/scenarios/memory_to_debug_observer/config/MemoryToDebugObserver.cfg @@ -163,10 +163,18 @@ # ArmarX.MemoryToDebugObserver.p.memoryToDebugObserverJson: Configuration of MemoryToDebugObserver in JSON format. # Attributes: -# - Default: {"plottedValues":[{"aronPath":["joints","position","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocity","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","position","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocity","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","position","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocity","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]}]} +# - Default: {"plottedValues":[{"aronPath":["joints","position","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_1_Yaw.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","positionTarget","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_1_Yaw.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","relativePosition","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_1_Yaw.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocity","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_1_Yaw.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocityTarget","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_1_Yaw.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","torque","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_1_Yaw.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","motorCurrent","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_1_Yaw.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","currentTarget","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_1_Yaw.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","position","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_2_Hemisphere_A.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","positionTarget","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_2_Hemisphere_A.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","relativePosition","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_2_Hemisphere_A.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocity","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_2_Hemisphere_A.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocityTarget","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_2_Hemisphere_A.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","torque","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_2_Hemisphere_A.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","motorCurrent","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_2_Hemisphere_A.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","currentTarget","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_2_Hemisphere_A.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","position","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_3_Hemisphere_B.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","positionTarget","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_3_Hemisphere_B.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","relativePosition","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_3_Hemisphere_B.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocity","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_3_Hemisphere_B.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocityTarget","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_3_Hemisphere_B.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","torque","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_3_Hemisphere_B.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","motorCurrent","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_3_Hemisphere_B.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","currentTarget","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_3_Hemisphere_B.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]}]} # - Case sensitivity: yes # - Required: no -# ArmarX.MemoryToDebugObserver.p.memoryToDebugObserverJson = {"plottedValues":[{"aronPath":["joints","position","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocity","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","position","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocity","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","position","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocity","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]}]} +# ArmarX.MemoryToDebugObserver.p.memoryToDebugObserverJson = {"plottedValues":[{"aronPath":["joints","position","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_1_Yaw.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","positionTarget","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_1_Yaw.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","relativePosition","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_1_Yaw.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocity","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_1_Yaw.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocityTarget","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_1_Yaw.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","torque","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_1_Yaw.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","motorCurrent","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_1_Yaw.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","currentTarget","Neck_1_Yaw"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_1_Yaw.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","position","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_2_Hemisphere_A.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","positionTarget","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_2_Hemisphere_A.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","relativePosition","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_2_Hemisphere_A.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocity","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_2_Hemisphere_A.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocityTarget","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_2_Hemisphere_A.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","torque","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_2_Hemisphere_A.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","motorCurrent","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_2_Hemisphere_A.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","currentTarget","Neck_2_Hemisphere_A"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_2_Hemisphere_A.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","position","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_3_Hemisphere_B.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","positionTarget","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_3_Hemisphere_B.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","relativePosition","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_3_Hemisphere_B.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocity","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_3_Hemisphere_B.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","velocityTarget","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_3_Hemisphere_B.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","torque","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_3_Hemisphere_B.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","motorCurrent","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_3_Hemisphere_B.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["joints","currentTarget","Neck_3_Hemisphere_B"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]},{"aronPath":["extraLongs","Neck_3_Hemisphere_B.absoluteEncoderTicks"],"entityID":["RobotState","Proprioception","Armar7","Armar7"]}]} + + +# ArmarX.MemoryToDebugObserver.p.pollFrequencyHz: +# Attributes: +# - Default: 30 +# - Case sensitivity: yes +# - Required: no +# ArmarX.MemoryToDebugObserver.p.pollFrequencyHz = 30 # ArmarX.RedirectStdout: Redirect std::cout and std::cerr to ArmarXLog diff --git a/source/RobotAPI/components/armem/client/MemoryToDebugObserver/Component.cpp b/source/RobotAPI/components/armem/client/MemoryToDebugObserver/Component.cpp index 89782e6df70a51e35725ed198165f92d4d20029b..2217e1d8137ab275a387b917ea623f6d59b36518 100644 --- a/source/RobotAPI/components/armem/client/MemoryToDebugObserver/Component.cpp +++ b/source/RobotAPI/components/armem/client/MemoryToDebugObserver/Component.cpp @@ -49,7 +49,13 @@ namespace armarx::memory_to_debug_observer { std::vector<std::string> attributes{ "position", + "positionTarget", + "relativePosition", "velocity", + "velocityTarget", + "torque", + "motorCurrent", + "currentTarget", }; for (const std::string& attribute : attributes) { @@ -57,6 +63,10 @@ namespace armarx::memory_to_debug_observer .entityID = robotEntityId, .aronPath = {{"joints", attribute, jointName}}, }); + properties.memoryToDebugObserver.plottedValues.push_back({ + .entityID = robotEntityId, + .aronPath = {{"extraLongs", jointName + ".absoluteEncoderTicks"}}, + }); } } diff --git a/source/RobotAPI/components/units/RobotUnit/util/ControlThreadOutputBuffer.cpp b/source/RobotAPI/components/units/RobotUnit/util/ControlThreadOutputBuffer.cpp index bedfc430f0dee9f2030ac495d2ba6dd74bfa1350..8f8738d48a54c135198d48a370d0d36006d5a129 100644 --- a/source/RobotAPI/components/units/RobotUnit/util/ControlThreadOutputBuffer.cpp +++ b/source/RobotAPI/components/units/RobotUnit/util/ControlThreadOutputBuffer.cpp @@ -362,7 +362,7 @@ namespace armarx const auto numExcessEntries = std::max(requiredAdditionalEntries, numEntries - entries.size()); const auto requiredSize = entries.size() + numExcessEntries; - ARMARX_WARNING << "Iteration " << iterationCount << " required " + ARMARX_VERBOSE << "Iteration " << iterationCount << " required " << requiredAdditionalEntries << " | " << numExcessEntries << " additional message entries. \n" << "The requested total number of entries is " << requiredSize << ". \n" @@ -371,7 +371,7 @@ namespace armarx << getMaximalNumberOfBufferEntries(); if (requiredSize > getMaximalNumberOfBufferEntries()) { - ARMARX_WARNING << deactivateSpam(1, to_string(requiredSize)) << "Iteration " + ARMARX_VERBOSE << deactivateSpam(1, to_string(requiredSize)) << "Iteration " << iterationCount << " would require " << requiredSize << " message entries, but the maximal number of entries is " << getMaximalNumberOfBufferEntries(); diff --git a/source/RobotAPI/gui-plugins/KinematicUnitPlugin/KinematicUnitGuiPlugin.cpp b/source/RobotAPI/gui-plugins/KinematicUnitPlugin/KinematicUnitGuiPlugin.cpp index 9b56d6c370d6f24ea3dd98b07ed2bcb0b3ea7d2a..440815d7d495c3a7a0e57acdde433e4a3a1d672f 100644 --- a/source/RobotAPI/gui-plugins/KinematicUnitPlugin/KinematicUnitGuiPlugin.cpp +++ b/source/RobotAPI/gui-plugins/KinematicUnitPlugin/KinematicUnitGuiPlugin.cpp @@ -1353,8 +1353,8 @@ namespace armarx auto it = reportedJointStatuses.find(rn[i]->getName()); if (it == reportedJointStatuses.end()) { - ARMARX_WARNING << deactivateSpam(5, rn[i]->getName()) << "Joint Status for " << rn[i]->getName() - << " was not reported!"; + ARMARX_VERBOSE << deactivateSpam(5, rn[i]->getName()) << "Joint Status for " + << rn[i]->getName() << " was not reported!"; continue; } JointStatus currentStatus = it->second; diff --git a/source/RobotAPI/libraries/ArmarXObjects/CMakeLists.txt b/source/RobotAPI/libraries/ArmarXObjects/CMakeLists.txt index 3e503f9a7f04ff1fdcdb4bb1988ee04f0b18666d..879422d20200f53cc0befe9b1c28f6b59220396a 100644 --- a/source/RobotAPI/libraries/ArmarXObjects/CMakeLists.txt +++ b/source/RobotAPI/libraries/ArmarXObjects/CMakeLists.txt @@ -82,7 +82,6 @@ armarx_enable_aron_file_generation_for_target( "${LIB_NAME}" ARON_FILES aron/ObjectID.xml - aron/ObjectNames.xml aron/ObjectPose.xml aron/ObjectType.xml aron/PoseManifoldGaussian.xml diff --git a/source/RobotAPI/libraries/armem_objects/aron/ObjectClass.xml b/source/RobotAPI/libraries/armem_objects/aron/ObjectClass.xml index 019987f5054e844478066d377ad0bf1e948b6db7..190e105b4d17d222543ff72db8e2feada3db7b5d 100644 --- a/source/RobotAPI/libraries/armem_objects/aron/ObjectClass.xml +++ b/source/RobotAPI/libraries/armem_objects/aron/ObjectClass.xml @@ -8,7 +8,7 @@ Core segment type of Object/Class. <PackagePath package="RobotAPI" path="libraries/aron/common/aron/OrientedBox.xml" /> <PackagePath package="RobotAPI" path="libraries/aron/common/aron/PackagePath.xml" /> <PackagePath package="RobotAPI" path="libraries/ArmarXObjects/aron/ObjectID.xml" /> - <PackagePath package="RobotAPI" path="libraries/ArmarXObjects/aron/ObjectNames.xml" /> + <PackagePath package="RobotAPI" path="libraries/aron/common/aron/Names.xml" /> <PackagePath package="RobotAPI" path="libraries/armem/aron/MemoryID.xml" /> </AronIncludes> <GenerateTypes> @@ -83,7 +83,7 @@ Core segment type of Object/Class. </ObjectChild> <ObjectChild key="names"> - <armarx::arondto::ObjectNames /> + <armarx::arondto::Names /> </ObjectChild> <ObjectChild key="ivtFeatures"> diff --git a/source/RobotAPI/libraries/armem_objects/aron_conversions.cpp b/source/RobotAPI/libraries/armem_objects/aron_conversions.cpp index da32c2771a2149f58e5ba3a1a01db93ecbe71028..62ee858c9a198e2141228d56fd5af09e1c30f1af 100644 --- a/source/RobotAPI/libraries/armem_objects/aron_conversions.cpp +++ b/source/RobotAPI/libraries/armem_objects/aron_conversions.cpp @@ -4,50 +4,53 @@ #include <RobotAPI/libraries/armem/core/aron_conversions.h> #include <RobotAPI/libraries/aron/common/aron_conversions.h> -namespace armarx::armem +namespace armarx { void - fromAron(const arondto::ObjectInstance& dto, objpose::arondto::ObjectPose& bo) + armem::fromAron(const arondto::ObjectInstance& dto, objpose::arondto::ObjectPose& bo) { bo = dto.pose; } void - toAron(arondto::ObjectInstance& dto, const objpose::arondto::ObjectPose& bo) + armem::toAron(arondto::ObjectInstance& dto, const objpose::arondto::ObjectPose& bo) { dto.pose = bo; } void - fromAron(const arondto::ObjectInstance& dto, objpose::ObjectPose& bo) + armem::fromAron(const arondto::ObjectInstance& dto, objpose::ObjectPose& bo) { objpose::fromAron(dto.pose, bo); } void - toAron(arondto::ObjectInstance& dto, const objpose::ObjectPose& bo) + armem::toAron(arondto::ObjectInstance& dto, const objpose::ObjectPose& bo) { objpose::toAron(dto.pose, bo); } /* Attachments */ void - fromAron(const arondto::attachment::AgentDescription& dto, attachment::AgentDescription& bo) + armem::fromAron(const arondto::attachment::AgentDescription& dto, + attachment::AgentDescription& bo) { fromAron(dto.id, bo.id); aron::fromAron(dto.frame, bo.frame); } void - toAron(arondto::attachment::AgentDescription& dto, const attachment::AgentDescription& bo) + armem::toAron(arondto::attachment::AgentDescription& dto, + const attachment::AgentDescription& bo) { toAron(dto.id, bo.id); aron::toAron(dto.frame, bo.frame); } void - fromAron(const arondto::attachment::ObjectAttachment& dto, attachment::ObjectAttachment& bo) + armem::fromAron(const arondto::attachment::ObjectAttachment& dto, + attachment::ObjectAttachment& bo) { fromAron(dto.agent, bo.agent); aron::fromAron(dto.transformation, bo.transformation); @@ -57,7 +60,8 @@ namespace armarx::armem } void - toAron(arondto::attachment::ObjectAttachment& dto, const attachment::ObjectAttachment& bo) + armem::toAron(arondto::attachment::ObjectAttachment& dto, + const attachment::ObjectAttachment& bo) { toAron(dto.agent, bo.agent); aron::toAron(dto.transformation, bo.transformation); @@ -67,8 +71,8 @@ namespace armarx::armem } void - fromAron(const arondto::attachment::ArticulatedObjectAttachment& dto, - attachment::ArticulatedObjectAttachment& bo) + armem::fromAron(const arondto::attachment::ArticulatedObjectAttachment& dto, + attachment::ArticulatedObjectAttachment& bo) { fromAron(dto.agent, bo.agent); aron::fromAron(dto.transformation, bo.transformation); @@ -78,8 +82,8 @@ namespace armarx::armem } void - toAron(arondto::attachment::ArticulatedObjectAttachment& dto, - const attachment::ArticulatedObjectAttachment& bo) + armem::toAron(arondto::attachment::ArticulatedObjectAttachment& dto, + const attachment::ArticulatedObjectAttachment& bo) { toAron(dto.agent, bo.agent); aron::toAron(dto.transformation, bo.transformation); @@ -89,7 +93,7 @@ namespace armarx::armem } void - toAron(arondto::Marker& dto, const marker::Marker& bo) + armem::toAron(arondto::Marker& dto, const marker::Marker& bo) { dto.name = bo.name; armarx::toAron(dto.robotGlobal, bo.robotGlobal); @@ -100,7 +104,7 @@ namespace armarx::armem } void - fromAron(const arondto::Marker& dto, marker::Marker& bo) + armem::fromAron(const arondto::Marker& dto, marker::Marker& bo) { bo.name = dto.name; armarx::fromAron(dto.robotGlobal, bo.robotGlobal); @@ -109,13 +113,13 @@ namespace armarx::armem armarx::fromAron(dto.markerPose, bo.markerPose); } -} // namespace armarx::armem +} // namespace armarx -namespace armarx::armem::clazz +namespace armarx::armem { void - fromAron(const arondto::Feature& dto, Feature& bo) + clazz::fromAron(const arondto::Feature& dto, Feature& bo) { bo.angle = dto.angle; bo.scale = dto.scale; @@ -125,7 +129,7 @@ namespace armarx::armem::clazz } void - toAron(arondto::Feature& dto, const Feature& bo) + clazz::toAron(arondto::Feature& dto, const Feature& bo) { dto.angle = bo.angle; dto.scale = bo.scale; @@ -135,7 +139,7 @@ namespace armarx::armem::clazz } void - fromAron(const arondto::ObjectClass& dto, ObjectClass& bo) + clazz::fromAron(const arondto::ObjectClass& dto, ObjectClass& bo) { armarx::fromAron(dto.id, bo.id); armarx::fromAron(dto.simoxXmlPath, bo.simoxXmlPath); @@ -147,6 +151,7 @@ namespace armarx::armem::clazz armarx::fromAron(dto.meshObjPath, bo.meshObjPath); armarx::fromAron(dto.aabb, bo.aabb); armarx::fromAron(dto.oobb, bo.oobb); + fromAron(dto.names, bo.names); bo.ivtFeatures.clear(); for (const auto& i : dto.ivtFeatures) { @@ -155,7 +160,7 @@ namespace armarx::armem::clazz } void - toAron(arondto::ObjectClass& dto, const ObjectClass& bo) + clazz::toAron(arondto::ObjectClass& dto, const ObjectClass& bo) { armarx::toAron(dto.id, bo.id); armarx::toAron(dto.simoxXmlPath, bo.simoxXmlPath); @@ -167,6 +172,7 @@ namespace armarx::armem::clazz armarx::toAron(dto.meshObjPath, bo.meshObjPath); armarx::toAron(dto.aabb, bo.aabb); armarx::toAron(dto.oobb, bo.oobb); + toAron(dto.names, bo.names); dto.ivtFeatures.clear(); for (const auto& i : bo.ivtFeatures) { @@ -174,7 +180,7 @@ namespace armarx::armem::clazz } } -} // namespace armarx::armem::clazz +} // namespace armarx::armem armarx::armem::MemoryID armarx::armem::obj::makeObjectInstanceMemoryID(const objpose::ObjectPose& objectPose) diff --git a/source/RobotAPI/libraries/armem_objects/aron_conversions.h b/source/RobotAPI/libraries/armem_objects/aron_conversions.h index b61164a5d6a7de07bd8ba3761117e263ac714949..a41c7ccf43a9d5050cad2488c6369d0c28b3772d 100644 --- a/source/RobotAPI/libraries/armem_objects/aron_conversions.h +++ b/source/RobotAPI/libraries/armem_objects/aron_conversions.h @@ -1,6 +1,7 @@ #pragma once #include <RobotAPI/libraries/ArmarXObjects/ObjectPose.h> +#include <RobotAPI/libraries/armem/core/MemoryID.h> #include <RobotAPI/libraries/armem_objects/aron/Attachment.aron.generated.h> #include <RobotAPI/libraries/armem_objects/aron/Marker.aron.generated.h> #include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h> @@ -32,6 +33,7 @@ namespace armarx::armem void fromAron(const arondto::Marker& dto, marker::Marker& bo); void toAron(arondto::Marker& dto, const marker::Marker& bo); + } // namespace armarx::armem namespace armarx::armem::clazz @@ -44,10 +46,9 @@ namespace armarx::armem::clazz } // namespace armarx::armem::clazz -#include <RobotAPI/libraries/armem/core/MemoryID.h> - namespace armarx::armem::obj { /// Make a Memory ID for the object instance snapshot representing this pose. MemoryID makeObjectInstanceMemoryID(const objpose::ObjectPose& objectPose); + } // namespace armarx::armem::obj diff --git a/source/RobotAPI/libraries/armem_objects/client/class/ClassReader.cpp b/source/RobotAPI/libraries/armem_objects/client/class/ClassReader.cpp index bceba7d960ffbe41a620c36d47a5d8fc0897c157..ca365080d21ef1ca6eab5c779d50231e4f1b007a 100644 --- a/source/RobotAPI/libraries/armem_objects/client/class/ClassReader.cpp +++ b/source/RobotAPI/libraries/armem_objects/client/class/ClassReader.cpp @@ -1,5 +1,9 @@ #include "ClassReader.h" +#include <RobotAPI/libraries/armem/client/query.h> +#include <RobotAPI/libraries/armem_objects/aron_conversions.h> +#include <RobotAPI/libraries/armem_objects/types.h> + namespace armarx::armem::obj::clazz { std::optional<armem::clazz::ObjectClass> @@ -27,6 +31,42 @@ namespace armarx::armem::obj::clazz return std::nullopt; } + std::map<ObjectID, armem::clazz::ObjectClass> + ClassReader::getObjectClasses(const std::vector<ObjectID>& objectIDs) + { + armem::client::query::Builder builder; + auto& entities = builder.coreSegments() + .withName(properties().coreSegmentName) + .providerSegments() + .all() + .entities(); + + for (const ObjectID& objectID : objectIDs) + { + entities.withName(objectID.getClassID().str()).snapshots().latest(); + } + + const armem::client::QueryResult result = memoryReader().query(builder); + if (not result.success) + { + throw armem::error::QueryFailed(result.errorMessage); + } + + std::map<ObjectID, armem::clazz::ObjectClass> objectClasses; + + result.memory.forEachInstance( + [&objectClasses](const armem::wm::EntityInstance& instance) -> bool + { + const ObjectID classID = ObjectID::FromString(instance.id().entityName); + auto aron = instance.dataAs<armarx::armem::arondto::ObjectClass>(); + armarx::armem::clazz::fromAron(aron, objectClasses[classID]); + + return true; + }); + + return objectClasses; + } + std::string ClassReader::propertyPrefix() const { diff --git a/source/RobotAPI/libraries/armem_objects/client/class/ClassReader.h b/source/RobotAPI/libraries/armem_objects/client/class/ClassReader.h index 4d2805b4f03e81bb6b58b65d73997eeae56755ab..8dd50018a7483d7ce645475dd49f3dd840fe8f75 100644 --- a/source/RobotAPI/libraries/armem_objects/client/class/ClassReader.h +++ b/source/RobotAPI/libraries/armem_objects/client/class/ClassReader.h @@ -21,11 +21,10 @@ #pragma once -#include <mutex> +#include <map> #include <optional> #include <RobotAPI/libraries/armem/client/util/SimpleReaderBase.h> -#include <RobotAPI/libraries/armem_objects/aron_conversions.h> #include <RobotAPI/libraries/armem_objects/types.h> namespace armarx::armem::obj::clazz @@ -38,11 +37,18 @@ namespace armarx::armem::obj::clazz std::optional<armem::clazz::ObjectClass> getObjectClass(const std::string& providerName, const armarx::ObjectID& id); + /** + * @brief Get object class information for object class IDs. + * @param objectIDs The object class IDs. + * @return The corresponding object classes. + * @throw armarx::armem::error::QueryFailed If the memory query failed. + */ + std::map<armarx::ObjectID, armem::clazz::ObjectClass> + getObjectClasses(const std::vector<armarx::ObjectID>& objectIDs); + protected: std::string propertyPrefix() const final; Properties defaultProperties() const final; - - private: }; diff --git a/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp b/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp index c841afc4dc6afe2629802871399944a0ef39da04..5506ddbf598ed92ac11522769b9e7b0734d20162 100644 --- a/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp +++ b/source/RobotAPI/libraries/armem_objects/server/class/Segment.cpp @@ -1,51 +1,55 @@ #include "Segment.h" -#include <RobotAPI/libraries/aron/core/Exception.h> -#include <RobotAPI/libraries/aron/common/aron_conversions.h> -#include <RobotAPI/libraries/ArmarXObjects/aron_conversions.h> -#include <RobotAPI/libraries/armem/server/MemoryToIceAdapter.h> -#include <RobotAPI/libraries/armem_objects/aron_conversions.h> -#include <RobotAPI/libraries/armem_objects/memory_ids.h> -#include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h> - -#include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h> -#include <ArmarXCore/core/time/TimeUtil.h> +#include <filesystem> #include <SimoxUtility/color/Color.h> #include <SimoxUtility/math/pose/pose.h> #include <SimoxUtility/shapes/AxisAlignedBoundingBox.h> #include <SimoxUtility/shapes/OrientedBox.h> -#include <filesystem> +#include <ArmarXCore/core/application/properties/PropertyDefinitionContainer.h> +#include <ArmarXCore/core/time/TimeUtil.h> +#include <RobotAPI/libraries/ArmarXObjects/aron_conversions.h> +#include <RobotAPI/libraries/armem/server/MemoryToIceAdapter.h> +#include <RobotAPI/libraries/armem_objects/aron/ObjectClass.aron.generated.h> +#include <RobotAPI/libraries/armem_objects/aron_conversions.h> +#include <RobotAPI/libraries/armem_objects/memory_ids.h> +#include <RobotAPI/libraries/aron/common/aron_conversions.h> +#include <RobotAPI/libraries/aron/core/Exception.h> namespace armarx::armem::server::obj::clazz { Segment::Segment(armem::server::MemoryToIceAdapter& memoryToIceAdapter) : - SpecializedCoreSegment(memoryToIceAdapter, objects::classSegmentID.coreSegmentName, arondto::ObjectClass::ToAronType(), -1) + SpecializedCoreSegment(memoryToIceAdapter, + objects::classSegmentID.coreSegmentName, + arondto::ObjectClass::ToAronType(), + -1) { } - Segment::~Segment() { } - - void Segment::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix) + void + Segment::defineProperties(armarx::PropertyDefinitionsPtr defs, const std::string& prefix) { SpecializedCoreSegment::defineProperties(defs, prefix); - defs->optional(p.objectsPackage, prefix + "ObjectsPackage", "Name of the objects package to load from."); - defs->optional(p.loadFromObjectsPackage, prefix + "LoadFromObjectsPackage", + 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."); floorVis.defineProperties(defs, prefix + "Floor."); } - - void Segment::init() + void + Segment::init() { SpecializedCoreSegment::init(); @@ -55,8 +59,8 @@ namespace armarx::armem::server::obj::clazz } } - - void Segment::connect(viz::Client arviz) + void + Segment::connect(viz::Client arviz) { this->arviz = arviz; @@ -64,28 +68,29 @@ namespace armarx::armem::server::obj::clazz floorVis.updateFloorObject(*segmentPtr); } - - void Segment::loadByObjectFinder(const std::string& objectsPackage) + void + Segment::loadByObjectFinder(const std::string& objectsPackage) { loadByObjectFinder(ObjectFinder(objectsPackage)); } - - void Segment::loadByObjectFinder(const ObjectFinder& finder) + void + Segment::loadByObjectFinder(const ObjectFinder& finder) { this->objectFinder = finder; loadByObjectFinder(); } - - void Segment::loadByObjectFinder() + void + Segment::loadByObjectFinder() { const Time now = Time::Now(); const bool checkPaths = false; std::vector<ObjectInfo> infos = objectFinder.findAllObjects(checkPaths); - const MemoryID providerID = segmentPtr->id().withProviderSegmentName(objectFinder.getPackageName()); + const MemoryID providerID = + segmentPtr->id().withProviderSegmentName(objectFinder.getPackageName()); ARMARX_INFO << "Loading up to " << infos.size() << " object classes from '" << objectFinder.getPackageName() << "' ..."; Commit commit; @@ -98,18 +103,15 @@ namespace armarx::armem::server::obj::clazz update.arrivedTime = update.referencedTime = update.sentTime = now; arondto::ObjectClass objectClass = objectClassFromInfo(info); - update.instancesData = - { - objectClass.toAron() - }; + update.instancesData = {objectClass.toAron()}; } ARMARX_INFO << "Loaded " << commit.updates.size() << " object classes from '" << objectFinder.getPackageName() << "'."; iceMemory.commitLocking(commit); } - - void Segment::visualizeClass(const MemoryID& entityID, bool showAABB, bool showOOBB) + void + Segment::visualizeClass(const MemoryID& entityID, bool showAABB, bool showOOBB) { const Eigen::Matrix4f pose = Eigen::Matrix4f::Identity(); @@ -124,10 +126,11 @@ namespace armarx::armem::server::obj::clazz { try { - std::optional<arondto::ObjectClass> aron = doLocked([this, &entityID]() - { - return segmentPtr->findLatestInstanceDataAs<arondto::ObjectClass>(entityID, 0); - }); + std::optional<arondto::ObjectClass> aron = doLocked( + [this, &entityID]() { + return segmentPtr->findLatestInstanceDataAs<arondto::ObjectClass>(entityID, + 0); + }); if (not aron.has_value()) { return; @@ -136,23 +139,24 @@ namespace armarx::armem::server::obj::clazz if (not aron->simoxXmlPath.package.empty()) { layerObject.add(viz::Object(entityID.str()) - .file(aron->simoxXmlPath.package, aron->simoxXmlPath.path) - .pose(pose)); + .file(aron->simoxXmlPath.package, aron->simoxXmlPath.path) + .pose(pose)); } if (showAABB) { layerAABB.add(viz::Box("AABB") - .pose(pose * simox::math::pose(aron->aabb.center)) - .size(aron->aabb.extents) - .color(simox::Color::cyan(255, 64))); + .pose(pose * simox::math::pose(aron->aabb.center)) + .size(aron->aabb.extents) + .color(simox::Color::cyan(255, 64))); } if (showOOBB) { layerOOBB.add(viz::Box("OOBB") - .pose(pose * simox::math::pose(aron->oobb.center, aron->oobb.orientation)) - .size(aron->oobb.extents) - .color(simox::Color::lime(255, 64))); + .pose(pose * simox::math::pose(aron->oobb.center, + aron->oobb.orientation)) + .size(aron->oobb.extents) + .color(simox::Color::lime(255, 64))); } } catch (const armem::error::ArMemError& e) @@ -170,16 +174,16 @@ namespace armarx::armem::server::obj::clazz arviz.commit({layerObject, layerOrigin, layerAABB, layerOOBB}); } - - arondto::ObjectClass Segment::objectClassFromInfo(const ObjectInfo& info) + arondto::ObjectClass + Segment::objectClassFromInfo(const ObjectInfo& info) { namespace fs = std::filesystem; arondto::ObjectClass data; toAron(data.id, info.id()); - auto setPathIfExists = [](armarx::arondto::PackagePath & aron, - const PackageFileLocation & location) + auto setPathIfExists = + [](armarx::arondto::PackagePath& aron, const PackageFileLocation& location) { if (fs::is_regular_file(location.absolutePath)) { @@ -206,18 +210,18 @@ namespace armarx::armem::server::obj::clazz if (auto recogNames = info.loadRecognizedNames()) { - data.names.recognizedNames = recogNames.value(); + data.names.recognized = recogNames.value(); } if (auto spokenNames = info.loadSpokenNames()) { - data.names.spokenNames = spokenNames.value(); + data.names.spoken = spokenNames.value(); } return data; } - - void Segment::RemoteGui::setup(const Segment& segment) + void + Segment::RemoteGui::setup(const Segment& segment) { using namespace armarx::RemoteGui::Client; @@ -232,15 +236,15 @@ namespace armarx::armem::server::obj::clazz group.addChildren({layout, VSpacer()}); } - - void Segment::RemoteGui::update(Segment& segment) + void + Segment::RemoteGui::update(Segment& segment) { data.update(segment); visu.update(segment); } - - void Segment::RemoteGui::Data::setup(const Segment& segment) + void + Segment::RemoteGui::Data::setup(const Segment& segment) { using namespace armarx::RemoteGui::Client; @@ -264,8 +268,8 @@ namespace armarx::armem::server::obj::clazz group.addChild(grid); } - - void Segment::RemoteGui::Data::update(Segment& segment) + void + Segment::RemoteGui::Data::update(Segment& segment) { if (reloadButton.wasClicked()) { @@ -275,31 +279,35 @@ namespace armarx::armem::server::obj::clazz } if (infiniteHistory.hasValueChanged() || maxHistorySize.hasValueChanged()) { - segment.doLocked([this, &segment]() - { - segment.properties.maxHistorySize = infiniteHistory.getValue() ? -1 : maxHistorySize.getValue(); - if (segment.segmentPtr) + segment.doLocked( + [this, &segment]() { - segment.segmentPtr->setMaxHistorySize(long(segment.properties.maxHistorySize)); - } - }); + segment.properties.maxHistorySize = + infiniteHistory.getValue() ? -1 : maxHistorySize.getValue(); + if (segment.segmentPtr) + { + segment.segmentPtr->setMaxHistorySize( + long(segment.properties.maxHistorySize)); + } + }); } } - - void Segment::RemoteGui::Visu::setup(const Segment& segment) + void + Segment::RemoteGui::Visu::setup(const Segment& segment) { using namespace armarx::RemoteGui::Client; showComboBox = {}; showOptionsIndex.clear(); - segment.segmentPtr->forEachEntity([this](const wm::Entity & entity) - { - std::stringstream option; - option << entity.id().entityName << " (" << entity.id().providerSegmentName << ")"; - showComboBox.addOption(option.str()); - showOptionsIndex.push_back(entity.id()); - }); + segment.segmentPtr->forEachEntity( + [this](const wm::Entity& entity) + { + std::stringstream option; + option << entity.id().entityName << " (" << entity.id().providerSegmentName << ")"; + showComboBox.addOption(option.str()); + showOptionsIndex.push_back(entity.id()); + }); if (showOptionsIndex.empty()) { showComboBox.addOption("<none>"); @@ -318,8 +326,8 @@ namespace armarx::armem::server::obj::clazz group.addChild(grid); } - - void Segment::RemoteGui::Visu::update(Segment& segment) + void + Segment::RemoteGui::Visu::update(Segment& segment) { if (showButton.wasClicked()) { @@ -331,4 +339,4 @@ namespace armarx::armem::server::obj::clazz } } -} +} // namespace armarx::armem::server::obj::clazz diff --git a/source/RobotAPI/libraries/armem_objects/types.h b/source/RobotAPI/libraries/armem_objects/types.h index 598c78ca9c6bc5f4fc007059352ee94fc28b2fec..564bf3b460a06e036cd33b481541f4d41119cf25 100644 --- a/source/RobotAPI/libraries/armem_objects/types.h +++ b/source/RobotAPI/libraries/armem_objects/types.h @@ -30,6 +30,7 @@ #include <RobotAPI/libraries/armem/core/Time.h> #include <RobotAPI/libraries/armem_robot/types.h> #include <RobotAPI/libraries/core/FramedPose.h> +#include <RobotAPI/libraries/core/Names.h> #include "aron_forward_declarations.h" @@ -67,7 +68,7 @@ namespace armarx::armem::clazz armarx::PackagePath meshObjPath; simox::AxisAlignedBoundingBox aabb; simox::OrientedBoxf oobb; - // TODO NAMES + armarx::Names names; std::vector<Feature> ivtFeatures; }; } // namespace armarx::armem::clazz diff --git a/source/RobotAPI/libraries/aron/core/data/variant/container/Dict.cpp b/source/RobotAPI/libraries/aron/core/data/variant/container/Dict.cpp index 3e9f067c989d57087dc7311c73c8140cc7c1828a..19dd673bd2eeaec02f4be8fb49081d5edeb846c6 100644 --- a/source/RobotAPI/libraries/aron/core/data/variant/container/Dict.cpp +++ b/source/RobotAPI/libraries/aron/core/data/variant/container/Dict.cpp @@ -261,7 +261,8 @@ namespace armarx::aron::data const auto& p = data->getPath(); if (not p.hasDirectPrefix(this->getPath())) { - ARMARX_DEBUG << "An element added to a dict does not have a correct path set. This " + ARMARX_DEBUG << deactivateSpam(5) + << "An element added to a dict does not have a correct path set. This " "may cause errors. Please use setElemetCopy() instead."; } } diff --git a/source/RobotAPI/libraries/skills/provider/CMakeLists.txt b/source/RobotAPI/libraries/skills/provider/CMakeLists.txt index 9cb59c319fdf937ee9eb341610071f44114de3c1..83d51089a1298c56819a820b02e4db8eb3b0ff5a 100644 --- a/source/RobotAPI/libraries/skills/provider/CMakeLists.txt +++ b/source/RobotAPI/libraries/skills/provider/CMakeLists.txt @@ -46,6 +46,8 @@ armarx_add_library( detail/SkillImplementationWrapper.h SkillContext.h + blueprints/SkillWithContextBlueprint.h + mixins/All.h mixins/ArvizSkillMixin.h diff --git a/source/RobotAPI/libraries/skills/provider/SkillProviderComponentPlugin.cpp b/source/RobotAPI/libraries/skills/provider/SkillProviderComponentPlugin.cpp index 3d775f587834aa3a62fd42d1be353eb23a8fc0d4..730ce95a67671fad8464f4b886431a544a6410e3 100644 --- a/source/RobotAPI/libraries/skills/provider/SkillProviderComponentPlugin.cpp +++ b/source/RobotAPI/libraries/skills/provider/SkillProviderComponentPlugin.cpp @@ -210,7 +210,7 @@ namespace armarx::plugins auto it = skillExecutions.emplace(std::piecewise_construct, std::make_tuple(executionId), - std::make_tuple(*fac, + std::make_tuple(fac, executionId, executionRequest.parameters, executionRequest.callbackInterface)); @@ -265,7 +265,7 @@ namespace armarx::plugins auto it = skillExecutions.emplace(std::piecewise_construct, std::make_tuple(executionId), - std::make_tuple(*fac, + std::make_tuple(fac, executionId, executionRequest.parameters, executionRequest.callbackInterface)); diff --git a/source/RobotAPI/libraries/skills/provider/SkillProviderComponentPlugin.h b/source/RobotAPI/libraries/skills/provider/SkillProviderComponentPlugin.h index 20ffe1fbdb75ee9f4b5831dbd406180f7acf22fc..858ee511de6fa042e257b202b6cee3bf94a446a1 100644 --- a/source/RobotAPI/libraries/skills/provider/SkillProviderComponentPlugin.h +++ b/source/RobotAPI/libraries/skills/provider/SkillProviderComponentPlugin.h @@ -72,7 +72,7 @@ namespace armarx::plugins { auto fac = std::make_unique<FactoryT>(std::forward<Args>(args)...); auto* facPtr = fac.get(); - addCustomSkillFactory(std::move(fac)); + addSkillFactory(std::move(fac)); return static_cast<FactoryT*>(facPtr); } @@ -189,7 +189,7 @@ namespace armarx requires skills::isSkillBlueprint<FacT> FacT* addCustomSkillFactory(Args&&... args) { - return plugin->addSkillFactory<FacT>(std::forward<Args>(args)...); + return plugin->addCustomSkillFactory<FacT>(std::forward<Args>(args)...); } private: diff --git a/source/RobotAPI/libraries/skills/provider/blueprints/SkillWithContextBlueprint.h b/source/RobotAPI/libraries/skills/provider/blueprints/SkillWithContextBlueprint.h new file mode 100644 index 0000000000000000000000000000000000000000..db852e076274c6f8b479a25d4b7d65c474912fae --- /dev/null +++ b/source/RobotAPI/libraries/skills/provider/blueprints/SkillWithContextBlueprint.h @@ -0,0 +1,82 @@ +/* + * 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 RobotAPI + * @author Christoph Pohl ( christoph dot pohl at kit dot edu ) + * @date 05.12.23 + * @copyright http://www.gnu.org/licenses/gpl-2.0.txt + * GNU General Public License + */ + +#pragma once + +#include <RobotAPI/libraries/skills/provider/SkillFactory.h> + +namespace armarx +{ + namespace skills + { +// template <typename T> +// concept takesContext = requires(typename T::Context cntxt) { +// { T::connectTo(cntxt) } -> void; +// }; + + + template <typename SkillT> + class SkillWithContextBlueprint : public SkillBlueprint + { + public: + using ContextT = typename SkillT::Context; + + template <typename... Args> + SkillWithContextBlueprint(Args&&... args) : + SkillBlueprint(*SkillBlueprint::ForSkill<SkillT>(std::forward<Args>(args)...)) + { + } + + virtual std::unique_ptr<Skill> + createSkill(const ProviderID& pid) const override + { + if (not isConnected_) + { + return nullptr; + } + auto s = _createSkill(); + s->setProviderId(pid); + static_cast<SkillT*>(s.get())->connectTo(context_); + return s; + } + + virtual SkillDescription + createSkillDescription(const skills::ProviderID& pid) const + { + auto s = _createSkill(); + s->setProviderId(pid); + return s->getSkillDescription(); + } + + void + connectTo(const ContextT& context) + { + context_ = context; + isConnected_ = true; + } + + private: + std::atomic_bool isConnected_ = false; + ContextT context_; + }; + } // namespace skills +} // namespace armarx \ No newline at end of file diff --git a/source/RobotAPI/libraries/skills/provider/detail/SkillImplementationWrapper.cpp b/source/RobotAPI/libraries/skills/provider/detail/SkillImplementationWrapper.cpp index 25fe34efa5b5c26ffed19bdca3680555302326f6..773fc5af86c525950cd84846b6a641deabcb1c29 100644 --- a/source/RobotAPI/libraries/skills/provider/detail/SkillImplementationWrapper.cpp +++ b/source/RobotAPI/libraries/skills/provider/detail/SkillImplementationWrapper.cpp @@ -5,7 +5,7 @@ namespace armarx namespace skills::detail { SkillRuntime::SkillRuntime( - const skills::SkillBlueprint& fac, + const skills::SkillBlueprint* fac, const skills::SkillExecutionID& execId, const aron::data::DictPtr& initial_parameters, const skills::callback::dti::SkillProviderCallbackInterfacePrx& callbackInterface) : @@ -120,7 +120,8 @@ namespace armarx ARMARX_INFO_S << "Construct skill: " << skillName; updateStatus(SkillStatus::Constructing); - this->skill = this->factory.createSkill(providerId); + ARMARX_CHECK_NOT_NULL(factory) << "Skill Factory is a nullptr"; + this->skill = this->factory->createSkill(providerId); this->skill->setExecutorName(executorName); this->skill->setManager(manager); this->skill->setCallback([&](const SkillStatus s, const armarx::aron::data::DictPtr& d) @@ -242,6 +243,7 @@ namespace armarx { std::string message = "SkillError 201: The prepare method of skill '" + skillName + "' did not succeed."; + ARMARX_ERROR_S << message; return exitAndMakeFailedResult(message); } } diff --git a/source/RobotAPI/libraries/skills/provider/detail/SkillImplementationWrapper.h b/source/RobotAPI/libraries/skills/provider/detail/SkillImplementationWrapper.h index e5a5b1f82c3db4e5939fd4c880a738373967402b..935fa227bf13831d3bcc789a124b36d12f1ba423 100644 --- a/source/RobotAPI/libraries/skills/provider/detail/SkillImplementationWrapper.h +++ b/source/RobotAPI/libraries/skills/provider/detail/SkillImplementationWrapper.h @@ -1,5 +1,6 @@ #pragma once +#include <experimental/memory> #include <shared_mutex> #include <RobotAPI/interface/skills/SkillManagerInterface.h> @@ -18,7 +19,7 @@ namespace armarx class SkillRuntime { private: - const skills::SkillBlueprint factory; + const std::experimental::observer_ptr<const skills::SkillBlueprint> factory; std::unique_ptr<Skill> skill; mutable std::mutex executionMutex; @@ -33,7 +34,7 @@ namespace armarx std::thread execution; // ctor - SkillRuntime(const skills::SkillBlueprint& fac, + SkillRuntime(const skills::SkillBlueprint* fac, const skills::SkillExecutionID&, const aron::data::DictPtr&, const skills::callback::dti::SkillProviderCallbackInterfacePrx&);