diff --git a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp index fe2a7471594c303e21ed0638bb1fa6f5e1635fa5..f60377622987efff1d3fa780ff2e05932528931b 100644 --- a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp +++ b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.cpp @@ -21,7 +21,9 @@ */ #include "ObjectMemory.h" +#include <VirtualRobot/VirtualRobot.h> +#include "ArmarXCore/core/time/Clock.h" #include <ArmarXCore/core/ice_conversions/ice_conversions_templates.h> #include <ArmarXCore/core/time/ice_conversions.h> @@ -65,6 +67,8 @@ namespace armarx::armem::server::obj "Duration of time window into the past to use for predictions" " when requested via the PredictingMemoryInterface (in seconds)."); + defs->optional(robotName, "robotName", ""); + return defs; } @@ -74,6 +78,7 @@ namespace armarx::armem::server::obj classSegment(iceAdapter()), attachmentSegment(iceAdapter()) { + addPlugin(virtualRobotReaderPlugin); } @@ -130,20 +135,24 @@ namespace armarx::armem::server::obj { // onConnect can be called multiple times, but addRobot will fail if called more than once with the same ID // So we need to always make sure to guard a call to addRobot - const std::string robotKey = "robot"; - VirtualRobot::RobotPtr robot = RobotState::hasRobot(robotKey) - ? RobotState::getRobot(robotKey) - : RobotState::addRobot(robotKey, VirtualRobot::RobotIO::RobotDescription::eStructure); + // const std::string robotKey = "robot"; + // VirtualRobot::RobotPtr robot = RobotState::hasRobot(robotKey) + // ? RobotState::getRobot(robotKey) + // : RobotState::addRobot(robotKey, VirtualRobot::RobotIO::RobotDescription::eStructure); - robotStateComponent = RobotState::getRobotStateComponent(); + // TODO: the instance segment should check the provided object poses and instantiate the needed robots by itself. + VirtualRobot::RobotPtr robot = virtualRobotReaderPlugin->get().getSynchronizedRobot(robotName, armarx::Clock::Now()); getProxyFromProperty(kinematicUnitObserver, "cmp.KinematicUnitObserverName", false, "", false); // Create first to use the original values. createRemoteGuiTab(); + ARMARX_CHECK_NOT_NULL(virtualRobotReaderPlugin); + // ARMARX_CHECK(virtualRobotReaderPlugin->isAvailable()); + instance::SegmentAdapter::connect( - robotStateComponent, + &virtualRobotReaderPlugin->get(), robot, kinematicUnitObserver, ArVizComponentPluginUser::getArvizClient(), diff --git a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h index 1a939eebff7c94f887b4d68f5d363c5f986e5194..5cf03b6e31f15526cf6f99e0be43c0aacedabb11 100644 --- a/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h +++ b/source/RobotAPI/components/armem/server/ObjectMemory/ObjectMemory.h @@ -22,6 +22,8 @@ #pragma once +#include "RobotAPI/libraries/armem/client/plugins/ReaderWriterPlugin.h" +#include "RobotAPI/libraries/armem_robot_state/client/common/VirtualRobotReader.h" #include <RobotAPI/libraries/armem_objects/server/class/Segment.h> #include <RobotAPI/libraries/armem_objects/server/instance/SegmentAdapter.h> #include <RobotAPI/libraries/armem_objects/server/attachments/Segment.h> @@ -61,15 +63,11 @@ namespace armarx::armem::server::obj , virtual public armarx::armem::server::ObjectMemoryInterface , virtual public armarx::armem::server::ReadWritePluginUser , virtual public armarx::armem::server::obj::instance::SegmentAdapter - - , virtual public armarx::RobotStateComponentPluginUser , virtual public armarx::LightweightRemoteGuiComponentPluginUser , virtual public armarx::ArVizComponentPluginUser { public: - using RobotState = armarx::RobotStateComponentPluginUser; - static const std::string defaultMemoryName; @@ -119,7 +117,6 @@ namespace armarx::armem::server::obj private: DebugObserverInterfacePrx debugObserver; - RobotStateComponentInterfacePrx robotStateComponent; KinematicUnitObserverInterfacePrx kinematicUnitObserver; double predictionTimeWindow = 2; @@ -137,6 +134,8 @@ namespace armarx::armem::server::obj }; std::unique_ptr<RemoteGuiTab> tab; + std::string robotName = "Armar6"; + armem::client::plugins::ReaderWriterPlugin<robot_state::VirtualRobotReader>* virtualRobotReaderPlugin; }; }