yaml_extenstions.h
Go to the documentation of this file.
1 
26 #ifndef TESSERACT_COMMON_YAML_EXTENSTIONS_H
27 #define TESSERACT_COMMON_YAML_EXTENSTIONS_H
28 
31 #include <yaml-cpp/yaml.h>
32 #include <set>
34 
38 
39 namespace YAML
40 {
41 template <>
42 struct convert<tesseract_common::PluginInfo>
43 {
44  static Node encode(const tesseract_common::PluginInfo& rhs)
45  {
46  Node node;
47  node["class"] = rhs.class_name;
48 
49  if (!rhs.config.IsNull())
50  node["config"] = rhs.config;
51 
52  return node;
53  }
54 
55  static bool decode(const Node& node, tesseract_common::PluginInfo& rhs)
56  {
57  // Check for required entries
58  if (!node["class"])
59  throw std::runtime_error("PluginInfo, missing 'class' entry!");
60 
61  rhs.class_name = node["class"].as<std::string>();
62 
63  if (node["config"]) // NOLINT
64  rhs.config = node["config"];
65 
66  return true;
67  }
68 };
69 
70 template <>
71 struct convert<tesseract_common::PluginInfoContainer>
72 {
74  {
75  Node node;
76  if (!rhs.default_plugin.empty())
77  node["default"] = rhs.default_plugin;
78 
79  node["plugins"] = rhs.plugins;
80 
81  return node;
82  }
83 
84  static bool decode(const Node& node, tesseract_common::PluginInfoContainer& rhs)
85  {
86  if (node["default"]) // NOLINT
87  rhs.default_plugin = node["default"].as<std::string>();
88 
89  if (!node["plugins"]) // NOLINT
90  throw std::runtime_error("PluginInfoContainer, missing 'plugins' entry!");
91 
92  const Node& plugins = node["plugins"];
93  if (!plugins.IsMap())
94  throw std::runtime_error("PluginInfoContainer, 'plugins' should contain a map of plugins!");
95 
96  try
97  {
98  rhs.plugins = plugins.as<tesseract_common::PluginInfoMap>();
99  }
100  catch (const std::exception& e)
101  {
102  throw std::runtime_error(std::string("PluginInfoContainer: Constructor failed to cast 'plugins' to "
103  "tesseract_common::PluginInfoMap! Details: ") +
104  e.what());
105  }
106 
107  return true;
108  }
109 };
110 
111 template <typename T, typename A>
112 struct convert<std::set<T, A>>
113 {
114  static Node encode(const std::set<T, A>& rhs)
115  {
116  Node node(NodeType::Sequence);
117  for (const auto& element : rhs)
118  node.push_back(element);
119  return node;
120  }
121 
122  static bool decode(const Node& node, std::set<T, A>& rhs)
123  {
124  if (!node.IsSequence())
125  return false;
126 
127  rhs.clear();
128  for (const auto& element : node)
129  rhs.insert(element.as<std::string>());
130 
131  return true;
132  }
133 };
134 
135 template <>
136 struct convert<Eigen::Isometry3d>
137 {
138  static Node encode(const Eigen::Isometry3d& rhs)
139  {
140  Node xyz;
141  xyz["x"] = rhs.translation().x();
142  xyz["y"] = rhs.translation().y();
143  xyz["z"] = rhs.translation().z();
144 
145  const Eigen::Quaterniond q(rhs.linear());
146  Node quat;
147  quat["x"] = q.x();
148  quat["y"] = q.y();
149  quat["z"] = q.z();
150  quat["w"] = q.w();
151 
152  Node node;
153  node["position"] = xyz;
154  node["orientation"] = quat;
155 
156  return node;
157  }
158 
159  static bool decode(const Node& node, Eigen::Isometry3d& rhs)
160  {
161  Eigen::Isometry3d out = Eigen::Isometry3d::Identity();
162 
163  const YAML::Node& p = node["position"];
164  out.translation().x() = p["x"].as<double>();
165  out.translation().y() = p["y"].as<double>();
166  out.translation().z() = p["z"].as<double>();
167 
168  const YAML::Node& o = node["orientation"];
169  if (o["x"] && o["y"] && o["z"] && o["w"]) // NOLINT
170  {
171  Eigen::Quaterniond quat;
172  quat.x() = o["x"].as<double>();
173  quat.y() = o["y"].as<double>();
174  quat.z() = o["z"].as<double>();
175  quat.w() = o["w"].as<double>();
176  quat.normalize();
177 
178  out.linear() = quat.toRotationMatrix();
179  }
180  else if (o["r"] && o["p"] && o["y"]) // NOLINT
181  {
182  auto r = o["r"].as<double>();
183  auto p = o["p"].as<double>();
184  auto y = o["y"].as<double>();
185 
186  Eigen::AngleAxisd rollAngle(r, Eigen::Vector3d::UnitX());
187  Eigen::AngleAxisd pitchAngle(p, Eigen::Vector3d::UnitY());
188  Eigen::AngleAxisd yawAngle(y, Eigen::Vector3d::UnitZ());
189 
190  Eigen::Quaterniond rpy{ yawAngle * pitchAngle * rollAngle };
191 
192  out.linear() = rpy.toRotationMatrix();
193  }
194  else
195  {
196  throw std::runtime_error("Eigen::Isometry3d, failed to decode orientation missing (x, y, z, w) or (r, p, y)");
197  }
198 
199  rhs = out;
200  return true;
201  }
202 };
203 
204 template <>
205 struct convert<Eigen::VectorXd>
206 {
207  static Node encode(const Eigen::VectorXd& rhs)
208  {
209  Node node;
210  for (long i = 0; i < static_cast<long>(rhs.size()); ++i)
211  node.push_back(rhs(i));
212 
213  return node;
214  }
215 
216  static bool decode(const Node& node, Eigen::VectorXd& rhs)
217  {
218  if (!node.IsSequence())
219  return false;
220 
221  rhs.resize(static_cast<long>(node.size()));
222  for (long i = 0; i < static_cast<long>(node.size()); ++i)
223  rhs(i) = node[i].as<double>();
224 
225  return true;
226  }
227 };
228 
229 template <>
230 struct convert<Eigen::Vector2d>
231 {
232  static Node encode(const Eigen::Vector2d& rhs)
233  {
234  Node node;
235  for (long i = 0; i < rhs.size(); ++i)
236  node.push_back(rhs(i));
237 
238  return node;
239  }
240 
241  static bool decode(const Node& node, Eigen::Vector2d& rhs)
242  {
243  if (!node.IsSequence() || (node.size() != 2))
244  return false;
245 
246  for (long i = 0; i < 2; ++i)
247  rhs(i) = node[i].as<double>();
248 
249  return true;
250  }
251 };
252 
253 template <>
254 struct convert<Eigen::Vector3d>
255 {
256  static Node encode(const Eigen::Vector3d& rhs)
257  {
258  Node node;
259  for (long i = 0; i < rhs.size(); ++i)
260  node.push_back(rhs(i));
261 
262  return node;
263  }
264 
265  static bool decode(const Node& node, Eigen::Vector3d& rhs)
266  {
267  if (!node.IsSequence() || (node.size() != 3))
268  return false;
269 
270  for (long i = 0; i < 3; ++i)
271  rhs(i) = node[i].as<double>();
272 
273  return true;
274  }
275 };
276 
277 template <>
278 struct convert<tesseract_common::KinematicsPluginInfo>
279 {
281  {
282  const std::string SEARCH_PATHS_KEY{ "search_paths" };
283  const std::string SEARCH_LIBRARIES_KEY{ "search_libraries" };
284  const std::string FWD_KIN_PLUGINS_KEY{ "fwd_kin_plugins" };
285  const std::string INV_KIN_PLUGINS_KEY{ "inv_kin_plugins" };
286 
287  YAML::Node kinematic_plugins;
288  if (!rhs.search_paths.empty())
289  kinematic_plugins[SEARCH_PATHS_KEY] = rhs.search_paths;
290 
291  if (!rhs.search_libraries.empty())
292  kinematic_plugins[SEARCH_LIBRARIES_KEY] = rhs.search_libraries;
293 
294  if (!rhs.fwd_plugin_infos.empty())
295  kinematic_plugins[FWD_KIN_PLUGINS_KEY] = rhs.fwd_plugin_infos;
296 
297  if (!rhs.inv_plugin_infos.empty())
298  kinematic_plugins[INV_KIN_PLUGINS_KEY] = rhs.inv_plugin_infos;
299 
300  return kinematic_plugins;
301  }
302 
303  static bool decode(const Node& node, tesseract_common::KinematicsPluginInfo& rhs)
304  {
305  const std::string SEARCH_PATHS_KEY{ "search_paths" };
306  const std::string SEARCH_LIBRARIES_KEY{ "search_libraries" };
307  const std::string FWD_KIN_PLUGINS_KEY{ "fwd_kin_plugins" };
308  const std::string INV_KIN_PLUGINS_KEY{ "inv_kin_plugins" };
309 
310  if (const YAML::Node& search_paths = node[SEARCH_PATHS_KEY])
311  {
312  std::set<std::string> sp;
313  try
314  {
315  sp = search_paths.as<std::set<std::string>>();
316  }
317  catch (const std::exception& e)
318  {
319  throw std::runtime_error("KinematicsPluginFactory: Constructor failed to cast '" + SEARCH_PATHS_KEY +
320  "' to std::set<std::string>! "
321  "Details: " +
322  e.what());
323  }
324  rhs.search_paths.insert(sp.begin(), sp.end());
325  }
326 
327  if (const YAML::Node& search_libraries = node[SEARCH_LIBRARIES_KEY])
328  {
329  std::set<std::string> sl;
330  try
331  {
332  sl = search_libraries.as<std::set<std::string>>();
333  }
334  catch (const std::exception& e)
335  {
336  throw std::runtime_error("KinematicsPluginFactory: Constructor failed to cast '" + SEARCH_LIBRARIES_KEY +
337  "' to std::set<std::string>! "
338  "Details: " +
339  e.what());
340  }
341  rhs.search_libraries.insert(sl.begin(), sl.end());
342  }
343 
344  if (const YAML::Node& fwd_kin_plugins = node[FWD_KIN_PLUGINS_KEY])
345  {
346  if (!fwd_kin_plugins.IsMap())
347  throw std::runtime_error(FWD_KIN_PLUGINS_KEY + ", should contain a map of group names to solver plugins!");
348 
349  try
350  {
351  rhs.fwd_plugin_infos = fwd_kin_plugins.as<std::map<std::string, tesseract_common::PluginInfoContainer>>();
352  }
353  catch (const std::exception& e)
354  {
355  throw std::runtime_error("KinematicsPluginFactory: Constructor failed to cast '" + FWD_KIN_PLUGINS_KEY +
356  "' to std::map<std::string, "
357  "tesseract_common::PluginInfoContainer>! Details: " +
358  e.what());
359  }
360  }
361 
362  if (const YAML::Node& inv_kin_plugins = node[INV_KIN_PLUGINS_KEY])
363  {
364  if (!inv_kin_plugins.IsMap())
365  throw std::runtime_error(INV_KIN_PLUGINS_KEY + ", should contain a map of group names to solver plugins!");
366 
367  try
368  {
369  rhs.inv_plugin_infos = inv_kin_plugins.as<std::map<std::string, tesseract_common::PluginInfoContainer>>();
370  }
371  catch (const std::exception& e)
372  {
373  throw std::runtime_error("KinematicsPluginFactory: Constructor failed to cast '" + INV_KIN_PLUGINS_KEY +
374  "' to std::map<std::string, "
375  "tesseract_common::PluginInfoContainer>! Details: " +
376  e.what());
377  }
378  }
379 
380  return true;
381  }
382 };
383 
384 template <>
385 struct convert<tesseract_common::ContactManagersPluginInfo>
386 {
388  {
389  const std::string SEARCH_PATHS_KEY{ "search_paths" };
390  const std::string SEARCH_LIBRARIES_KEY{ "search_libraries" };
391  const std::string DISCRETE_PLUGINS_KEY{ "discrete_plugins" };
392  const std::string CONTINUOUS_PLUGINS_KEY{ "continuous_plugins" };
393 
394  YAML::Node contact_manager_plugins;
395  if (!rhs.search_paths.empty())
396  contact_manager_plugins[SEARCH_PATHS_KEY] = rhs.search_paths;
397 
398  if (!rhs.search_libraries.empty())
399  contact_manager_plugins[SEARCH_LIBRARIES_KEY] = rhs.search_libraries;
400 
401  if (!rhs.discrete_plugin_infos.plugins.empty())
402  contact_manager_plugins[DISCRETE_PLUGINS_KEY] = rhs.discrete_plugin_infos;
403 
404  if (!rhs.continuous_plugin_infos.plugins.empty())
405  contact_manager_plugins[CONTINUOUS_PLUGINS_KEY] = rhs.continuous_plugin_infos;
406 
407  return contact_manager_plugins;
408  }
409 
410  static bool decode(const Node& node, tesseract_common::ContactManagersPluginInfo& rhs)
411  {
412  const std::string SEARCH_PATHS_KEY{ "search_paths" };
413  const std::string SEARCH_LIBRARIES_KEY{ "search_libraries" };
414  const std::string DISCRETE_PLUGINS_KEY{ "discrete_plugins" };
415  const std::string CONTINUOUS_PLUGINS_KEY{ "continuous_plugins" };
416 
417  if (const YAML::Node& search_paths = node[SEARCH_PATHS_KEY])
418  {
419  std::set<std::string> sp;
420  try
421  {
422  sp = search_paths.as<std::set<std::string>>();
423  }
424  catch (const std::exception& e)
425  {
426  throw std::runtime_error("ContactManagersPluginFactory: Constructor failed to cast '" + SEARCH_PATHS_KEY +
427  "' to std::set<std::string>! "
428  "Details: " +
429  e.what());
430  }
431  rhs.search_paths.insert(sp.begin(), sp.end());
432  }
433 
434  if (const YAML::Node& search_libraries = node[SEARCH_LIBRARIES_KEY])
435  {
436  std::set<std::string> sl;
437  try
438  {
439  sl = search_libraries.as<std::set<std::string>>();
440  }
441  catch (const std::exception& e)
442  {
443  throw std::runtime_error("ContactManagersPluginFactory: Constructor failed to cast '" + SEARCH_LIBRARIES_KEY +
444  "' to std::set<std::string>! "
445  "Details: " +
446  e.what());
447  }
448  rhs.search_libraries.insert(sl.begin(), sl.end());
449  }
450 
451  if (const YAML::Node& discrete_plugins = node[DISCRETE_PLUGINS_KEY])
452  {
453  if (!discrete_plugins.IsMap())
454  throw std::runtime_error(DISCRETE_PLUGINS_KEY + ", should contain a map of contact manager names to plugins!");
455 
456  try
457  {
459  }
460  catch (const std::exception& e)
461  {
462  throw std::runtime_error("ContactManagersPluginFactory: Constructor failed to cast '" + DISCRETE_PLUGINS_KEY +
463  "' to tesseract_common::PluginInfoContainer! Details: " + e.what());
464  }
465  }
466 
467  if (const YAML::Node& continuous_plugins = node[CONTINUOUS_PLUGINS_KEY])
468  {
469  if (!continuous_plugins.IsMap())
470  throw std::runtime_error(CONTINUOUS_PLUGINS_KEY + ", should contain a map of names to plugins!");
471 
472  try
473  {
474  rhs.continuous_plugin_infos = continuous_plugins.as<tesseract_common::PluginInfoContainer>();
475  }
476  catch (const std::exception& e)
477  {
478  throw std::runtime_error("ContactManagersPluginFactory: Constructor failed to cast '" + CONTINUOUS_PLUGINS_KEY +
479  "' to tesseract_common::PluginInfoContainer! Details: " + e.what());
480  }
481  }
482 
483  return true;
484  }
485 };
486 
487 template <>
488 struct convert<tesseract_common::TaskComposerPluginInfo>
489 {
491  {
492  const std::string SEARCH_PATHS_KEY{ "search_paths" };
493  const std::string SEARCH_LIBRARIES_KEY{ "search_libraries" };
494  const std::string EXECUTOR_PLUGINS_KEY{ "executors" };
495  const std::string NODE_PLUGINS_KEY{ "tasks" };
496 
497  YAML::Node task_composer_plugins;
498  if (!rhs.search_paths.empty())
499  task_composer_plugins[SEARCH_PATHS_KEY] = rhs.search_paths;
500 
501  if (!rhs.search_libraries.empty())
502  task_composer_plugins[SEARCH_LIBRARIES_KEY] = rhs.search_libraries;
503 
504  if (!rhs.executor_plugin_infos.plugins.empty())
505  task_composer_plugins[EXECUTOR_PLUGINS_KEY] = rhs.executor_plugin_infos;
506 
507  if (!rhs.task_plugin_infos.plugins.empty())
508  task_composer_plugins[NODE_PLUGINS_KEY] = rhs.task_plugin_infos;
509 
510  return task_composer_plugins;
511  }
512 
513  static bool decode(const Node& node, tesseract_common::TaskComposerPluginInfo& rhs)
514  {
515  const std::string SEARCH_PATHS_KEY{ "search_paths" };
516  const std::string SEARCH_LIBRARIES_KEY{ "search_libraries" };
517  const std::string EXECUTOR_PLUGINS_KEY{ "executors" };
518  const std::string NODE_PLUGINS_KEY{ "tasks" };
519 
520  if (const YAML::Node& search_paths = node[SEARCH_PATHS_KEY])
521  {
522  std::set<std::string> sp;
523  try
524  {
525  sp = search_paths.as<std::set<std::string>>();
526  }
527  catch (const std::exception& e)
528  {
529  throw std::runtime_error("TaskComposerPluginInfo: Constructor failed to cast '" + SEARCH_PATHS_KEY +
530  "' to std::set<std::string>! "
531  "Details: " +
532  e.what());
533  }
534  rhs.search_paths.insert(sp.begin(), sp.end());
535  }
536 
537  if (const YAML::Node& search_libraries = node[SEARCH_LIBRARIES_KEY])
538  {
539  std::set<std::string> sl;
540  try
541  {
542  sl = search_libraries.as<std::set<std::string>>();
543  }
544  catch (const std::exception& e)
545  {
546  throw std::runtime_error("TaskComposerPluginInfo: Constructor failed to cast '" + SEARCH_LIBRARIES_KEY +
547  "' to std::set<std::string>! "
548  "Details: " +
549  e.what());
550  }
551  rhs.search_libraries.insert(sl.begin(), sl.end());
552  }
553 
554  if (const YAML::Node& executor_plugins = node[EXECUTOR_PLUGINS_KEY])
555  {
556  if (!executor_plugins.IsMap())
557  throw std::runtime_error(EXECUTOR_PLUGINS_KEY + ", should contain a map of task composer executor names to "
558  "plugins!");
559 
560  try
561  {
563  }
564  catch (const std::exception& e)
565  {
566  throw std::runtime_error("TaskComposerPluginInfo: Constructor failed to cast '" + EXECUTOR_PLUGINS_KEY +
567  "' to tesseract_common::PluginInfoContainer! Details: " + e.what());
568  }
569  }
570 
571  if (const YAML::Node& node_plugins = node[NODE_PLUGINS_KEY])
572  {
573  if (!node_plugins.IsMap())
574  throw std::runtime_error(NODE_PLUGINS_KEY + ", should contain a map of names to plugins!");
575 
576  try
577  {
579  }
580  catch (const std::exception& e)
581  {
582  throw std::runtime_error("TaskComposerPluginInfo: Constructor failed to cast '" + NODE_PLUGINS_KEY +
583  "' to tesseract_common::PluginInfoContainer! Details: " + e.what());
584  }
585  }
586 
587  return true;
588  }
589 };
590 
591 template <>
593 {
594  static Node encode(const tesseract_common::TransformMap& rhs)
595  {
596  Node node;
597  for (const auto& pair : rhs)
598  node[pair.first] = pair.second;
599 
600  return node;
601  }
602 
603  static bool decode(const Node& node, tesseract_common::TransformMap& rhs)
604  {
605  if (!node.IsMap())
606  return false;
607 
608  for (const auto& pair : node)
609  rhs[pair.first.as<std::string>()] = pair.second.as<Eigen::Isometry3d>();
610 
611  return true;
612  }
613 };
614 
615 template <>
616 struct convert<tesseract_common::CalibrationInfo>
617 {
619  {
620  Node node;
621  node["joints"] = rhs.joints;
622 
623  return node;
624  }
625 
626  static bool decode(const Node& node, tesseract_common::CalibrationInfo& rhs)
627  {
628  const YAML::Node& joints_node = node["joints"];
629 
630  rhs.joints = joints_node.as<tesseract_common::TransformMap>();
631 
632  return true;
633  }
634 };
635 
636 template <>
637 struct convert<tesseract_common::Toolpath>
638 {
639  static Node encode(const tesseract_common::Toolpath& rhs)
640  {
641  Node node;
642  for (const auto& seg : rhs)
643  {
644  Node seg_node;
645  for (const auto& p : seg)
646  seg_node.push_back(p);
647 
648  node.push_back(seg_node);
649  }
650 
651  return node;
652  }
653 
654  static bool decode(const Node& node, tesseract_common::Toolpath& rhs)
655  {
656  if (!node.IsSequence())
657  return false;
658 
659  rhs.reserve(node.size());
660  for (const auto& seg_node : node)
661  {
663  seg.reserve(seg_node.size());
664  for (const auto& p_node : seg_node)
665  seg.push_back(p_node.as<Eigen::Isometry3d>());
666 
667  rhs.push_back(seg);
668  }
669 
670  return true;
671  }
672 };
673 
674 //=========================== CollisionMarginPairOverrideType Enum ===========================
675 template <>
677 {
679  {
680  // LCOV_EXCL_START
681  static const std::map<tesseract_common::CollisionMarginPairOverrideType, std::string> m = {
685  };
686  // LCOV_EXCL_STOP
687  return Node(m.at(rhs));
688  }
689 
690  static bool decode(const Node& node, tesseract_common::CollisionMarginPairOverrideType& rhs)
691  {
692  // LCOV_EXCL_START
693  static const std::map<std::string, tesseract_common::CollisionMarginPairOverrideType> inv = {
697  };
698  // LCOV_EXCL_STOP
699 
700  if (!node.IsScalar())
701  return false;
702 
703  auto it = inv.find(node.Scalar());
704  if (it == inv.end())
705  return false;
706 
707  rhs = it->second;
708  return true;
709  }
710 };
711 
712 //============================ PairsCollisionMarginData ============================
713 template <>
715 {
717  {
718  Node node(NodeType::Map);
719  for (const auto& pair : rhs)
720  {
721  Node key_node(NodeType::Sequence);
722  key_node.push_back(pair.first.first);
723  key_node.push_back(pair.first.second);
724 
725  // tell yaml-cpp “emit this sequence in [a, b] inline style”
726  key_node.SetStyle(YAML::EmitterStyle::Flow);
727 
728  node[key_node] = pair.second;
729  }
730 
731  return node;
732  }
733 
734  static bool decode(const Node& node, tesseract_common::PairsCollisionMarginData& rhs)
735  {
736  if (!node.IsMap())
737  return false;
738 
739  for (auto it = node.begin(); it != node.end(); ++it)
740  {
741  Node key_node = it->first;
742  if (!key_node.IsSequence() || key_node.size() != 2)
743  return false;
744 
745  std::pair<std::string, std::string> key;
746  key.first = key_node[0].as<std::string>();
747  key.second = key_node[1].as<std::string>();
748 
749  auto v = it->second.as<double>();
750  rhs.emplace(std::move(key), v);
751  }
752  return true;
753  }
754 };
755 
756 //================================== CollisionMarginPairData =================================
757 template <>
758 struct convert<tesseract_common::CollisionMarginPairData>
759 {
761  {
763  return Node(data);
764  }
765 
766  static bool decode(const Node& node, tesseract_common::CollisionMarginPairData& rhs)
767  {
768  auto data = node.as<tesseract_common::PairsCollisionMarginData>();
770  return true;
771  }
772 };
773 
774 //============================ AllowedCollisionEntries ============================
775 template <>
777 {
779  {
780  Node node(NodeType::Map);
781  for (const auto& pair : rhs)
782  {
783  Node key_node(NodeType::Sequence);
784  key_node.push_back(pair.first.first);
785  key_node.push_back(pair.first.second);
786 
787  // tell yaml-cpp “emit this sequence in [a, b] inline style”
788  key_node.SetStyle(YAML::EmitterStyle::Flow);
789 
790  node[key_node] = pair.second;
791  }
792 
793  return node;
794  }
795 
796  static bool decode(const Node& node, tesseract_common::AllowedCollisionEntries& rhs)
797  {
798  if (!node.IsMap())
799  return false;
800 
801  for (auto it = node.begin(); it != node.end(); ++it)
802  {
803  Node key_node = it->first;
804  if (!key_node.IsSequence() || key_node.size() != 2)
805  return false;
806 
807  std::pair<std::string, std::string> key;
808  key.first = key_node[0].as<std::string>();
809  key.second = key_node[1].as<std::string>();
810 
811  auto v = it->second.as<std::string>();
812  rhs.emplace(std::move(key), v);
813  }
814  return true;
815  }
816 };
817 
818 //================================== AllowedCollisionMatrix =================================
819 template <>
820 struct convert<tesseract_common::AllowedCollisionMatrix>
821 {
823  {
825  return Node(data);
826  }
827 
828  static bool decode(const Node& node, tesseract_common::AllowedCollisionMatrix& rhs)
829  {
830  auto data = node.as<tesseract_common::AllowedCollisionEntries>();
832  return true;
833  }
834 };
835 
836 //============================== std::unordered_map =============================
837 template <typename T, typename A>
838 struct convert<std::unordered_map<T, A>>
839 {
840  static Node encode(const std::unordered_map<T, A>& rhs)
841  {
842  Node node(NodeType::Map);
843  for (const auto& pair : rhs)
844  node[pair.first] = pair.second;
845 
846  return node;
847  }
848 
849  static bool decode(const Node& node, std::unordered_map<T, A>& rhs)
850  {
851  if (!node.IsMap())
852  return false;
853 
854  for (auto it = node.begin(); it != node.end(); ++it)
855  rhs[it->first.as<T>()] = it->second.as<A>();
856 
857  return true;
858  }
859 };
860 
861 } // namespace YAML
862 
863 #endif // TESSERACT_COMMON_YAML_EXTENSTIONS_H
tesseract_common::VectorIsometry3d
AlignedVector< Eigen::Isometry3d > VectorIsometry3d
Definition: eigen_types.h:28
YAML::convert< tesseract_common::AllowedCollisionEntries >::encode
static Node encode(const tesseract_common::AllowedCollisionEntries &rhs)
Definition: yaml_extenstions.h:778
tesseract_common
Definition: allowed_collision_matrix.h:19
YAML::convert< tesseract_common::CollisionMarginPairOverrideType >::encode
static Node encode(const tesseract_common::CollisionMarginPairOverrideType &rhs)
Definition: yaml_extenstions.h:678
tesseract_common::AllowedCollisionMatrix::getAllAllowedCollisions
const AllowedCollisionEntries & getAllAllowedCollisions() const
Get all of the entries in the allowed collision matrix.
Definition: allowed_collision_matrix.cpp:77
YAML::convert< Eigen::Isometry3d >::decode
static bool decode(const Node &node, Eigen::Isometry3d &rhs)
Definition: yaml_extenstions.h:159
tesseract_common::Toolpath
AlignedVector< VectorIsometry3d > Toolpath
Definition: eigen_types.h:33
tesseract_common::AllowedCollisionEntries
std::unordered_map< tesseract_common::LinkNamesPair, std::string, tesseract_common::PairHash > AllowedCollisionEntries
Definition: allowed_collision_matrix.h:24
tesseract_common::CollisionMarginPairOverrideType::REPLACE
@ REPLACE
Replace the contact manager's CollisionMarginPairData.
tesseract_common::CalibrationInfo::joints
tesseract_common::TransformMap joints
The joint origin calibration information.
Definition: calibration_info.h:54
tesseract_common::TaskComposerPluginInfo::executor_plugin_infos
tesseract_common::PluginInfoContainer executor_plugin_infos
A map of name to task composer executor plugin information.
Definition: plugin_info.h:181
YAML::convert< Eigen::Isometry3d >::encode
static Node encode(const Eigen::Isometry3d &rhs)
Definition: yaml_extenstions.h:138
tesseract_common::CollisionMarginPairOverrideType::MODIFY
@ MODIFY
Modify the contact managers pair margins.
tesseract_common::CollisionMarginPairData::getCollisionMargins
const PairsCollisionMarginData & getCollisionMargins() const
Get Collision Margin Data for stored pairs.
Definition: collision_margin_data.cpp:70
collision_margin_data.h
This is used to store collision margin information.
YAML::convert< Eigen::Vector3d >::encode
static Node encode(const Eigen::Vector3d &rhs)
Definition: yaml_extenstions.h:256
tesseract_common::TaskComposerPluginInfo::search_libraries
std::set< std::string > search_libraries
A list of library names without the prefix or suffix that contain plugins.
Definition: plugin_info.h:178
YAML::convert< tesseract_common::TaskComposerPluginInfo >::decode
static bool decode(const Node &node, tesseract_common::TaskComposerPluginInfo &rhs)
Definition: yaml_extenstions.h:513
tesseract_common::TransformMap
AlignedMap< std::string, Eigen::Isometry3d > TransformMap
Definition: eigen_types.h:32
YAML::convert< tesseract_common::PairsCollisionMarginData >::decode
static bool decode(const Node &node, tesseract_common::PairsCollisionMarginData &rhs)
Definition: yaml_extenstions.h:734
YAML::convert< Eigen::Vector2d >::encode
static Node encode(const Eigen::Vector2d &rhs)
Definition: yaml_extenstions.h:232
tesseract_common::TaskComposerPluginInfo
The task composer plugin information structure.
Definition: plugin_info.h:172
YAML::convert< tesseract_common::PluginInfoContainer >::encode
static Node encode(const tesseract_common::PluginInfoContainer &rhs)
Definition: yaml_extenstions.h:73
macros.h
Common Tesseract Macros.
YAML::convert< tesseract_common::PluginInfoContainer >::decode
static bool decode(const Node &node, tesseract_common::PluginInfoContainer &rhs)
Definition: yaml_extenstions.h:84
tesseract_common::PluginInfoContainer
Definition: plugin_info.h:81
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
Definition: macros.h:71
YAML::convert< Eigen::Vector3d >::decode
static bool decode(const Node &node, Eigen::Vector3d &rhs)
Definition: yaml_extenstions.h:265
tesseract_common::ContactManagersPluginInfo::discrete_plugin_infos
tesseract_common::PluginInfoContainer discrete_plugin_infos
A map of name to discrete contact manager plugin information.
Definition: plugin_info.h:144
YAML
Definition: yaml_extenstions.h:39
YAML::convert< tesseract_common::CalibrationInfo >::encode
static Node encode(const tesseract_common::CalibrationInfo &rhs)
Definition: yaml_extenstions.h:618
YAML::convert< tesseract_common::Toolpath >::encode
static Node encode(const tesseract_common::Toolpath &rhs)
Definition: yaml_extenstions.h:639
YAML::convert< tesseract_common::ContactManagersPluginInfo >::encode
static Node encode(const tesseract_common::ContactManagersPluginInfo &rhs)
Definition: yaml_extenstions.h:387
YAML::convert< std::unordered_map< T, A > >::decode
static bool decode(const Node &node, std::unordered_map< T, A > &rhs)
Definition: yaml_extenstions.h:849
tesseract_common::ContactManagersPluginInfo::continuous_plugin_infos
tesseract_common::PluginInfoContainer continuous_plugin_infos
A map of name to continuous contact manager plugin information.
Definition: plugin_info.h:147
tesseract_common::KinematicsPluginInfo::search_paths
std::set< std::string > search_paths
A list of paths to search for plugins.
Definition: plugin_info.h:101
tesseract_common::PluginInfo::class_name
std::string class_name
The plugin class name.
Definition: plugin_info.h:54
tesseract_common::TaskComposerPluginInfo::task_plugin_infos
tesseract_common::PluginInfoContainer task_plugin_infos
A map of name to task composer task plugin information.
Definition: plugin_info.h:184
YAML::convert< tesseract_common::AllowedCollisionMatrix >::decode
static bool decode(const Node &node, tesseract_common::AllowedCollisionMatrix &rhs)
Definition: yaml_extenstions.h:828
YAML::convert< tesseract_common::Toolpath >::decode
static bool decode(const Node &node, tesseract_common::Toolpath &rhs)
Definition: yaml_extenstions.h:654
plugin_info.h
Common Tesseract Plugin Infos.
YAML::convert< tesseract_common::AllowedCollisionMatrix >::encode
static Node encode(const tesseract_common::AllowedCollisionMatrix &rhs)
Definition: yaml_extenstions.h:822
YAML::convert< Eigen::VectorXd >::decode
static bool decode(const Node &node, Eigen::VectorXd &rhs)
Definition: yaml_extenstions.h:216
YAML::convert< tesseract_common::PluginInfo >::decode
static bool decode(const Node &node, tesseract_common::PluginInfo &rhs)
Definition: yaml_extenstions.h:55
YAML::convert< tesseract_common::CollisionMarginPairOverrideType >::decode
static bool decode(const Node &node, tesseract_common::CollisionMarginPairOverrideType &rhs)
Definition: yaml_extenstions.h:690
tesseract_common::CollisionMarginPairOverrideType
CollisionMarginPairOverrideType
Identifies how the provided contact margin data should be applied.
Definition: collision_margin_data.h:51
tesseract_common::CalibrationInfo
The CalibrationInfo struct.
Definition: calibration_info.h:41
tesseract_common::KinematicsPluginInfo::inv_plugin_infos
std::map< std::string, tesseract_common::PluginInfoContainer > inv_plugin_infos
A map of group name to inverse kinematics plugin information.
Definition: plugin_info.h:110
tesseract_common::ContactManagersPluginInfo
The contact managers plugin information structure.
Definition: plugin_info.h:135
tesseract_common::PluginInfo
The Plugin Information struct.
Definition: plugin_info.h:51
YAML::convert< tesseract_common::AllowedCollisionEntries >::decode
static bool decode(const Node &node, tesseract_common::AllowedCollisionEntries &rhs)
Definition: yaml_extenstions.h:796
tesseract_common::TaskComposerPluginInfo::search_paths
std::set< std::string > search_paths
A list of paths to search for plugins.
Definition: plugin_info.h:175
tesseract_common::PluginInfoContainer::default_plugin
std::string default_plugin
Definition: plugin_info.h:83
YAML::convert< tesseract_common::TransformMap >::encode
static Node encode(const tesseract_common::TransformMap &rhs)
Definition: yaml_extenstions.h:594
tesseract_common::KinematicsPluginInfo
The kinematics plugin information structure.
Definition: plugin_info.h:98
YAML::convert< std::set< T, A > >::decode
static bool decode(const Node &node, std::set< T, A > &rhs)
Definition: yaml_extenstions.h:122
YAML::convert< std::set< T, A > >::encode
static Node encode(const std::set< T, A > &rhs)
Definition: yaml_extenstions.h:114
tesseract_common::PluginInfo::config
YAML::Node config
The plugin config data.
Definition: plugin_info.h:57
YAML::convert< tesseract_common::ContactManagersPluginInfo >::decode
static bool decode(const Node &node, tesseract_common::ContactManagersPluginInfo &rhs)
Definition: yaml_extenstions.h:410
tesseract_common::PluginInfoMap
std::map< std::string, PluginInfo > PluginInfoMap
A map of PluginInfo to user defined name.
Definition: plugin_info.h:79
tesseract_common::CollisionMarginPairData
Definition: collision_margin_data.h:68
tesseract_common::KinematicsPluginInfo::fwd_plugin_infos
std::map< std::string, tesseract_common::PluginInfoContainer > fwd_plugin_infos
A map of group name to forward kinematics plugin information.
Definition: plugin_info.h:107
tesseract_common::ContactManagersPluginInfo::search_libraries
std::set< std::string > search_libraries
A list of library names without the prefix or suffix that contain plugins.
Definition: plugin_info.h:141
TESSERACT_COMMON_IGNORE_WARNINGS_POP
#define TESSERACT_COMMON_IGNORE_WARNINGS_POP
Definition: macros.h:72
YAML::convert< Eigen::Vector2d >::decode
static bool decode(const Node &node, Eigen::Vector2d &rhs)
Definition: yaml_extenstions.h:241
YAML::convert< std::unordered_map< T, A > >::encode
static Node encode(const std::unordered_map< T, A > &rhs)
Definition: yaml_extenstions.h:840
calibration_info.h
Calibration Information.
tesseract_common::AllowedCollisionMatrix
Definition: allowed_collision_matrix.h:28
YAML::convert< tesseract_common::CalibrationInfo >::decode
static bool decode(const Node &node, tesseract_common::CalibrationInfo &rhs)
Definition: yaml_extenstions.h:626
YAML::convert< tesseract_common::CollisionMarginPairData >::decode
static bool decode(const Node &node, tesseract_common::CollisionMarginPairData &rhs)
Definition: yaml_extenstions.h:766
YAML::convert< tesseract_common::KinematicsPluginInfo >::decode
static bool decode(const Node &node, tesseract_common::KinematicsPluginInfo &rhs)
Definition: yaml_extenstions.h:303
YAML::convert< tesseract_common::PairsCollisionMarginData >::encode
static Node encode(const tesseract_common::PairsCollisionMarginData &rhs)
Definition: yaml_extenstions.h:716
YAML::convert< tesseract_common::TransformMap >::decode
static bool decode(const Node &node, tesseract_common::TransformMap &rhs)
Definition: yaml_extenstions.h:603
YAML::convert< tesseract_common::CollisionMarginPairData >::encode
static Node encode(const tesseract_common::CollisionMarginPairData &rhs)
Definition: yaml_extenstions.h:760
YAML::convert< tesseract_common::PluginInfo >::encode
static Node encode(const tesseract_common::PluginInfo &rhs)
Definition: yaml_extenstions.h:44
YAML::convert< tesseract_common::KinematicsPluginInfo >::encode
static Node encode(const tesseract_common::KinematicsPluginInfo &rhs)
Definition: yaml_extenstions.h:280
YAML::convert< tesseract_common::TaskComposerPluginInfo >::encode
static Node encode(const tesseract_common::TaskComposerPluginInfo &rhs)
Definition: yaml_extenstions.h:490
tesseract_common::PluginInfoContainer::plugins
PluginInfoMap plugins
Definition: plugin_info.h:84
YAML::convert< Eigen::VectorXd >::encode
static Node encode(const Eigen::VectorXd &rhs)
Definition: yaml_extenstions.h:207
tesseract_common::ContactManagersPluginInfo::search_paths
std::set< std::string > search_paths
A list of paths to search for plugins.
Definition: plugin_info.h:138
tesseract_common::KinematicsPluginInfo::search_libraries
std::set< std::string > search_libraries
A list of library names without the prefix or suffix that contain plugins.
Definition: plugin_info.h:104
tesseract_common::PairsCollisionMarginData
std::unordered_map< tesseract_common::LinkNamesPair, double, tesseract_common::PairHash > PairsCollisionMarginData
Definition: collision_margin_data.h:66
tesseract_common::CollisionMarginPairOverrideType::NONE
@ NONE
Do not apply contact margin data.


tesseract_common
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:01:40