30 #include <urdf_parser/urdf_parser.h> 38 std::string robot_description;
39 if (!nh.
getParam(
"robot_description", robot_description))
45 urdf::ModelInterfaceSharedPtr model;
48 model = urdf::parseURDF(robot_description);
50 catch (std::exception ex)
53 "getMassAndInertia() couldn't parse URDF at " << nh.
getNamespace() <<
"/robot_description: " << ex.what());
57 urdf::InertialSharedPtr inertial = model->getRoot()->inertial;
58 if (!inertial || !inertial->mass || !inertial->ixx || !inertial->iyy || !inertial->izz)
61 "getMassAndInertia() requires inertial information stored on the root link " << nh.
getNamespace() <<
62 "/robot_description");
66 mass = inertial->mass;
67 inertia[0] = inertial->ixx;
68 inertia[1] = inertial->iyy;
69 inertia[2] = inertial->izz;
73 bool poseWithinTolerance(
const geometry_msgs::Pose &pose_current,
const geometry_msgs::Pose &pose_target,
74 const double dist_tolerance,
const double yaw_tolerance)
77 if(yaw_tolerance > 0.0)
79 double yaw_current, yaw_target;
87 double yaw_error = yaw_current - yaw_target;
91 yaw_error -= 2 * M_PI;
93 else if (yaw_error < -M_PI)
95 yaw_error += 2 * M_PI;
97 if (std::abs(yaw_error) > yaw_tolerance)
105 if(dist_tolerance > 0.0)
107 tf2::Vector3 v_current(pose_current.position.x, pose_current.position.y, pose_current.position.z);
108 tf2::Vector3 v_target(pose_target.position.x, pose_target.position.y, pose_target.position.z);
109 if ((v_current - v_target).
length() > dist_tolerance)
void getRPY(tf2Scalar &roll, tf2Scalar &pitch, tf2Scalar &yaw, unsigned int solution_number=1) const
bool poseWithinTolerance(const geometry_msgs::Pose &pose_current, const geometry_msgs::Pose &pose_target, const double dist_tolerance, const double yaw_tolerance)
TF2SIMD_FORCE_INLINE tf2Scalar length(const Quaternion &q)
void fromMsg(const A &, B &b)
const std::string & getNamespace() const
#define ROS_DEBUG_STREAM(args)
bool getParam(const std::string &key, std::string &s) const
bool getMassAndInertia(const ros::NodeHandle &nh, double &mass, double inertia[3])
#define ROS_ERROR_STREAM(args)