Tesseract 0.28.4
Loading...
Searching...
No Matches
utils.cpp File Reference

Common Tesseract Utility Functions. More...

#include <tesseract/common/macros.h>
#include <ctime>
#include <random>
#include <string>
#include <type_traits>
#include <console_bridge/console.h>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <tinyxml2.h>
#include <cassert>
#include <tesseract/common/utils.h>

Namespaces

namespace  tesseract::common
 Namespace owning boost's hash_is_avalanching, and defined iff boost has the trait at all.
 

Functions

template bool tesseract::common::toNumeric< double > (const std::string &, double &)
 
template bool tesseract::common::toNumeric< float > (const std::string &, float &)
 
template bool tesseract::common::toNumeric< int > (const std::string &, int &)
 
template bool tesseract::common::toNumeric< long > (const std::string &, long &)
 
template bool tesseract::common::isIdentical< std::string > (const std::vector< std::string > &, const std::vector< std::string > &, bool, const std::function< bool(const std::string &, const std::string &)> &, const std::function< bool(const std::string &, const std::string &)> &)
 
template bool tesseract::common::isIdentical< Eigen::Index > (const std::vector< Eigen::Index > &, const std::vector< Eigen::Index > &, bool, const std::function< bool(const Eigen::Index &, const Eigen::Index &)> &, const std::function< bool(const Eigen::Index &, const Eigen::Index &)> &)
 
template<typename E >
std::enable_if_t<!std::is_polymorphic< E >::value > tesseract::common::my_rethrow_if_nested (const E &)
 
template<typename E >
std::enable_if_t< std::is_polymorphic< E >::value > tesseract::common::my_rethrow_if_nested (const E &e)
 
std::string tesseract::common::fileToString (const std::filesystem::path &filepath)
 Read in the contents of the file into a string.
 
void tesseract::common::twistChangeRefPoint (Eigen::Ref< Eigen::VectorXd > twist, const Eigen::Ref< const Eigen::Vector3d > &ref_point)
 Change the reference point of the provided Twist.
 
void tesseract::common::twistChangeBase (Eigen::Ref< Eigen::VectorXd > twist, const Eigen::Isometry3d &change_base)
 Change the base coordinate system of the Twist.
 
void tesseract::common::jacobianChangeBase (Eigen::Ref< Eigen::MatrixXd > jacobian, const Eigen::Isometry3d &change_base)
 Change the base coordinate system of the jacobian.
 
void tesseract::common::jacobianChangeRefPoint (Eigen::Ref< Eigen::MatrixXd > jacobian, const Eigen::Ref< const Eigen::Vector3d > &ref_point)
 Change the reference point of the jacobian.
 
Eigen::VectorXd tesseract::common::concat (const Eigen::VectorXd &a, const Eigen::VectorXd &b)
 Concatenate two vector.
 
std::pair< Eigen::Vector3d, double > tesseract::common::calcRotationalErrorDecomposed (const Eigen::Ref< const Eigen::Matrix3d > &R)
 
Eigen::Vector3d tesseract::common::calcRotationalError (const Eigen::Ref< const Eigen::Matrix3d > &R)
 Calculate the rotation error vector given a rotation error matrix where the angle is between [-pi, pi].
 
Eigen::VectorXd tesseract::common::calcTransformError (const Eigen::Isometry3d &t1, const Eigen::Isometry3d &t2)
 Calculate error between two transforms expressed in t1 coordinate system.
 
void tesseract::common::applyTolerances (Eigen::Ref< Eigen::VectorXd > v, const Eigen::Ref< const Eigen::VectorXd > &lower_tolerance, const Eigen::Ref< const Eigen::VectorXd > &upper_tolerance)
 Apply a per-component dead-band tolerance to an error vector in place.
 
Eigen::VectorXd tesseract::common::calcJacobianTransformErrorDiff (const Eigen::Isometry3d &target, const Eigen::Isometry3d &source, const Eigen::Isometry3d &source_perturbed)
 Calculate jacobian transform error difference expressed in the target frame coordinate system.
 
Eigen::VectorXd tesseract::common::calcJacobianTransformErrorDiff (const Eigen::Isometry3d &target, const Eigen::Isometry3d &source, const Eigen::Isometry3d &source_perturbed, const Eigen::Ref< const Eigen::VectorXd > &lower_tolerance, const Eigen::Ref< const Eigen::VectorXd > &upper_tolerance)
 Calculate jacobian transform error difference with optional per-component dead-band tolerances.
 
