From 2a9aa29f4fc6c68c7b4bc1a245e87d056ee34b16 Mon Sep 17 00:00:00 2001 From: "Christian R. G. Dreher" <c.dreher@kit.edu> Date: Fri, 9 Jul 2021 11:25:56 +0200 Subject: [PATCH] fix: Formatting. --- .../components/Navigator/Navigator.cpp | 236 ++++++++++-------- 1 file changed, 129 insertions(+), 107 deletions(-) diff --git a/source/Navigation/components/Navigator/Navigator.cpp b/source/Navigation/components/Navigator/Navigator.cpp index bda158c8..4b81d19d 100644 --- a/source/Navigation/components/Navigator/Navigator.cpp +++ b/source/Navigation/components/Navigator/Navigator.cpp @@ -40,147 +40,169 @@ #include <Navigation/libraries/factories/NavigationStackFactory.h> -namespace armarx::nav::components +armarx::nav::components::Navigator::Navigator() : executor{platformUnit} { +} - Navigator::Navigator() : executor{platformUnit} - { - } +armarx::nav::components::Navigator::~Navigator() +{ +} - Navigator::~Navigator() - { - } - void Navigator::onInitComponent() - { - } +void +armarx::nav::components::Navigator::onInitComponent() +{ +} - void Navigator::onConnectComponent() - { - } - void Navigator::onDisconnectComponent() - { - } +void +armarx::nav::components::Navigator::onConnectComponent() +{ +} - void Navigator::onExitComponent() - { - } - void Navigator::updateContext() - { - scene.staticScene = staticScene(); - scene.robot = getRobot(); - } +void +armarx::nav::components::Navigator::onDisconnectComponent() +{ +} - std::string Navigator::getDefaultName() const - { - return "Navigator"; - } - std::vector<core::Pose> convert(const std::vector<Eigen::Matrix4f>& wps) - { - std::vector<core::Pose> p; - p.reserve(wps.size()); - std::transform(wps.begin(), wps.end(), std::back_inserter(p), [](const auto & p) - { - return Eigen::Affine3f(p); - }); - return p; - } - - std::string - Navigator::createConfig(const aron::data::AronDictPtr& stackConfig, - const Ice::Current&) - { - // TODO: Not thread-safe. - const std::string uuid = boost::uuids::to_string(boost::uuids::random_generator()()); +void +armarx::nav::components::Navigator::onExitComponent() +{ +} - server::NavigationStack stack = fac::NavigationStackFactory::create(stackConfig, scene); - navigators.emplace(uuid, server::Navigator{stack, scene, executor}); - return uuid; - } +void +armarx::nav::components::Navigator::updateContext() +{ + scene.staticScene = staticScene(); + scene.robot = getRobot(); +} - void Navigator::moveTo(const std::vector<Eigen::Matrix4f>& waypoints, - const std::string& navigationMode, - const std::string& configId, - const Ice::Current&) - { - // TODO: Error handling. - navigators.at(configId).moveTo(convert(waypoints), core::NavigationFramesMap.from_name(navigationMode)); - } +std::string +armarx::nav::components::Navigator::getDefaultName() const +{ + return "Navigator"; +} - void Navigator::moveTowards(const Eigen::Vector3f& direction, - const std::string& navigationMode, - const std::string& configId, - const Ice::Current&) + +std::vector<armarx::nav::core::Pose> +convert(const std::vector<Eigen::Matrix4f>& wps) +{ + std::vector<core::Pose> p; + p.reserve(wps.size()); + std::transform(wps.begin(), wps.end(), std::back_inserter(p), [](const auto & p) { - // TODO: Error handling. + return Eigen::Affine3f(p); + }); + return p; +} - navigators.at(configId).moveTowards(direction, core::NavigationFramesMap.from_name(navigationMode)); - } - void - Navigator::pauseMovement(const Ice::Current&) - { +std::string +armarx::nav::components::Navigator::createConfig(const aron::data::AronDictPtr& stackConfig, + const Ice::Current&) +{ + // TODO: Not thread-safe. + const std::string uuid = boost::uuids::to_string(boost::uuids::random_generator()()); - } + server::NavigationStack stack = fac::NavigationStackFactory::create(stackConfig, scene); + navigators.emplace(uuid, server::Navigator{stack, scene, executor}); - void - Navigator::resumeMovement(const Ice::Current&) - { + return uuid; +} - } - armarx::PropertyDefinitionsPtr Navigator::createPropertyDefinitions() - { - armarx::PropertyDefinitionsPtr def = - new ComponentPropertyDefinitions(getConfigIdentifier()); +void +armarx::nav::components::Navigator::moveTo(const std::vector<Eigen::Matrix4f>& waypoints, + const std::string& navigationMode, + const std::string& configId, + const Ice::Current&) +{ + // TODO: Error handling. + + navigators.at(configId).moveTo(convert(waypoints), core::NavigationFramesMap.from_name(navigationMode)); +} - // Publish to a topic (passing the TopicListenerPrx). - // def->topic(myTopicListener); - // Subscribe to a topic (passing the topic name). - // def->topic<PlatformUnitListener>("MyTopic"); +void +armarx::nav::components::Navigator::moveTowards(const Eigen::Vector3f& direction, + const std::string& navigationMode, + const std::string& configId, + const Ice::Current&) +{ + // TODO: Error handling. - // Use (and depend on) another component (passing the ComponentInterfacePrx). - def->component(platformUnit); + navigators.at(configId).moveTowards(direction, core::NavigationFramesMap.from_name(navigationMode)); +} - // Add a required property. - // def->required(properties.boxLayerName, "p.box.LayerName", "Name of the box layer in ArViz."); - // Add an optionalproperty. - // def->optional(properties.numBoxes, "p.box.Number", "Number of boxes to draw in ArViz."); +void +armarx::nav::components::Navigator::pauseMovement(const Ice::Current&) +{ - return def; - } +} - core::StaticScene Navigator::staticScene() - { - core::StaticScene scene; - objpose::ObjectPoseSeq objectPoses = ObjectPoseClientPluginUser::getObjectPoses(); +void +armarx::nav::components::Navigator::resumeMovement(const Ice::Current&) +{ - scene.objects = util::asSceneObjects(objectPoses); +} - return scene; - } - VirtualRobot::RobotPtr Navigator::getRobot() - { - auto robot = RemoteRobot::createLocalCloneFromFile( - getRobotStateComponent(), VirtualRobot::RobotIO::RobotDescription::eFull); - // auto robot = RemoteRobot::createLocalClone(getRobotStateComponent()); - ARMARX_CHECK_NOT_NULL(robot); +armarx::PropertyDefinitionsPtr +armarx::nav::components::Navigator::createPropertyDefinitions() +{ + armarx::PropertyDefinitionsPtr def = + new ComponentPropertyDefinitions(getConfigIdentifier()); + + // 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(platformUnit); - // ARMARX_INFO << "Resetting robot"; - // robot = VirtualRobot::RobotIO::loadRobot(robot->getFilename()); + // Add a required property. + // def->required(properties.boxLayerName, "p.box.LayerName", "Name of the box layer in ArViz."); + + // Add an optionalproperty. + // def->optional(properties.numBoxes, "p.box.Number", "Number of boxes to draw in ArViz."); + + return def; +} + + +armarx::nav::core::StaticScene +armarx::nav::components::Navigator::staticScene() +{ + core::StaticScene scene; + + objpose::ObjectPoseSeq objectPoses = ObjectPoseClientPluginUser::getObjectPoses(); + + scene.objects = util::asSceneObjects(objectPoses); + + return scene; +} + + +VirtualRobot::RobotPtr +armarx::nav::components::Navigator::getRobot() +{ + auto robot = RemoteRobot::createLocalCloneFromFile( + getRobotStateComponent(), VirtualRobot::RobotIO::RobotDescription::eFull); + // auto robot = RemoteRobot::createLocalClone(getRobotStateComponent()); + ARMARX_CHECK_NOT_NULL(robot); - RemoteRobot::synchronizeLocalClone(robot, getRobotStateComponent()); + // ARMARX_INFO << "Resetting robot"; + // robot = VirtualRobot::RobotIO::loadRobot(robot->getFilename()); - return robot; - } + RemoteRobot::synchronizeLocalClone(robot, getRobotStateComponent()); -} // namespace armarx::nav::components + return robot; +} -- GitLab