49 for (std::size_t i = 0; i < names.size(); ++i)
50 for (std::size_t j = i; j < names.size(); ++j)
51 setEntry(names[i], names[j], allowed);
57 for (
const std::string& name :
srdf.getNoDefaultCollisionLinks())
60 for (
auto const& collision :
srdf.getEnabledCollisionPairs())
61 setEntry(collision.link1_, collision.link2_,
false);
63 for (
auto const& collision :
srdf.getDisabledCollisionPairs())
64 setEntry(collision.link1_, collision.link2_,
true);
69 if (msg.entry_names.size() != msg.entry_values.size() ||
70 msg.default_entry_names.size() != msg.default_entry_values.size())
72 ROS_ERROR_NAMED(
"collision_detection",
"The number of links does not match the number of entries "
73 "in AllowedCollisionMatrix message");
76 for (std::size_t i = 0; i < msg.default_entry_names.size(); ++i)
77 setDefaultEntry(msg.default_entry_names[i], msg.default_entry_values[i]);
79 for (std::size_t i = 0; i < msg.entry_names.size(); ++i)
81 if (msg.entry_values[i].enabled.size() != msg.entry_names.size())
84 "Number of entries is incorrect for link '%s' in AllowedCollisionMatrix message",
85 msg.entry_names[i].c_str());
88 for (std::size_t j = i + 1; j < msg.entry_values[i].enabled.size(); ++j)
91 if (!
getDefaultEntry(msg.entry_names[i], msg.entry_names[j], allowed_default))
95 if (allowed_entry != allowed_default)
96 setEntry(msg.entry_names[i], msg.entry_names[j], allowed_entry);
106 auto it2 = it1->second.find(name2);
107 if (it2 == it1->second.end())
119 auto it2 = it1->second.find(name2);
120 if (it2 == it1->second.end())
122 allowed_collision = it2->second;
136 auto it2 = it1->second.find(name2);
137 return it2 != it1->second.end();
149 auto jt = it->second.find(name2);
150 if (jt != it->second.end())
151 it->second.erase(jt);
156 auto jt = it->second.find(name1);
157 if (jt != it->second.end())
158 it->second.erase(jt);
173 entry.second.erase(name);
175 allowed_contact.second.erase(name);
183 auto it = jt->second.find(name2);
184 if (it != jt->second.end())
185 jt->second.erase(it);
190 auto it = jt->second.find(name1);
191 if (it != jt->second.end())
192 jt->second.erase(it);
198 auto jt = it->second.find(name2);
199 if (jt != it->second.end())
200 it->second.erase(jt);
205 auto jt = it->second.find(name1);
206 if (jt != it->second.end())
207 it->second.erase(jt);
213 for (
const auto& other_name : other_names)
214 if (other_name !=
name)
221 for (
const auto& name1 : names1)
227 std::string last =
name;
229 if (name != entry.first && last != entry.first)
232 setEntry(name, entry.first, allowed);
240 for (
auto& it2 : entry.second)
262 allowed_collision = it->second;
277 return f1(contact) && f2(contact);
289 if (found1 && !found2)
291 else if (!found1 && found2)
293 else if (found1 && found2)
307 if (!found1 && !found2)
309 else if (found1 && !found2)
310 allowed_collision = t1;
311 else if (!found1 && found2)
312 allowed_collision = t2;
313 else if (found1 && found2)
343 names.push_back(entry.first);
347 auto it = std::lower_bound(names.begin(), names.end(), item.first);
348 if (it != names.end() && *it != item.first)
349 names.insert(it, item.first);
355 msg.entry_names.clear();
356 msg.entry_values.clear();
357 msg.default_entry_names.clear();
358 msg.default_entry_values.clear();
362 msg.entry_values.resize(msg.entry_names.size());
363 for (std::size_t i = 0; i < msg.entry_names.size(); ++i)
364 msg.entry_values[i].enabled.resize(msg.entry_names.size(),
false);
368 for (std::size_t i = 0; i < msg.entry_names.size(); ++i)
374 msg.default_entry_names.push_back(msg.entry_names[i]);
378 for (std::size_t j = i; j < msg.entry_names.size(); ++j)
389 std::vector<std::string> names;
392 std::size_t spacing = 4;
393 for (
auto&
name : names)
401 std::size_t number_digits = 2;
402 while (names.size() > pow(10, number_digits) - 1)
406 for (std::size_t j = 0; j < number_digits; ++j)
408 out << std::setw(spacing + number_digits + 8) <<
"";
409 for (std::size_t i = 0; i < names.size(); ++i)
411 std::stringstream ss;
412 ss << std::setw(number_digits) << i;
413 out << std::setw(3) << ss.str().c_str()[j];
418 const char* indicator =
"01?";
419 for (std::size_t i = 0; i < names.size(); ++i)
421 out << std::setw(spacing) << names[i];
422 out << std::setw(number_digits + 1) << i;
427 out << indicator[type];
432 for (std::size_t j = 0; j < names.size(); ++j)
436 out << std::setw(3) << indicator[type];
438 out << std::setw(3) <<
'-';