From d0c91e1f90fc91d838c268e14bb9f6990de6ddb9 Mon Sep 17 00:00:00 2001 From: jgvictores Date: Sun, 3 Dec 2017 23:15:39 +0100 Subject: [PATCH] enable bypass if 'name' exists --- .../OpenraveYarpPluginLoader.cpp | 61 ++++++++++--------- 1 file changed, 32 insertions(+), 29 deletions(-) diff --git a/libraries/OpenravePlugins/OpenraveYarpPluginLoader/OpenraveYarpPluginLoader.cpp b/libraries/OpenravePlugins/OpenraveYarpPluginLoader/OpenraveYarpPluginLoader.cpp index 3f930e42..e76b53b0 100644 --- a/libraries/OpenravePlugins/OpenraveYarpPluginLoader/OpenraveYarpPluginLoader.cpp +++ b/libraries/OpenravePlugins/OpenraveYarpPluginLoader/OpenraveYarpPluginLoader.cpp @@ -109,47 +109,50 @@ class OpenraveYarpPluginLoader : public OpenRAVE::ModuleBase yarp::os::Value v(&penv, sizeof(OpenRAVE::EnvironmentBasePtr)); options.put("penv",v); - //-- If robotIndex (and then if manipulatorIndex), get and put name - if( options.check("robotIndex") ) + if( ! options.check("name") ) // Enable bypass if "name" already exists { - std::string name; - - if( options.check("prefix") ) + //-- If robotIndex (and then if manipulatorIndex), get and put name + if( options.check("robotIndex") ) { - name += options.find("prefix").asString(); - } - - name += "/"; - int robotPtrIdx = options.find("robotIndex").asInt(); + std::string name; - std::vector vectorOfRobotPtr; - GetEnv()->GetRobots(vectorOfRobotPtr); + if( options.check("prefix") ) // Note that not taken into account if using "name" + { + name += options.find("prefix").asString(); + } - if(robotPtrIdx >= vectorOfRobotPtr.size()) - { - CD_ERROR("robotIndex %d >= vectorOfRobotPtr.size() %d, not loading yarpPlugin.\n",robotPtrIdx,vectorOfRobotPtr.size()); - return false; - } + name += "/"; + int robotPtrIdx = options.find("robotIndex").asInt(); - name += vectorOfRobotPtr[ robotPtrIdx ]->GetName(); + std::vector vectorOfRobotPtr; + GetEnv()->GetRobots(vectorOfRobotPtr); - if( options.check("manipulatorIndex") ) - { - int manipulatorPtrIdx = options.find("manipulatorIndex").asInt(); + if(robotPtrIdx >= vectorOfRobotPtr.size()) + { + CD_ERROR("robotIndex %d >= vectorOfRobotPtr.size() %d, not loading yarpPlugin.\n",robotPtrIdx,vectorOfRobotPtr.size()); + return false; + } - std::vector vectorOfManipulatorPtr = vectorOfRobotPtr[ robotPtrIdx ]->GetManipulators(); + name += vectorOfRobotPtr[ robotPtrIdx ]->GetName(); - if(manipulatorPtrIdx >= vectorOfManipulatorPtr.size()) + if( options.check("manipulatorIndex") ) { - CD_ERROR("manipulatorPtrIdx %d >= vectorOfManipulatorPtr.size() %d, not loading yarpPlugin.\n",manipulatorPtrIdx,vectorOfManipulatorPtr.size()); - return false; + int manipulatorPtrIdx = options.find("manipulatorIndex").asInt(); + + std::vector vectorOfManipulatorPtr = vectorOfRobotPtr[ robotPtrIdx ]->GetManipulators(); + + if(manipulatorPtrIdx >= vectorOfManipulatorPtr.size()) + { + CD_ERROR("manipulatorPtrIdx %d >= vectorOfManipulatorPtr.size() %d, not loading yarpPlugin.\n",manipulatorPtrIdx,vectorOfManipulatorPtr.size()); + return false; + } + + name += "/"; + name += vectorOfManipulatorPtr[ manipulatorPtrIdx ]->GetName(); } - name += "/"; - name += vectorOfManipulatorPtr[ manipulatorPtrIdx ]->GetName(); + options.put("name",name); } - - options.put("name",name); } CD_DEBUG("post-config: %s\n", options.toString().c_str());