13 Eigen::Isometry2d iso;
14 iso.translation() = Eigen::Vector2d(x, y);
15 iso.linear() = Eigen::Rotation2D<double>(theta).toRotationMatrix();
27 return Eigen::Rotation2D<double>(frame.linear()).angle();
32 const auto &t = frame.translation();
38 if (alpha > 1 || alpha < 0)
40 SE2EZ_WARN(
"Parameter alpha must be in [0,1] defaulting to 0.75");
44 return alpha * (t1.translation() - t2.translation()).norm()
52 return KDL::Frame(KDL::Rotation::RPY(0., 0., v[2]), KDL::Vector(v[0], v[1], 0));
57 Eigen::Isometry2d iso;
68 KDL::JntArray jnt(vec.size());
69 for (
unsigned int i = 0; i < vec.size(); ++i)
93 ss.
setf(std::ios::fixed, std::ios::floatfield);
98 for (
unsigned int i = 0; i < v.size(); ++i)
101 if (i < v.size() - 1)
112 ss.
setf(std::ios::fixed, std::ios::floatfield);
115 for (
unsigned int j = 0; j < v.rows(); ++j)
117 ss << ((j) ?
" " :
"[ ");
118 for (
unsigned int i = 0; i < v.cols(); ++i)
120 ss <<
std::setw(precision + 4) << v(j, i);
121 if (i < v.cols() - 1)
125 if (j < v.rows() - 1)
136 return Eigen::VectorXd::Constant(1, x);
141 Eigen::VectorXd r(x.
size());
144 for (
unsigned int i = 0; i < x.
size(); ++i)
152 Eigen::MatrixXd M(vlist.
size(), vlist[0].
size());
154 for (
unsigned int i = 0; i < M.rows(); i++)
160 double math::remap(
double a1,
double a2,
double av,
double b1,
double b2)
162 double dat = fabs(a2 - a1);
163 double dav = fabs(av - a1);
165 double dbt = fabs(b2 - b1);
166 double dbv = dbt * (dav / dat);
168 double bv = b1 + dbv;
181 return (v > b) ? b : ((v < a) ? a : v);
214 return -(360. - v) *
math::pi / 180.;
221 SE2EZ_ERROR(
"Lower bound must be lower than upper bound");
225 return rng.uniformReal(lower, upper);
231 SE2EZ_ERROR(
"Lower bound must be lower than upper bound");
233 return rng.uniformInt(lower, upper);
238 return rng.gaussian(mean, std);
Eigen::Isometry2d KDLToEigenFrame(const KDL::Frame &frame)
Converts an KDL transformation into a Eigen transformation.
double gaussianReal(double mean, double std)
Return a random number sampled from a gaussain with given std and mean.
double toRadians(double v)
Convert an angle to radians.
Eigen::Vector3d flattenIsometry(const Eigen::Isometry2d &frame)
Converts a transformation frame into a vector [x, y, t] composed of a translation (x...
Eigen::MatrixXd toMatrix(const std::vector< Eigen::VectorXd > &vlist)
Converts a vector of lists into a Matrix.
std::string printFrame(const Eigen::Isometry2d &frame)
Returns a string "[x, y, t]" of the translation (x, y) and rotation (t) component of a transform...
double uniformReal(double lower, double upper)
Return a uniform random number between lower and upper.
double getRotation(const Eigen::Isometry2d &frame)
Gets rotation from a frame from the X-axis (t)
double clamp(double v, double a, double b)
Clamp a value v between a range [a, b].
std::string printMatrix(const Eigen::MatrixXd &v, unsigned int precision=4)
Returns a string of a matrix's contents.
Eigen::VectorXd KDLToEigenVec(const KDL::JntArray &array)
Converts an KDL vector into a Eigen vector.
double transformDistance(const Eigen::Isometry2d &t1, const Eigen::Isometry2d &t2=Eigen::Isometry2d::Identity(), double alpha=0.75)
Return the transform distance between two transformations, w is the weight of the euclidean distance...
Eigen::Isometry2d toIsometry(double x, double y, double theta)
Converts a translation (x, y) and rotation from X-axis (theta) into a transform.
#define SE2EZ_WARN(fmt,...)
Eigen::VectorXd toVector(double x)
Converts a single double value into a 1 x 1 matrix.
double angleNormalize(double v)
Normalize an angle between -pi to pi.
KDL::JntArray EigenToKDLVec(const Eigen::VectorXd &vec)
Converts an Eigen vector into a KDL vector.
std::string printVector(const Eigen::VectorXd &v, unsigned int precision=4)
Returns a string of a vector's contents.
KDL::Frame EigenToKDLFrame(const Eigen::Isometry2d &iso)
Converts an Eigen transformation into a KDL transformation.
int uniformInteger(int lower, int upper)
Return a uniform random integer between lower and upper (inclusive).
double toDegrees(double v)
Convert an angle to degrees.
#define SE2EZ_ERROR(fmt,...)
double remap(double a1, double a2, double av, double b1, double b2)
Remap a value av in the interval a1, a2 to the interval b1, b2.
static ompl::RNG rng
Random number generation from OMPL. An instance of this class cannot be used by multiple threads at o...
double angleDistance(double v1, double v2)
Return the minimum distance between two angles (wrapping from -pi to pi).