00001 #include "descartes_trajectory/axial_symmetric_pt.h"
00002
00003 using descartes_trajectory::TolerancedFrame;
00004 using descartes_trajectory::AxialSymmetricPt;
00005 using namespace descartes_core::utils;
00006
00007 static TolerancedFrame makeUnconstrainedRotation(double x, double y, double z, double rx, double ry, double rz,
00008 AxialSymmetricPt::FreeAxis axis)
00009 {
00010 using namespace descartes_trajectory;
00011
00012 Eigen::Affine3d pose = toFrame(x, y, z, rx, ry, rz, EulerConventions::XYZ);
00013 PositionTolerance pos_tol = ToleranceBase::zeroTolerance<PositionTolerance>(x, y, z);
00014 OrientationTolerance orient_tol = ToleranceBase::createSymmetric<OrientationTolerance>(
00015 ((axis == AxialSymmetricPt::X_AXIS) ? 0.0 : rx), ((axis == AxialSymmetricPt::Y_AXIS) ? 0.0 : ry),
00016 ((axis == AxialSymmetricPt::Z_AXIS) ? 0.0 : rz), ((axis == AxialSymmetricPt::X_AXIS) ? 2 * M_PI : 0.0),
00017 ((axis == AxialSymmetricPt::Y_AXIS) ? 2 * M_PI : 0.0), ((axis == AxialSymmetricPt::Z_AXIS) ? 2 * M_PI : 0.0));
00018 return TolerancedFrame(pose, pos_tol, orient_tol);
00019 }
00020
00021 static TolerancedFrame makeUnconstrainedRotation(const Eigen::Affine3d& pose, AxialSymmetricPt::FreeAxis axis)
00022 {
00023 using namespace descartes_trajectory;
00024
00025 Eigen::Vector3d rpy = pose.rotation().eulerAngles(0, 1, 2);
00026 double rx = rpy(0);
00027 double ry = rpy(1);
00028 double rz = rpy(2);
00029 double x = pose.translation()(0);
00030 double y = pose.translation()(1);
00031 double z = pose.translation()(2);
00032
00033 PositionTolerance pos_tol = ToleranceBase::zeroTolerance<PositionTolerance>(x, y, z);
00034 OrientationTolerance orient_tol = ToleranceBase::createSymmetric<OrientationTolerance>(
00035 ((axis == AxialSymmetricPt::X_AXIS) ? 0.0 : rx), ((axis == AxialSymmetricPt::Y_AXIS) ? 0.0 : ry),
00036 ((axis == AxialSymmetricPt::Z_AXIS) ? 0.0 : rz), ((axis == AxialSymmetricPt::X_AXIS) ? 2 * M_PI : 0.0),
00037 ((axis == AxialSymmetricPt::Y_AXIS) ? 2 * M_PI : 0.0), ((axis == AxialSymmetricPt::Z_AXIS) ? 2 * M_PI : 0.0));
00038 return TolerancedFrame(pose, pos_tol, orient_tol);
00039 }
00040
00041 namespace descartes_trajectory
00042 {
00043 AxialSymmetricPt::AxialSymmetricPt(const descartes_core::TimingConstraint& timing) : CartTrajectoryPt(timing)
00044 {
00045 }
00046
00047 AxialSymmetricPt::AxialSymmetricPt(double x, double y, double z, double rx, double ry, double rz,
00048 double orient_increment, FreeAxis axis,
00049 const descartes_core::TimingConstraint& timing)
00050 : CartTrajectoryPt(makeUnconstrainedRotation(x, y, z, rx, ry, rz, axis),
00051 0.0,
00052 orient_increment,
00053 timing)
00054 {
00055 }
00056
00057 AxialSymmetricPt::AxialSymmetricPt(const Eigen::Affine3d& pose, double orient_increment, FreeAxis axis,
00058 const descartes_core::TimingConstraint& timing)
00059 : CartTrajectoryPt(makeUnconstrainedRotation(pose, axis),
00060 0.0,
00061 orient_increment,
00062 timing)
00063 {
00064 }
00065
00066 }