Skip to content

Commit

Permalink
enable bypass if 'name' exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jgvictores committed Dec 3, 2017
1 parent 3c45449 commit d0c91e1
Showing 1 changed file with 32 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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<OpenRAVE::RobotBasePtr> 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<OpenRAVE::RobotBasePtr> 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<OpenRAVE::RobotBase::ManipulatorPtr> 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<OpenRAVE::RobotBase::ManipulatorPtr> 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());
Expand Down

0 comments on commit d0c91e1

Please sign in to comment.