36 #include <console_bridge/console.h>
40 std::unique_ptr<ForwardKinematics>
45 const YAML::Node& config)
const
47 std::string base_link;
52 if (YAML::Node n = config[
"base_link"])
53 base_link = n.as<std::string>();
55 throw std::runtime_error(
"KDLFwdKinChainFactory, missing 'base_link' entry");
57 if (YAML::Node n = config[
"tip_link"])
58 tip_link = n.as<std::string>();
60 throw std::runtime_error(
"KDLFwdKinChainFactory, missing 'tip_link' entry");
62 catch (
const std::exception& e)
64 CONSOLE_BRIDGE_logError(
"KDLFwdKinChainFactory: Failed to parse yaml config data! Details: %s", e.what());
68 return std::make_unique<KDLFwdKinChain>(scene_graph, base_link, tip_link, solver_name);
71 std::unique_ptr<InverseKinematics>
76 const YAML::Node& config)
const
78 std::string base_link;
84 if (YAML::Node n = config[
"base_link"])
85 base_link = n.as<std::string>();
87 throw std::runtime_error(
"KDLInvKinChainLMAFactory, missing 'base_link' entry");
89 if (YAML::Node n = config[
"tip_link"])
90 tip_link = n.as<std::string>();
92 throw std::runtime_error(
"KDLInvKinChainLMAFactory, missing 'tip_link' entry");
95 if (YAML::Node n = config[
"task_weights"])
99 throw std::runtime_error(
"KDLInvKinChainLMAFactory, size of task_weights needs to be 6");
101 kdl_config.
task_weights = n.as<std::array<double, 6>>();
104 if (YAML::Node n = config[
"eps"])
105 kdl_config.
eps = n.as<
double>();
107 if (YAML::Node n = config[
"max_iterations"])
110 if (YAML::Node n = config[
"eps_joints"])
113 catch (
const std::exception& e)
115 CONSOLE_BRIDGE_logError(
"KDLInvKinChainLMAFactory: Failed to parse yaml config data! Details: %s", e.what());
119 return std::make_unique<KDLInvKinChainLMA>(scene_graph, base_link, tip_link, kdl_config, solver_name);
122 std::unique_ptr<InverseKinematics>
127 const YAML::Node& config)
const
129 std::string base_link;
130 std::string tip_link;
135 if (YAML::Node n = config[
"base_link"])
136 base_link = n.as<std::string>();
138 throw std::runtime_error(
"KDLInvKinChainNRFactory, missing 'base_link' entry");
140 if (YAML::Node n = config[
"tip_link"])
141 tip_link = n.as<std::string>();
143 throw std::runtime_error(
"KDLInvKinChainNRFactory, missing 'tip_link' entry");
146 if (YAML::Node n = config[
"velocity_eps"])
147 kdl_config.
vel_eps = n.as<
double>();
149 if (YAML::Node n = config[
"velocity_iterations"])
152 if (YAML::Node n = config[
"position_eps"])
153 kdl_config.
pos_eps = n.as<
double>();
155 if (YAML::Node n = config[
"position_iterations"])
158 catch (
const std::exception& e)
160 CONSOLE_BRIDGE_logError(
"KDLInvKinChainNRFactory: Failed to parse yaml config data! Details: %s", e.what());
164 return std::make_unique<KDLInvKinChainNR>(scene_graph, base_link, tip_link, kdl_config, solver_name);
167 std::unique_ptr<InverseKinematics>
172 const YAML::Node& config)
const
174 std::string base_link;
175 std::string tip_link;
180 if (YAML::Node n = config[
"base_link"])
181 base_link = n.as<std::string>();
183 throw std::runtime_error(
"KDLInvKinChainNR_JLFactory, missing 'base_link' entry");
185 if (YAML::Node n = config[
"tip_link"])
186 tip_link = n.as<std::string>();
188 throw std::runtime_error(
"KDLInvKinChainNR_JLFactory, missing 'tip_link' entry");
190 if (YAML::Node n = config[
"velocity_eps"])
191 kdl_config.
vel_eps = n.as<
double>();
193 if (YAML::Node n = config[
"velocity_iterations"])
196 if (YAML::Node n = config[
"position_eps"])
197 kdl_config.
pos_eps = n.as<
double>();
199 if (YAML::Node n = config[
"position_iterations"])
202 catch (
const std::exception& e)
204 CONSOLE_BRIDGE_logError(
"KDLInvKinChainNR_JLFactory: Failed to parse yaml config data! Details: %s", e.what());
208 return std::make_unique<KDLInvKinChainNR_JL>(scene_graph, base_link, tip_link, kdl_config, solver_name);
211 PLUGIN_ANCHOR_IMPL(KDLFactoriesAnchor)