Skip to content

Commit

Permalink
implement getJointNames/getControllerNames (#51)
Browse files Browse the repository at this point in the history
this was discussed in #39
  • Loading branch information
mikeferguson authored Jun 18, 2020
1 parent a8ec038 commit d5b6f9c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,16 @@ class ControllerManager : public std::enable_shared_from_this<ControllerManager>
*/
GyroHandlePtr getGyroHandle(const std::string& name);

/**
* @brief Get the names of all joints.
*/
std::vector<std::string> getJointNames();

/**
* @brief Get the names of all controllers.
*/
std::vector<std::string> getControllerNames();

private:
/** @brief Service callback */
void callback(
Expand Down
20 changes: 20 additions & 0 deletions robot_controllers_interface/src/controller_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,26 @@ GyroHandlePtr ControllerManager::getGyroHandle(const std::string& name)
return GyroHandlePtr();
}

std::vector<std::string> ControllerManager::getJointNames()
{
std::vector<std::string> names;
for (auto j = joints_.begin(); j != joints_.end(); ++j)
{
names.push_back((*j)->getName());
}
return names;
}

std::vector<std::string> ControllerManager::getControllerNames()
{
std::vector<std::string> names;
for (auto c = controllers_.begin(); c != controllers_.end(); ++c)
{
names.push_back((*c)->getController()->getName());
}
return names;
}

void ControllerManager::callback(
const std::shared_ptr<robot_controllers_msgs::srv::QueryControllerStates::Request> request,
std::shared_ptr<robot_controllers_msgs::srv::QueryControllerStates::Response> response)
Expand Down

0 comments on commit d5b6f9c

Please sign in to comment.