10 size_t position = resource_id.rfind(
"_joint");
11 if (position != std::string::npos && position > 0) {
12 *arm_id = resource_id.substr(0, position);
15 position = resource_id.rfind(
"_robot");
16 if (position != std::string::npos && position > 0) {
17 *arm_id = resource_id.substr(0, position);
25 for (
auto& item : info) {
26 const std::vector<hardware_interface::InterfaceResources>& c_res = item.claimed_resources;
27 for (
auto& resource_set : c_res) {
28 const std::set<std::string>& iface_resources = resource_set.resources;
29 for (
auto& resource : iface_resources) {
30 std::vector<std::string> claiming_controller(3);
31 claiming_controller[0] = item.name;
32 claiming_controller[1] = item.type;
33 claiming_controller[2] = resource_set.hardware_interface;
34 resource_map[resource].push_back(claiming_controller);
42 std::string current_arm_id;
47 for (
auto map_it = resource_map.begin(); map_it != resource_map.end(); map_it++) {
50 << map_it->first <<
". Name joints as '<robot_arm_id>_joint<jointnumber>'");
54 for (
auto claimed_by : map_it->second) {
55 if (claimed_by[2] ==
"hardware_interface::EffortJointInterface") {
57 }
else if (claimed_by[2] ==
"hardware_interface::PositionJointInterface") {
59 }
else if (claimed_by[2] ==
"hardware_interface::VelocityJointInterface") {
61 }
else if (claimed_by[2] ==
"franka_hw::FrankaPoseCartesianInterface") {
63 }
else if (claimed_by[2] ==
"franka_hw::FrankaVelocityCartesianInterface") {
80 if (arm_claim_map[arm_id].joint_position_claims > 0 &&
81 arm_claim_map[arm_id].joint_velocity_claims == 0 &&
82 arm_claim_map[arm_id].joint_torque_claims == 0 &&
83 arm_claim_map[arm_id].cartesian_pose_claims == 0 &&
84 arm_claim_map[arm_id].cartesian_velocity_claims == 0) {
86 }
else if (arm_claim_map[arm_id].joint_position_claims == 0 &&
87 arm_claim_map[arm_id].joint_velocity_claims > 0 &&
88 arm_claim_map[arm_id].joint_torque_claims == 0 &&
89 arm_claim_map[arm_id].cartesian_pose_claims == 0 &&
90 arm_claim_map[arm_id].cartesian_velocity_claims == 0) {
92 }
else if (arm_claim_map[arm_id].joint_position_claims == 0 &&
93 arm_claim_map[arm_id].joint_velocity_claims == 0 &&
94 arm_claim_map[arm_id].joint_torque_claims > 0 &&
95 arm_claim_map[arm_id].cartesian_pose_claims == 0 &&
96 arm_claim_map[arm_id].cartesian_velocity_claims == 0) {
98 }
else if (arm_claim_map[arm_id].joint_position_claims == 0 &&
99 arm_claim_map[arm_id].joint_velocity_claims == 0 &&
100 arm_claim_map[arm_id].joint_torque_claims == 0 &&
101 arm_claim_map[arm_id].cartesian_pose_claims > 0 &&
102 arm_claim_map[arm_id].cartesian_velocity_claims == 0) {
104 }
else if (arm_claim_map[arm_id].joint_position_claims == 0 &&
105 arm_claim_map[arm_id].joint_velocity_claims == 0 &&
106 arm_claim_map[arm_id].joint_torque_claims == 0 &&
107 arm_claim_map[arm_id].cartesian_pose_claims == 0 &&
108 arm_claim_map[arm_id].cartesian_velocity_claims > 0) {
110 }
else if (arm_claim_map[arm_id].joint_position_claims > 0 &&
111 arm_claim_map[arm_id].joint_velocity_claims == 0 &&
112 arm_claim_map[arm_id].joint_torque_claims > 0 &&
113 arm_claim_map[arm_id].cartesian_pose_claims == 0 &&
114 arm_claim_map[arm_id].cartesian_velocity_claims == 0) {
116 }
else if (arm_claim_map[arm_id].joint_position_claims == 0 &&
117 arm_claim_map[arm_id].joint_velocity_claims > 0 &&
118 arm_claim_map[arm_id].joint_torque_claims > 0 &&
119 arm_claim_map[arm_id].cartesian_pose_claims == 0 &&
120 arm_claim_map[arm_id].cartesian_velocity_claims == 0) {
122 }
else if (arm_claim_map[arm_id].joint_position_claims == 0 &&
123 arm_claim_map[arm_id].joint_velocity_claims == 0 &&
124 arm_claim_map[arm_id].joint_torque_claims > 0 &&
125 arm_claim_map[arm_id].cartesian_pose_claims > 0 &&
126 arm_claim_map[arm_id].cartesian_velocity_claims == 0) {
128 }
else if (arm_claim_map[arm_id].joint_position_claims == 0 &&
129 arm_claim_map[arm_id].joint_velocity_claims == 0 &&
130 arm_claim_map[arm_id].joint_torque_claims > 0 &&
131 arm_claim_map[arm_id].cartesian_pose_claims == 0 &&
132 arm_claim_map[arm_id].cartesian_velocity_claims > 0) {
139 for (
const auto& resource : resource_map) {
140 if (resource.second.size() > 2) {
142 <<
" is claimed with more than two command interfaces " 143 "which is not supported.");
146 uint8_t torque_claims = 0;
147 uint8_t other_claims = 0;
148 if (resource.second.size() == 2) {
149 for (
const auto& claimed_by : resource.second) {
150 if (claimed_by.at(2) ==
"hardware_interface::EffortJointInterface") {
156 if (torque_claims != 1) {
159 <<
" is claimed with a combination of two interfaces that is not " 169 const std::string&
arm_id) {
171 if (arm_claim_map.find(arm_id) != arm_claim_map.end()) {
172 if ((arm_claim_map.at(arm_id).cartesian_velocity_claims +
173 arm_claim_map.at(arm_id).cartesian_pose_claims >
175 arm_claim_map.at(arm_id).joint_position_claims +
176 arm_claim_map.at(arm_id).joint_velocity_claims >
179 "Resource conflict: Invalid combination of claims on joint AND cartesian level on arm " 180 << arm_id <<
" which is not supported.");
190 if (arm_claim_map.find(arm_id) != arm_claim_map.end()) {
191 if ((arm_claim_map.at(arm_id).joint_position_claims > 0 &&
192 arm_claim_map.at(arm_id).joint_position_claims != 7) ||
193 (arm_claim_map.at(arm_id).joint_velocity_claims > 0 &&
194 arm_claim_map.at(arm_id).joint_velocity_claims != 7) ||
195 (arm_claim_map.at(arm_id).joint_torque_claims > 0 &&
196 arm_claim_map.at(arm_id).joint_torque_claims != 7)) {
199 <<
" is not supported. Make sure to claim all 7 joints of the robot.");
207 if (arm_claim_map.find(arm_id) != arm_claim_map.end()) {
208 if (arm_claim_map.at(arm_id).joint_position_claims +
209 arm_claim_map.at(arm_id).joint_velocity_claims +
210 arm_claim_map.at(arm_id).cartesian_velocity_claims +
211 arm_claim_map.at(arm_id).cartesian_pose_claims >
uint8_t joint_velocity_claims
uint8_t joint_position_claims
bool getArmClaimedMap(ResourceWithClaimsMap &resource_map, ArmClaimedMap &arm_claim_map)
bool hasConflictingJointAndCartesianClaim(const ArmClaimedMap &arm_claim_map, const std::string &arm_id)
ControlMode getControlMode(const std::string &arm_id, ArmClaimedMap &arm_claim_map)
std::map< std::string, ResourceClaims > ArmClaimedMap
uint8_t cartesian_velocity_claims
uint8_t joint_torque_claims
bool findArmIdInResourceId(const std::string &resource_id, std::string *arm_id)
std::map< std::string, std::vector< std::vector< std::string >>> ResourceWithClaimsMap
bool hasTrajectoryClaim(const ArmClaimedMap &arm_claim_map, const std::string &arm_id)
uint8_t cartesian_pose_claims
bool partiallyClaimsArmJoints(const ArmClaimedMap &arm_claim_map, const std::string &arm_id)
#define ROS_ERROR_STREAM(args)
ResourceWithClaimsMap getResourceMap(const std::list< hardware_interface::ControllerInfo > &info)
bool hasConflictingMultiClaim(const ResourceWithClaimsMap &resource_map)