diff --git a/examples/components/example_client/Component.cpp b/examples/components/example_client/Component.cpp index 56404a58d91a9a8069187941d30b590347f661e9..84f1485b2c299ad826d5cca5abd8ff7ebd0a32cc 100644 --- a/examples/components/example_client/Component.cpp +++ b/examples/components/example_client/Component.cpp @@ -46,9 +46,9 @@ namespace armarx::navigation::components::example_client { - Component::Component() : virtualRobotReader(memoryNameSystem()) + Component::Component() { - // pass + addPlugin(virtualRobotReaderPlugin); } @@ -68,8 +68,6 @@ namespace armarx::navigation::components::example_client void Component::onConnectComponent() { - virtualRobotReader.connect(); - task = new armarx::RunningTask<Component>(this, &Component::exampleNavigationPointToPoint); task->start(); } @@ -100,8 +98,6 @@ namespace armarx::navigation::components::example_client void Component::exampleNavigation() { - using namespace std::chrono_literals; - // Import relevant namespaces. using namespace armarx::navigation; @@ -120,7 +116,7 @@ namespace armarx::navigation::components::example_client // Example of registering a method as callback. getNavigator().onGoalReached([this] { goalReached(); }); - std::this_thread::sleep_for(1s); + Clock::WaitFor(Duration::Seconds(1)); ARMARX_INFO << "Moving to goal pose"; // Start moving to goal position using above config. @@ -129,7 +125,7 @@ namespace armarx::navigation::components::example_client getNavigator().moveTo(goal, core::NavigationFrame::Absolute); - std::this_thread::sleep_for(15s); + Clock::WaitFor(Duration::Seconds(15)); // Wait until goal is reached armarx::navigation::client::StopEvent se = getNavigator().waitForStop(); @@ -157,7 +153,7 @@ namespace armarx::navigation::components::example_client goal.translation() << -1500, 1000, 0; getNavigator().moveTo(goal, core::NavigationFrame::Absolute); - std::this_thread::sleep_for(15s); + Clock::WaitFor(Duration::Seconds(15)); // Wait until goal is reached se = getNavigator().waitForStop(); @@ -184,7 +180,7 @@ namespace armarx::navigation::components::example_client ARMARX_ERROR << "Could not reach goal 3!"; } - std::this_thread::sleep_for(15s); + Clock::WaitFor(Duration::Seconds(15)); // TODO example with waypoints @@ -192,7 +188,7 @@ namespace armarx::navigation::components::example_client // Start moving towards a direction getNavigator().moveTowards(core::Direction(100, 100, 0), core::NavigationFrame::Relative); - std::this_thread::sleep_for(3s); + Clock::WaitFor(Duration::Seconds(3)); ARMARX_INFO << "Pausing movement."; getNavigator().pause(); @@ -203,8 +199,6 @@ namespace armarx::navigation::components::example_client { ARMARX_INFO << "Demonstrating complex navigation"; - using namespace std::chrono_literals; - // Import relevant namespaces. using namespace armarx::navigation; @@ -223,7 +217,7 @@ namespace armarx::navigation::components::example_client // Example of registering a method as callback. getNavigator().onGoalReached([this] { goalReached(); }); - std::this_thread::sleep_for(1s); + Clock::WaitFor(Duration::Seconds(1)); ARMARX_INFO << "Moving to goal pose"; // Start moving to goal position using above config. @@ -246,8 +240,6 @@ namespace armarx::navigation::components::example_client ARMARX_INFO << "Starting execution"; getNavigator().moveTo(pathBuilder, core::NavigationFrame::Absolute); - std::this_thread::sleep_for(25s); // TODO(fabian.reister): remove in the future - // Wait until goal is reached armarx::navigation::client::StopEvent se = getNavigator().waitForStop(); if (se) @@ -295,12 +287,13 @@ namespace armarx::navigation::components::example_client .globalPlanner(global_planning::Point2PointParams()) .trajectoryController(traj_ctrl::TrajectoryFollowingControllerParams())); - - std::this_thread::sleep_for(1s); + Clock::WaitFor(Duration::Seconds(1)); ARMARX_INFO << "Moving to goal pose"; // Start moving to goal position using above config. + auto& virtualRobotReader = virtualRobotReaderPlugin->get(); + auto robot = virtualRobotReader.getSynchronizedRobot(properties.robotName, armarx::Clock::Now()); ARMARX_CHECK_NOT_NULL(robot); @@ -376,9 +369,6 @@ namespace armarx::navigation::components::example_client "relativeMovement", "The distance between two target poses [mm]"); - virtualRobotReader.registerPropertyDefinitions(def); - - return def; } diff --git a/examples/components/example_client/Component.h b/examples/components/example_client/Component.h index aaa629992d11fd4d873ab2777a3657df7538e0e8..0fb9bd4cb3a56f26a198d466045f64d461b7a019 100644 --- a/examples/components/example_client/Component.h +++ b/examples/components/example_client/Component.h @@ -27,6 +27,7 @@ #include <ArmarXCore/util/tasks.h> #include <armarx/navigation/client.h> +#include "RobotAPI/libraries/armem/client/plugins/ReaderWriterPlugin.h" #include "RobotAPI/libraries/armem_robot_state/client/common/VirtualRobotReader.h" #include <RobotAPI/libraries/armem/client/plugins.h> @@ -100,7 +101,8 @@ namespace armarx::navigation::components::example_client armarx::RunningTask<Component>::pointer_type task; - armem::robot_state::VirtualRobotReader virtualRobotReader; + armem::client::plugins::ReaderWriterPlugin<armem::robot_state::VirtualRobotReader>* virtualRobotReaderPlugin = nullptr; + };