Open swhart115 opened 6 years ago
bump
Seems reasonable... Just to clarify, currently there is this:
HandlePtr ControllerManager::getHandle(const std::string& name)
{
// Try joints first
for (JointHandleList::iterator j = joints_.begin(); j != joints_.end(); j++)
{
if ((*j)->getName() == name)
return *j;
}
// Then controllers
for (ControllerList::iterator c = controllers_.begin(); c != controllers_.end(); c++)
{
if ((*c)->getController()->getName() == name)
return (*c)->getController();
}
// Not found
return HandlePtr();
}
JointHandlePtr ControllerManager::getJointHandle(const std::string& name)
{
// Try joints first
for (JointHandleList::iterator j = joints_.begin(); j != joints_.end(); j++)
{
if ((*j)->getName() == name)
return *j;
}
// Not found
return JointHandlePtr();
}
And I think you want:
ControllerPtr ControllerManager::getController(const std::string& name)
{
for (ControllerList::iterator c = controllers_.begin(); c != controllers_.end(); c++)
{
if ((*c)->getController()->getName() == name)
return (*c)->getController();
}
// Not found
return ControllerPtr();
}
?
this is great, thank you for your response. Maybe while we are at it, we could also add a function that returns list of the controller names?
For example:
std::vector<std::string> ControllerManager::getControllerNames()
{
std::vector<std::string> controller_names;
for (ControllerList::iterator c = controllers_.begin(); c != controllers_.end(); c++)
{
controller_names.push_back((*c)->getController()->getName());
}
return controller_names;
}
or alternatively:
void ControllerManager::getControllerNames(std::vector<std::string> &controller_names)
{
controller_names.clear();
for (ControllerList::iterator c = controllers_.begin(); c != controllers_.end(); c++)
{
controller_names.push_back((*c)->getController()->getName());
}
}
I think
std::vector<std::string> ControllerManager::getControllerNames()
{
std::vector<std::string> controller_names;
for (ControllerList::iterator c = controllers_.begin(); c != controllers_.end(); c++)
{
controller_names.push_back((*c)->getController()->getName());
}
return controller_names;
}
Fits better with the rest of the code.
looks good to me!
Hi I was wondering what the reason was to have the ControllerList private in the ControllerManager class. I'm trying to work with this class, but keep wanting more info about controllers. Since I can't access the list, and since i can only get the pointers to the handles for the controllers, it's proving difficult to get the info i need. I can get the joint handles by name, wondering why i cant actualyl get the controllers (as controller classes) by name. Thanks.