Eigen::VectorXd tesseract::common::calcJacobianTransformErrorDiff (const Eigen::Isometry3d &target, const Eigen::Isometry3d &target_perturbed, const Eigen::Isometry3d &source, const Eigen::Isometry3d &source_perturbed)
 Calculate jacobian transform error difference expressed in the target frame coordinate system.
 
Eigen::VectorXd tesseract::common::calcJacobianTransformErrorDiff (const Eigen::Isometry3d &target, const Eigen::Isometry3d &target_perturbed, const Eigen::Isometry3d &source, const Eigen::Isometry3d &source_perturbed, const Eigen::Ref< const Eigen::VectorXd > &lower_tolerance, const Eigen::Ref< const Eigen::VectorXd > &upper_tolerance)
 Calculate jacobian transform error difference (dynamic target) with optional per-component dead-band tolerances.
 
Eigen::Vector4d tesseract::common::computeRandomColor ()
 This computes a random color RGBA [0, 1] with alpha set to 1.
 
void tesseract::common::printNestedException (const std::exception &e, int level=0)
 Print a nested exception.
 
std::string tesseract::common::getTempPath ()
 Get the host temp directory path.
 
bool tesseract::common::isNumeric (const std::string &s)
 Determine if a string is a number.
 
bool tesseract::common::isNumeric (const std::vector< std::string > &sv)
 Determine if each string in vector is a number.
 
Eigen::VectorXd tesseract::common::generateRandomNumber (const Eigen::Ref< const Eigen::MatrixX2d > &limits)
 Given a set of limits it will generate a vector of random numbers between the limit.
 
void tesseract::common::ltrim (std::string &s)
 Left trim string.
 
void tesseract::common::rtrim (std::string &s)
 Right trim string.
 
void tesseract::common::trim (std::string &s)
 Trim left and right of string.
 
std::string tesseract::common::getTimestampString ()
 Get Timestamp string.
 
void tesseract::common::reorder (Eigen::Ref< Eigen::VectorXd > v, std::vector< Eigen::Index > order)
 Reorder Eigen::VectorXd implace given index list.
 
int tesseract::common::QueryStringValue (const tinyxml2::XMLElement *xml_element, std::string &value)
 Query a string value from xml element.
 
int tesseract::common::QueryStringText (const tinyxml2::XMLElement *xml_element, std::string &text)
 Query a string Text from xml element.
 
int tesseract::common::QueryStringValue (const tinyxml2::XMLAttribute *xml_attribute, std::string &value)
 Query a string value from xml attribute.
 
int tesseract::common::QueryStringAttribute (const tinyxml2::XMLElement *xml_element, const char *name, std::string &value)
 Query a string attribute from an xml element.
 
std::string tesseract::common::StringAttribute (const tinyxml2::XMLElement *xml_element, const char *name, std::string default_value)
 Get string attribute if exist. If it does not exist it returns the default value.
 
int tesseract::common::QueryStringAttributeRequired (const tinyxml2::XMLElement *xml_element, const char *name, std::string &value)
 Query a string attribute from an xml element and print error log.
 
int tesseract::common::QueryDoubleAttributeRequired (const tinyxml2::XMLElement *xml_element, const char *name, double &value)
 Query a double attribute from an xml element and print error log.
 
int tesseract::common::QueryIntAttributeRequired (const tinyxml2::XMLElement *xml_element, const char *name, int &value)
 Query a int attribute from an xml element and print error log.
 
bool tesseract::common::almostEqualRelativeAndAbs (double a, double b, double max_diff=1e-6, double max_rel_diff=std::numeric_limits< double >::epsilon())
 Check if two double are relatively equal.
 
bool tesseract::common::almostEqualRelativeAndAbs (const Eigen::Ref< const Eigen::VectorXd > &v1, const Eigen::Ref< const Eigen::VectorXd > &v2, double max_diff=1e-6, double max_rel_diff=std::numeric_limits< double >::epsilon())
 Check if two Eigen VectorXd are relatively and absolute equal.
 
bool tesseract::common::almostEqualRelativeAndAbs (const Eigen::Ref< const Eigen::VectorXd > &v1, const Eigen::Ref< const Eigen::VectorXd > &v2, const Eigen::Ref< const Eigen::VectorXd > &max_diff, const Eigen::Ref< const Eigen::VectorXd > &max_rel_diff)
 Check if two Eigen VectorXd are relatively and absolute equal.
 
std::vector< LinkIdtesseract::common::getAllowedCollisions (const std::vector< LinkId > &link_ids, const AllowedCollisionEntries &acm_entries, bool remove_duplicates=true)
 Gets allowed collisions for a set of link ids.
 

Detailed Description

Common Tesseract Utility Functions.

Author
Levi Armstrong
Date
January 18, 2018
License
Software License Agreement (Apache License)
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.