Skip to content

Commit

Permalink
Throw exception when finding a chain fails.
Browse files Browse the repository at this point in the history
  • Loading branch information
bcalli authored and de-vri-es committed Jul 29, 2016
1 parent 911c713 commit 75d1e7b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/dr_kdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,19 +98,27 @@ KDL::Chain KdlTree::getChain(std::string const & start, std::string const & end)

KdlTree KdlTree::fromParameter(std::string const & parameter) {
KDL::Tree kdl;
kdl_parser::treeFromParam(parameter, kdl);

if(!kdl_parser::treeFromParam(parameter, kdl)){
throw std::runtime_error("Failed to load kdl tree from the parameter.");
}

return kdl;
}

KdlTree KdlTree::fromString(std::string const & urdf) {
KDL::Tree kdl;
kdl_parser::treeFromString(urdf, kdl);
if(!kdl_parser::treeFromString(urdf, kdl)){
throw std::runtime_error("Failed to load kdl tree from the urdf.");
}
return kdl;
}

KdlTree KdlTree::fromFile(std::string const & filename) {
KDL::Tree kdl;
kdl_parser::treeFromFile(filename, kdl);
if(!kdl_parser::treeFromFile(filename, kdl)){
throw std::runtime_error("Failed to load kdl tree from the file.");
}
return kdl;
}

Expand Down

0 comments on commit 75d1e7b

Please sign in to comment.