33 #include <console_bridge/console.h>
41 const YAML::Node& config)
const
43 std::string base_link;
50 if (YAML::Node n = config[
"base_link"])
51 base_link = n.as<std::string>();
53 throw std::runtime_error(
"OPWInvKinFactory, missing 'base_link' entry");
55 if (YAML::Node n = config[
"tip_link"])
56 tip_link = n.as<std::string>();
58 throw std::runtime_error(
"OPWInvKinFactory, missing 'tip_link' entry");
60 if (YAML::Node opw_params = config[
"params"])
62 if (YAML::Node n = opw_params[
"a1"])
63 params.
a1 = n.as<
double>();
65 throw std::runtime_error(
"OPWInvKinFactory, 'params' missing 'a1' entry");
67 if (YAML::Node n = opw_params[
"a2"])
68 params.
a2 = n.as<
double>();
70 throw std::runtime_error(
"OPWInvKinFactory, 'params' missing 'a2' entry");
72 if (YAML::Node n = opw_params[
"b"])
73 params.
b = n.as<
double>();
75 throw std::runtime_error(
"OPWInvKinFactory, 'params' missing 'b' entry");
77 if (YAML::Node n = opw_params[
"c1"])
78 params.
c1 = n.as<
double>();
80 throw std::runtime_error(
"OPWInvKinFactory, 'params' missing 'c1' entry");
82 if (YAML::Node n = opw_params[
"c2"])
83 params.
c2 = n.as<
double>();
85 throw std::runtime_error(
"OPWInvKinFactory, 'params' missing 'c2' entry");
87 if (YAML::Node n = opw_params[
"c3"])
88 params.
c3 = n.as<
double>();
90 throw std::runtime_error(
"OPWInvKinFactory, 'params' missing 'c3' entry");
92 if (YAML::Node n = opw_params[
"c4"])
93 params.
c4 = n.as<
double>();
95 throw std::runtime_error(
"OPWInvKinFactory, 'params' missing 'c4' entry");
97 if (YAML::Node offsets = opw_params[
"offsets"])
99 auto o = offsets.as<std::vector<double>>();
101 throw std::runtime_error(
"OPWInvKinFactory, offsets should have six elements!");
103 std::copy(o.begin(), o.end(), params.
offsets.begin());
106 if (YAML::Node sign_corrections = opw_params[
"sign_corrections"])
108 auto sc = sign_corrections.as<std::vector<int>>();
110 throw std::runtime_error(
"OPWInvKinFactory, sign_corrections should have six elements!");
112 for (std::size_t i = 0; i < sc.size(); ++i)
116 else if (sc[i] == -1)
119 throw std::runtime_error(
"OPWInvKinFactory, sign_corrections can only contain 1 or -1");
125 throw std::runtime_error(
"OPWInvKinFactory, missing 'params' entry");
130 catch (
const std::exception& e)
132 CONSOLE_BRIDGE_logError(
"OPWInvKinFactory: Failed to parse yaml config data! Details: %s", e.what());
136 return std::make_unique<OPWInvKin>(params, base_link, tip_link, path.
active_joints, solver_name);
139 PLUGIN_ANCHOR_IMPL(OPWFactoriesAnchor)