ur_factory.cpp
Go to the documentation of this file.
1 
29 #include <string>
31 
35 
38 
39 #include <console_bridge/console.h>
40 
41 namespace tesseract_kinematics
42 {
43 std::unique_ptr<InverseKinematics> URInvKinFactory::create(const std::string& solver_name,
44  const tesseract_scene_graph::SceneGraph& scene_graph,
45  const tesseract_scene_graph::SceneState& /*scene_state*/,
46  const KinematicsPluginFactory& /*plugin_factory*/,
47  const YAML::Node& config) const
48 {
49  std::string base_link;
50  std::string tip_link;
53 
54  try
55  {
56  if (YAML::Node n = config["base_link"])
57  base_link = n.as<std::string>();
58  else
59  throw std::runtime_error("URInvKinFactory, missing 'base_link' entry");
60 
61  if (YAML::Node n = config["tip_link"])
62  tip_link = n.as<std::string>();
63  else
64  throw std::runtime_error("URInvKinFactory, missing 'tip_link' entry");
65 
66  if (YAML::Node model = config["model"])
67  {
68  auto model_str = model.as<std::string>();
69  if (model_str == "UR3")
70  params = UR3Parameters;
71  else if (model_str == "UR5")
72  params = UR5Parameters;
73  else if (model_str == "UR10")
74  params = UR10Parameters;
75  else if (model_str == "UR3e")
76  params = UR3eParameters;
77  else if (model_str == "UR5e")
78  params = UR5eParameters;
79  else if (model_str == "UR10e")
80  params = UR10eParameters;
81  else
82  {
83  CONSOLE_BRIDGE_logError("URInvKinFactory: Invalid model!");
84  return nullptr;
85  }
86  }
87  else
88  {
89  if (YAML::Node ur_params = config["params"])
90  {
91  if (YAML::Node n = ur_params["d1"])
92  params.d1 = n.as<double>();
93  else
94  throw std::runtime_error("URInvKinFactory, 'params' missing 'd1' entry");
95 
96  if (YAML::Node n = ur_params["a2"])
97  params.a2 = n.as<double>();
98  else
99  throw std::runtime_error("URInvKinFactory, 'params' missing 'a2' entry");
100 
101  if (YAML::Node n = ur_params["a3"])
102  params.a3 = n.as<double>();
103  else
104  throw std::runtime_error("URInvKinFactory, 'params' missing 'a3' entry");
105 
106  if (YAML::Node n = ur_params["d4"])
107  params.d4 = n.as<double>();
108  else
109  throw std::runtime_error("URInvKinFactory, 'params' missing 'd4' entry");
110 
111  if (YAML::Node n = ur_params["d5"])
112  params.d5 = n.as<double>();
113  else
114  throw std::runtime_error("URInvKinFactory, 'params' missing 'd5' entry");
115 
116  if (YAML::Node n = ur_params["d6"])
117  params.d6 = n.as<double>();
118  else
119  throw std::runtime_error("URInvKinFactory, 'params' missing 'd6' entry");
120  }
121  else
122  {
123  throw std::runtime_error("URInvKinFactory, missing 'params' or 'model' entry");
124  }
125  }
126 
127  path = scene_graph.getShortestPath(base_link, tip_link);
128  }
129  catch (const std::exception& e)
130  {
131  CONSOLE_BRIDGE_logError("URInvKinFactory: Failed to parse yaml config data! Details: %s", e.what());
132  return nullptr;
133  }
134 
135  return std::make_unique<URInvKin>(params, base_link, tip_link, path.active_joints, solver_name);
136 }
137 
138 PLUGIN_ANCHOR_IMPL(URFactoriesAnchor)
139 
140 } // namespace tesseract_kinematics
141 
142 // NOLINTNEXTLINE(cppcoreguidelines-avoid-non-const-global-variables)
graph.h
ur_factory.h
Tesseract UR Inverse kinematics Factory.
types.h
Kinematics types.
tesseract_kinematics::UR3eParameters
const static URParameters UR3eParameters(0.15185, -0.24355, -0.2132, 0.13105, 0.08535, 0.0921)
The UR3e kinematic parameters.
tesseract_scene_graph::ShortestPath::active_joints
std::vector< std::string > active_joints
tesseract_kinematics::URParameters::d5
double d5
Definition: types.h:53
ur_inv_kin.h
TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
#define TESSERACT_COMMON_IGNORE_WARNINGS_PUSH
tesseract_scene_graph::SceneGraph
tesseract_kinematics::UR10eParameters
const static URParameters UR10eParameters(0.1807, -0.6127, -0.57155, 0.17415, 0.11985, 0.11655)
The UR10e kinematic parameters.
tesseract_kinematics::URParameters::d6
double d6
Definition: types.h:54
tesseract_scene_graph::SceneState
tesseract_kinematics::URInvKinFactory
Definition: ur_factory.h:34
tesseract_kinematics::URParameters::d4
double d4
Definition: types.h:52
tesseract_kinematics::URParameters
The Universal Robot kinematic parameters.
Definition: types.h:41
tesseract_scene_graph::SceneGraph::getShortestPath
ShortestPath getShortestPath(const std::string &root, const std::string &tip) const
tesseract_kinematics::URParameters::a2
double a2
Definition: types.h:50
tesseract_kinematics::UR3Parameters
const static URParameters UR3Parameters(0.1519, -0.24365, -0.21325, 0.11235, 0.08535, 0.0819)
The UR3 kinematic parameters.
tesseract_kinematics::UR5eParameters
const static URParameters UR5eParameters(0.1625, -0.425, -0.3922, 0.1333, 0.0997, 0.0996)
The UR5e kinematic parameters.
tesseract_kinematics::URParameters::a3
double a3
Definition: types.h:51
tesseract_kinematics::URParameters::d1
double d1
Definition: types.h:49
tesseract_scene_graph::ShortestPath
TESSERACT_COMMON_IGNORE_WARNINGS_POP
#define TESSERACT_COMMON_IGNORE_WARNINGS_POP
scene_state.h
TESSERACT_ADD_INV_KIN_PLUGIN
TESSERACT_ADD_INV_KIN_PLUGIN(tesseract_kinematics::URInvKinFactory, URInvKinFactory)
tesseract_kinematics::UR10Parameters
const static URParameters UR10Parameters(0.1273, -0.612, -0.5723, 0.163941, 0.1157, 0.0922)
The UR10 kinematic parameters.
tesseract_kinematics::UR5Parameters
const static URParameters UR5Parameters(0.089159, -0.42500, -0.39225, 0.10915, 0.09465, 0.0823)
The UR5 kinematic parameters.
tesseract_kinematics
Definition: forward_kinematics.h:40
macros.h
tesseract_kinematics::KinematicsPluginFactory
Definition: kinematics_plugin_factory.h:116
tesseract_kinematics::URInvKinFactory::create
std::unique_ptr< InverseKinematics > create(const std::string &solver_name, const tesseract_scene_graph::SceneGraph &scene_graph, const tesseract_scene_graph::SceneState &scene_state, const KinematicsPluginFactory &plugin_factory, const YAML::Node &config) const override final
Create Inverse Kinematics Object.
Definition: ur_factory.cpp:43


tesseract_kinematics
Author(s): Levi Armstrong
autogenerated on Sun May 18 2025 03:02:14