Skip to content

Commit

Permalink
Improve tesseract_environment code coverage (#655)
Browse files Browse the repository at this point in the history
* Improve tesseract_environment code coverage

* Improve tesseract_common code coverage

* Improve tesseract_geometry code coverage

* Fix bug in tesseract_environment with populating contact managers

* Fix issue in JointGroup and StateSolver getStaticLinkNames

* Fix clang-tidy error

* Fix issue with findTCPOffset and improve code coverage

* Improve tesseract_environment code coverage

* Add checkTrajectory unit tests

* Improve checkTrajectory code coverage
  • Loading branch information
Levi-Armstrong authored Oct 29, 2021
1 parent c487976 commit a8a19f7
Show file tree
Hide file tree
Showing 19 changed files with 1,562 additions and 194 deletions.
1 change: 1 addition & 0 deletions tesseract_common/include/tesseract_common/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ struct PairHash
LinkNamesPair makeOrderedLinkPair(const std::string& link_name1, const std::string& link_name2);

/** @brief The Plugin Information struct */
// NOLINTNEXTLINE
struct PluginInfo
{
/** @brief The plugin class name */
Expand Down
4 changes: 2 additions & 2 deletions tesseract_common/include/tesseract_common/utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,8 @@ Eigen::Vector3d calcRotationalError2(const Eigen::Ref<const Eigen::Matrix3d>& R)
Eigen::VectorXd calcTransformError(const Eigen::Isometry3d& t1, const Eigen::Isometry3d& t2);

/**
* @brief This computes a random color with alpha set to 1
* @return A random color
* @brief This computes a random color RGBA [0, 1] with alpha set to 1
* @return A random RGBA color
*/
Eigen::Vector4d computeRandomColor();

Expand Down
23 changes: 12 additions & 11 deletions tesseract_common/include/tesseract_common/yaml_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,10 @@ struct convert<tesseract_common::PluginInfo>
{
Node node;
node["class"] = rhs.class_name;

if (!rhs.config.IsNull())
node["config"] = rhs.config;

return node;
}

Expand All @@ -58,7 +60,7 @@ struct convert<tesseract_common::PluginInfo>

rhs.class_name = node["class"].as<std::string>();

if (node["config"])
if (node["config"] != nullptr)
rhs.config = node["config"];

return true;
Expand All @@ -75,17 +77,16 @@ struct convert<tesseract_common::PluginInfoContainer>
node["default"] = rhs.default_plugin;

node["plugins"] = rhs.plugins;
;

return node;
}

static bool decode(const Node& node, tesseract_common::PluginInfoContainer& rhs)
{
if (node["default"])
if (node["default"] != nullptr)
rhs.default_plugin = node["default"].as<std::string>();

if (!node["plugins"])
if (node["plugins"] == nullptr)
throw std::runtime_error("PluginInfoContainer, missing 'plugins' entry!");

const Node& plugins = node["plugins"];
Expand All @@ -98,7 +99,7 @@ struct convert<tesseract_common::PluginInfoContainer>
}
catch (const std::exception& e)
{
throw std::runtime_error(std::string("ContactManagersPluginFactory: Constructor failed to cast 'plugins' to "
throw std::runtime_error(std::string("PluginInfoContainer: Constructor failed to cast 'plugins' to "
"tesseract_common::PluginInfoMap! Details: ") +
e.what());
}
Expand Down Expand Up @@ -165,7 +166,7 @@ struct convert<Eigen::Isometry3d>
out.translation().z() = p["z"].as<double>();

const YAML::Node& o = node["orientation"];
if (o["x"] && o["y"] && o["z"] && o["w"])
if (o["x"] && o["y"] && o["z"] && o["w"]) // NOLINT
{
Eigen::Quaterniond quat;
quat.x() = o["x"].as<double>();
Expand All @@ -175,11 +176,11 @@ struct convert<Eigen::Isometry3d>

out.linear() = quat.toRotationMatrix();
}
else if (o["r"] && o["p"] && o["y"])
else if (o["r"] && o["p"] && o["y"]) // NOLINT
{
double r = o["r"].as<double>();
double p = o["p"].as<double>();
double y = o["y"].as<double>();
auto r = o["r"].as<double>();
auto p = o["p"].as<double>();
auto y = o["y"].as<double>();

Eigen::AngleAxisd rollAngle(r, Eigen::Vector3d::UnitX());
Eigen::AngleAxisd pitchAngle(p, Eigen::Vector3d::UnitY());
Expand Down Expand Up @@ -216,7 +217,7 @@ struct convert<Eigen::VectorXd>
if (!node.IsSequence())
return false;

rhs.resize(node.size());
rhs.resize(static_cast<Eigen::Index>(node.size()));
for (long i = 0; i < node.size(); ++i)
rhs(i) = node[i].as<double>();

Expand Down
3 changes: 3 additions & 0 deletions tesseract_common/src/utils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,8 @@ std::enable_if_t<std::is_polymorphic<E>::value> my_rethrow_if_nested(const E& e)
p->rethrow_nested();
}

// LCOV_EXCL_START
// These are tested in both tesseract_kinematics and tesseract_state_solver
void twistChangeRefPoint(Eigen::Ref<Eigen::VectorXd> twist, const Eigen::Ref<const Eigen::Vector3d>& ref_point)
{
twist(0) += twist(4) * ref_point(2) - twist(5) * ref_point(1);
Expand All @@ -86,6 +88,7 @@ void jacobianChangeRefPoint(Eigen::Ref<Eigen::MatrixXd> jacobian, const Eigen::R
for (int i = 0; i < jacobian.cols(); i++)
twistChangeRefPoint(jacobian.col(i), ref_point);
}
// LCOV_EXCL_STOP

Eigen::VectorXd concat(const Eigen::VectorXd& a, const Eigen::VectorXd& b)
{
Expand Down
Loading

0 comments on commit a8a19f7

Please sign in to comment.