Skip to content

Commit 8caa3a7

Browse files
authored
Add utility function to parse plugin yaml config from string (#31)
* Add plugin parsing utility functions to tesseract_srdf_python.i * Bump version to 0.1.8
1 parent eafbfe7 commit 8caa3a7

File tree

2 files changed

+69
-1
lines changed

2 files changed

+69
-1
lines changed

tesseract_python/package.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?xml version="1.0"?>
22
<package format="3">
33
<name>tesseract_python</name>
4-
<version>0.1.7</version>
4+
<version>0.1.8</version>
55
<description>The tesseract_python package</description>
66
<maintainer email="wason@wasontech.com">John Wason</maintainer>
77
<license>Apache 2.0</license>

tesseract_python/swig/tesseract_srdf_python.i

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@
4646
#include <tesseract_srdf/srdf_model.h>
4747
#include <tesseract_srdf/utils.h>
4848

49+
#include <tesseract_scene_graph/graph.h>
50+
#include <tesseract_common/utils.h>
51+
#include <tesseract_common/yaml_utils.h>
52+
4953
%}
5054

5155
// tesseract_srdf
@@ -55,3 +59,67 @@
5559
%include "tesseract_srdf/kinematics_information.h"
5660
%include "tesseract_srdf/srdf_model.h"
5761
%include "tesseract_srdf/utils.h"
62+
63+
%inline {
64+
tesseract_common::CalibrationInfo parseCalibrationConfigString(const tesseract_scene_graph::SceneGraph& scene_graph,
65+
const std::string& yaml_str)
66+
{
67+
YAML::Node config;
68+
try
69+
{
70+
config = YAML::Load(yaml_str);
71+
}
72+
catch (...)
73+
{
74+
std::throw_with_nested(std::runtime_error("calibration_config: YAML failed to parse calibration config string"));
75+
}
76+
77+
const YAML::Node& cal_info = config[tesseract_common::CalibrationInfo::CONFIG_KEY];
78+
auto info = cal_info.as<tesseract_common::CalibrationInfo>();
79+
80+
// Check to make sure calibration joints exist
81+
for (const auto& cal_joint : info.joints)
82+
{
83+
if (scene_graph.getJoint(cal_joint.first) == nullptr)
84+
std::throw_with_nested(std::runtime_error("calibration_config: joint '" + cal_joint.first + "' does not exist!"));
85+
}
86+
87+
return info;
88+
}
89+
90+
tesseract_common::KinematicsPluginInfo parseKinematicsPluginConfigString(const std::string& yaml_str)
91+
{
92+
93+
YAML::Node config;
94+
try
95+
{
96+
config = YAML::Load(yaml_str);
97+
}
98+
catch (...)
99+
{
100+
std::throw_with_nested(std::runtime_error("kinematics_plugin_config: YAML failed to parse kinematics plugins string" ));
101+
}
102+
103+
const YAML::Node& kin_plugin_info = config[tesseract_common::KinematicsPluginInfo::CONFIG_KEY];
104+
105+
return kin_plugin_info.as<tesseract_common::KinematicsPluginInfo>();
106+
}
107+
108+
tesseract_common::ContactManagersPluginInfo
109+
parseContactManagersPluginConfigString(const std::string& yaml_str)
110+
{
111+
YAML::Node config;
112+
try
113+
{
114+
config = YAML::Load(yaml_str);
115+
}
116+
catch (...)
117+
{
118+
std::throw_with_nested(std::runtime_error("contact_managers_plugin_config: YAML failed to parse contact "
119+
"managers plugins string"));
120+
}
121+
122+
const YAML::Node& cm_plugin_info = config[tesseract_common::ContactManagersPluginInfo::CONFIG_KEY];
123+
return cm_plugin_info.as<tesseract_common::ContactManagersPluginInfo>();
124+
}
125+
}

0 commit comments

Comments
 (0)