diff --git a/source/armarx/manipulation/components/articulated_objects_skill_provider/Component.cpp b/source/armarx/manipulation/components/articulated_objects_skill_provider/Component.cpp index b20c6146ddb55b53fcb05057f67a68162b8f764c..5823b2fe7b6697eb72412e62e4aba2241cf6984d 100644 --- a/source/armarx/manipulation/components/articulated_objects_skill_provider/Component.cpp +++ b/source/armarx/manipulation/components/articulated_objects_skill_provider/Component.cpp @@ -48,12 +48,13 @@ namespace armarx::manipulation::components::articulated_objects_skill_provider { - Component::Component() : articulatedObjectReader(memoryNameSystem()) + Component::Component() { + addPlugin(articulatedObjectReaderPlugin); } - const std::string Component::defaultName = "ActiculatedObjectsSkillProvider"; + const std::string Component::defaultName = skills::constants::ActiculatedObjectsSkillProvider; armarx::PropertyDefinitionsPtr @@ -64,24 +65,6 @@ namespace armarx::manipulation::components::articulated_objects_skill_provider robotProxies.registerPropertyDefinitions(def); - // Publish to a topic (passing the TopicListenerPrx). - // def->topic(myTopicListener); - - // Subscribe to a topic (passing the topic name). - // def->topic<PlatformUnitListener>("MyTopic"); - - // Use (and depend on) another component (passing the ComponentInterfacePrx). - // def->component(myComponentProxy) - - - // Add a required property. (The component won't start without a value being set.) - // def->required(properties.boxLayerName, "p.box.LayerName", "Name of the box layer in ArViz."); - - // Add an optionalproperty. - // def->optional( - // properties.boxLayerName, "p.box.LayerName", "Name of the box layer in ArViz."); - // def->optional(properties.numBoxes, "p.box.Number", "Number of boxes to draw in ArViz."); - return def; } @@ -105,8 +88,6 @@ namespace armarx::manipulation::components::articulated_objects_skill_provider Component::onConnectComponent() { - articulatedObjectReader.connect(); - core::Robot::InjectedServices injectedServices{.proxies = robotProxies, .memoryNameSystem = memoryNameSystem()}; @@ -124,11 +105,13 @@ namespace armarx::manipulation::components::articulated_objects_skill_provider addSkill( std::make_unique<skills::EstablishDoorContact>(skills::EstablishDoorContact::Context{ .robot = *robot, - .articulatedObjectReader = articulatedObjectReader, + .articulatedObjectReader = articulatedObjectReaderPlugin->get(), .arviz = arviz})); addSkill(std::make_unique<skills::ApproachHandle>(skills::ApproachHandle::Context{ - .robot = *robot, .articulatedObjectReader = articulatedObjectReader, .arviz = arviz})); + .robot = *robot, + .articulatedObjectReader = articulatedObjectReaderPlugin->get(), + .arviz = arviz})); addSkill( std::make_unique<skills::GraspHandle>(skills::GraspHandle::Context{.robot = *robot})); @@ -143,36 +126,13 @@ namespace armarx::manipulation::components::articulated_objects_skill_provider addSkill(std::make_unique<skills::meta::OpenDishwasherDoor>()); addSkill(std::make_unique<skills::meta::OpenFridge>()); - addSkill(std::make_unique<skills::SetJointValues>(skills::SetJointValues::Context{.robot = *robot, .arviz = arviz})); - addSkill(std::make_unique<skills::ParametricPathExecutor>(skills::ParametricPathExecutor::Context{.robot = *robot, .articulatedObjectReader = articulatedObjectReader, .arviz = arviz})); - - - // Do things after connecting to topics and components. - - /* (Requies the armarx::DebugObserverComponentPluginUser.) - // Use the debug observer to log data over time. - // The data can be viewed in the ObserverView and the LivePlotter. - // (Before starting any threads, we don't need to lock mutexes.) - { - setDebugObserverDatafield("numBoxes", properties.numBoxes); - setDebugObserverDatafield("boxLayerName", properties.boxLayerName); - sendDebugObserverBatch(); - } - */ - - /* (Requires the armarx::ArVizComponentPluginUser.) - // Draw boxes in ArViz. - // (Before starting any threads, we don't need to lock mutexes.) - drawBoxes(properties, arviz); - */ - - /* (Requires the armarx::LightweightRemoteGuiComponentPluginUser.) - // Setup the remote GUI. - { - createRemoteGuiTab(); - RemoteGui_startRunningTask(); - } - */ + addSkill(std::make_unique<skills::SetJointValues>( + skills::SetJointValues::Context{.robot = *robot, .arviz = arviz})); + addSkill(std::make_unique<skills::ParametricPathExecutor>( + skills::ParametricPathExecutor::Context{.robot = *robot, + .articulatedObjectReader = + articulatedObjectReaderPlugin->get(), + .arviz = arviz})); } @@ -202,87 +162,6 @@ namespace armarx::manipulation::components::articulated_objects_skill_provider } - /* (Requires the armarx::LightweightRemoteGuiComponentPluginUser.) - void - Component::createRemoteGuiTab() - { - using namespace armarx::RemoteGui::Client; - - // Setup the widgets. - - tab.boxLayerName.setValue(properties.boxLayerName); - - tab.numBoxes.setValue(properties.numBoxes); - tab.numBoxes.setRange(0, 100); - - tab.drawBoxes.setLabel("Draw Boxes"); - - // Setup the layout. - - GridLayout grid; - int row = 0; - { - grid.add(Label("Box Layer"), {row, 0}).add(tab.boxLayerName, {row, 1}); - ++row; - - grid.add(Label("Num Boxes"), {row, 0}).add(tab.numBoxes, {row, 1}); - ++row; - - grid.add(tab.drawBoxes, {row, 0}, {2, 1}); - ++row; - } - - VBoxLayout root = {grid, VSpacer()}; - RemoteGui_createTab(getName(), root, &tab); - } - - - void - Component::RemoteGui_update() - { - if (tab.boxLayerName.hasValueChanged() || tab.numBoxes.hasValueChanged()) - { - std::scoped_lock lock(propertiesMutex); - properties.boxLayerName = tab.boxLayerName.getValue(); - properties.numBoxes = tab.numBoxes.getValue(); - - { - setDebugObserverDatafield("numBoxes", properties.numBoxes); - setDebugObserverDatafield("boxLayerName", properties.boxLayerName); - sendDebugObserverBatch(); - } - } - if (tab.drawBoxes.wasClicked()) - { - // Lock shared variables in methods running in seperate threads - // and pass them to functions. This way, the called functions do - // not need to think about locking. - std::scoped_lock lock(propertiesMutex, arvizMutex); - drawBoxes(properties, arviz); - } - } - */ - - - /* (Requires the armarx::ArVizComponentPluginUser.) - void - Component::drawBoxes(const Component::Properties& p, viz::Client& arviz) - { - // Draw something in ArViz (requires the armarx::ArVizComponentPluginUser. - // See the ArVizExample in RobotAPI for more examples. - - viz::Layer layer = arviz.layer(p.boxLayerName); - for (int i = 0; i < p.numBoxes; ++i) - { - layer.add(viz::Box("box_" + std::to_string(i)) - .position(Eigen::Vector3f(i * 100, 0, 0)) - .size(20).color(simox::Color::blue())); - } - arviz.commit(layer); - } - */ - - ARMARX_REGISTER_COMPONENT_EXECUTABLE(Component, Component::GetDefaultName()); } // namespace armarx::manipulation::components::articulated_objects_skill_provider diff --git a/source/armarx/manipulation/components/articulated_objects_skill_provider/Component.h b/source/armarx/manipulation/components/articulated_objects_skill_provider/Component.h index d5ffaf4b3e2d22adab25285e8894563b04106f1e..4f8f2c1edd837888d6917601173b9599764cc5b5 100644 --- a/source/armarx/manipulation/components/articulated_objects_skill_provider/Component.h +++ b/source/armarx/manipulation/components/articulated_objects_skill_provider/Component.h @@ -31,6 +31,7 @@ #include <RobotAPI/libraries/RobotAPIComponentPlugins/ArVizComponentPlugin.h> #include <RobotAPI/libraries/armem/client/plugins.h> #include <RobotAPI/libraries/skills/provider/SkillProviderComponentPlugin.h> +#include "RobotAPI/libraries/armem/client/plugins/ReaderWriterPlugin.h" #include "armarx/manipulation/core/Robot.h" #include <armarx/manipulation/components/articulated_objects_skill_provider/ComponentInterface.h> @@ -144,7 +145,14 @@ namespace armarx::manipulation::components::articulated_objects_skill_provider std::unique_ptr<core::Robot> robot; - armarx::armem::articulated_object::ArticulatedObjectReader articulatedObjectReader; + + template <typename T> + using ReaderWriterPlugin = armarx::armem::client::plugins::ReaderWriterPlugin<T>; + + + ReaderWriterPlugin<armarx::armem::articulated_object::ArticulatedObjectReader>* articulatedObjectReaderPlugin = + nullptr; + }; } // namespace armarx::manipulation::components::articulated_objects_skill_provider