controller_verifier.cpp
Go to the documentation of this file.
2 
3 namespace franka_gazebo {
4 
6  const std::map<std::string, std::shared_ptr<franka_gazebo::Joint>>& joints,
7  const std::string& arm_id)
8  : arm_id_(arm_id) {
9  for (const auto& joint : joints) {
10  joint_names_.push_back(joint.first);
11  }
12 }
13 
15  const hardware_interface::ControllerInfo& controller) const {
16  if (isClaimingGripperController(controller) or isClaimingArmController(controller)) {
17  return true;
18  }
19  return std::none_of(
20  controller.claimed_resources.begin(), controller.claimed_resources.end(),
21  [](const auto& resource) {
22  return ControllerVerifier::determineControlMethod(resource.hardware_interface);
23  });
24 }
25 
27  const hardware_interface::ControllerInfo& info) const {
28  for (const auto& claimed_resource : info.claimed_resources) {
29  if (hasControlMethodAndValidSize(claimed_resource)) {
30  return areArmJoints(claimed_resource.resources);
31  }
32  }
33  return false;
34 }
35 
37  const hardware_interface::ControllerInfo& info) const {
38  for (const auto& claimed_resource : info.claimed_resources) {
39  if (not areFingerJoints(claimed_resource.resources) or claimed_resource.resources.size() != 2) {
40  continue;
41  }
42  auto control_method =
43  ControllerVerifier::determineControlMethod(claimed_resource.hardware_interface);
44  if (not control_method) {
45  continue;
46  }
47  if (control_method.value() == EFFORT) {
48  return true;
49  }
50  }
51  return false;
52 }
53 
57  .is_initialized() and
58  resource.resources.size() == 7;
59 }
60 
61 bool ControllerVerifier::areArmJoints(const std::set<std::string>& resources) const {
62  return std::all_of(resources.begin(), resources.end(), [this](const std::string& joint_name) {
63  return std::find_if(joint_names_.begin(), joint_names_.end(),
64  [&joint_name, this](const std::string& joint) {
65  // make sure that the joint is not a finger joint
66  if (joint.find(arm_id_ + "_finger_joint") != std::string::npos) {
67  return false;
68  }
69  return joint == joint_name;
70  }) != joint_names_.end();
71  });
72 }
73 
74 bool ControllerVerifier::areFingerJoints(const std::set<std::string>& resources) const {
75  return std::all_of(resources.begin(), resources.end(), [this](const std::string& joint_name) {
76  return joint_name.find(arm_id_ + "_finger_joint") != std::string::npos;
77  });
78 }
79 
80 boost::optional<ControlMethod> ControllerVerifier::determineControlMethod(
81  const std::string& hardware_interface) {
82  if (hardware_interface.find("hardware_interface::PositionJointInterface") != std::string::npos) {
83  return POSITION;
84  }
85  if (hardware_interface.find("hardware_interface::VelocityJointInterface") != std::string::npos) {
86  return VELOCITY;
87  }
88  if (hardware_interface.find("hardware_interface::EffortJointInterface") != std::string::npos) {
89  return EFFORT;
90  }
91  return boost::none;
92 }
93 
94 } // namespace franka_gazebo
static boost::optional< ControlMethod > determineControlMethod(const std::string &hardware_interface)
returns the control method of a hardware interface
bool isClaimingArmController(const hardware_interface::ControllerInfo &info) const
checks if a controller that uses the joints of the arm (not gripper joints) claims a position...
bool isClaimingGripperController(const hardware_interface::ControllerInfo &info) const
checks if a controller wants to use the finger joints with the effort interface
std::vector< std::string > joint_names_
bool areFingerJoints(const std::set< std::string > &resources) const
checks if a set of joint_names only contains the joints that are used for the gripper ...
bool isValidController(const hardware_interface::ControllerInfo &controller) const
checks if a controller can be used in the franka_hw gazebo plugin
std::set< std::string > resources
static bool hasControlMethodAndValidSize(const hardware_interface::InterfaceResources &resource)
ControllerVerifier(const std::map< std::string, std::shared_ptr< franka_gazebo::Joint >> &joints, const std::string &arm_id)
Creates a ControllerVerifier object to check controllers for franka_gazebo.
bool areArmJoints(const std::set< std::string > &resources) const
checks if a set of joint_names only contains the joints that are used for the arm ...
std::vector< InterfaceResources > claimed_resources


franka_gazebo
Author(s): Franka Emika GmbH
autogenerated on Mon Sep 19 2022 03:06:05