cart_trajectory_pt.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (Apache License)
00003  *
00004  * Copyright (c) 2014, Dan Solomon
00005  *
00006  * Licensed under the Apache License, Version 2.0 (the "License");
00007  * you may not use this file except in compliance with the License.
00008  * You may obtain a copy of the License at
00009  *
00010  * http://www.apache.org/licenses/LICENSE-2.0
00011  *
00012  * Unless required by applicable law or agreed to in writing, software
00013  * distributed under the License is distributed on an "AS IS" BASIS,
00014  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00015  * See the License for the specific language governing permissions and
00016  * limitations under the License.
00017  */
00018 /*
00019  * cart_trajectory_pt.h
00020  *
00021  *  Created on: Oct 3, 2014
00022  *      Author: Dan Solomon
00023  */
00024 
00025 #ifndef CART_TRAJECTORY_PT_H_
00026 #define CART_TRAJECTORY_PT_H_
00027 
00028 #include <moveit/kinematic_constraints/kinematic_constraint.h>
00029 #include "descartes_core/trajectory_pt.h"
00030 #include "ros/console.h"
00031 
00032 typedef boost::shared_ptr<kinematic_constraints::PositionConstraint> PositionConstraintPtr;
00033 typedef boost::shared_ptr<kinematic_constraints::OrientationConstraint> OrientationConstraintPtr;
00034 
00035 namespace descartes_trajectory
00036 {
00037 
00042 struct ToleranceBase
00043 {
00044 
00051   template<typename T>
00052   static T createSymmetric(double x, double y, double z,
00053                                           double x_tol, double y_tol, double z_tol)
00054   {
00055     double x_lower = x - x_tol/2.0;
00056     double x_upper = x + x_tol/2.0;
00057 
00058     double y_lower = y - y_tol/2.0;
00059     double y_upper = y + y_tol/2.0;
00060 
00061     double z_lower = z - z_tol/2.0;
00062     double z_upper = z + z_tol/2.0;
00063 
00064     return(T(x_lower, x_upper, y_lower, y_upper, z_lower, z_upper));
00065   }
00066 
00072   template<typename T>
00073   static T createSymmetric(const double& x, const double& y, const double& z,
00074                                           const double& tol)
00075   {
00076     return(createSymmetric<T>(x, y, z, tol, tol, tol));
00077   }
00078 
00083   template<typename T>
00084   static T zeroTolerance(const double& x, const double& y, const double& z)
00085   {
00086     return(createSymmetric<T>(x, y, z, 0.0, 0.0, 0.0));
00087   }
00088 
00089 
00093   ToleranceBase(): x_upper(0.), y_upper(0.), z_upper(0.),
00094     x_lower(0.), y_lower(0.), z_lower(0.)
00095   {}
00096 
00101   ToleranceBase(double x_lower_lim, double  x_upper_lim, double y_lower_lim, double y_upper_lim,
00102                 double z_lower_lim, double z_upper_lim):
00103     x_upper(x_upper_lim), y_upper(y_upper_lim), z_upper(z_upper_lim),
00104     x_lower(x_lower_lim), y_lower(y_lower_lim), z_lower(z_lower_lim)
00105   {
00106     ROS_DEBUG_STREAM("Creating fully defined Tolerance(base type)");
00107     ROS_DEBUG_STREAM("Initializing x tolerance (lower/upper)" << x_lower << "/" << x_upper);
00108     ROS_DEBUG_STREAM("Initializing y tolerance (lower/upper)" << y_lower << "/" << y_upper);
00109     ROS_DEBUG_STREAM("Initializing z tolerance (lower/upper)" << z_lower << "/" << z_upper);
00110   }
00111 
00112   void clear() {x_upper = y_upper = z_upper = x_lower = y_lower = z_lower = 0.;}
00113 
00114   double x_upper, y_upper, z_upper, x_lower, y_lower, z_lower;
00115 
00116 };
00117 
00118 
00122 struct PositionTolerance : public ToleranceBase
00123 {
00124   PositionTolerance() : ToleranceBase()
00125   {}
00126 
00127   PositionTolerance(double x_lower_lim, double  x_upper_lim, double y_lower_lim, double y_upper_lim,
00128                     double z_lower_lim, double z_upper_lim):
00129     ToleranceBase(x_lower_lim, x_upper_lim, y_lower_lim, y_upper_lim, z_lower_lim, z_upper_lim)
00130   {
00131     ROS_DEBUG_STREAM("Created fully defined Position Tolerance");
00132   }
00133 
00134 };
00135 
00139 struct OrientationTolerance : public ToleranceBase
00140 {
00141   OrientationTolerance() : ToleranceBase()
00142   {}
00143 
00144   OrientationTolerance(double x_lower_lim, double  x_upper_lim, double y_lower_lim, double y_upper_lim,
00145                     double z_lower_lim, double z_upper_lim):
00146     ToleranceBase(x_lower_lim, x_upper_lim, y_lower_lim, y_upper_lim, z_lower_lim, z_upper_lim)
00147   {
00148     ROS_DEBUG_STREAM("Created fully defined Orientation Tolerance");
00149   }
00150 };
00151 
00155 struct TolerancedFrame: public descartes_core::Frame
00156 {
00157   TolerancedFrame(){};
00158   TolerancedFrame(const Eigen::Affine3d &a):
00159     descartes_core::Frame(a)
00160   {
00161     Eigen::Vector3d t = a.translation();
00162     Eigen::Matrix3d m = a.rotation();
00163     Eigen::Vector3d rxyz = m.eulerAngles(0,1,2);
00164     position_tolerance =  ToleranceBase::createSymmetric<PositionTolerance>(t(0),t(1),t(2),0);
00165     orientation_tolerance = ToleranceBase::createSymmetric<OrientationTolerance>(rxyz(0),rxyz(1),rxyz(2),0);
00166   };
00167   TolerancedFrame(const descartes_core::Frame &a):
00168     descartes_core::Frame(a)
00169   {
00170     Eigen::Vector3d t = a.frame.translation();
00171     Eigen::Matrix3d m = a.frame.rotation();
00172     Eigen::Vector3d rxyz = m.eulerAngles(0,1,2);
00173     position_tolerance =  ToleranceBase::createSymmetric<PositionTolerance>(t(0),t(1),t(2),0);
00174     orientation_tolerance = ToleranceBase::createSymmetric<OrientationTolerance>(rxyz(0),rxyz(1),rxyz(2),0);
00175   };
00176 
00177   TolerancedFrame(const Eigen::Affine3d &a, const PositionTolerance &pos_tol,
00178                   const OrientationTolerance &orient_tol) :
00179     Frame(a), position_tolerance(pos_tol), orientation_tolerance(orient_tol){}
00180 
00181   PositionTolerance             position_tolerance;
00182   OrientationTolerance          orientation_tolerance;
00183   PositionConstraintPtr         position_constraint;
00184   OrientationConstraintPtr      orientation_constraint;
00185 };
00186 
00187 
00203 class CartTrajectoryPt : public descartes_core::TrajectoryPt
00204 {
00205 public:
00206   EIGEN_MAKE_ALIGNED_OPERATOR_NEW;
00207 public:
00208 
00212   CartTrajectoryPt(const descartes_core::TimingConstraint& timing = descartes_core::TimingConstraint());
00213 
00223   CartTrajectoryPt(const descartes_core::Frame &wobj_base, const TolerancedFrame &wobj_pt, const descartes_core::Frame &tool_base,
00224                    const TolerancedFrame &tool_pt, double pos_increment, double orient_increment, 
00225                    const descartes_core::TimingConstraint& timing = descartes_core::TimingConstraint());
00226 
00235   CartTrajectoryPt(const TolerancedFrame &wobj_pt, double pos_increment, double orient_increment,
00236                    const descartes_core::TimingConstraint& timing = descartes_core::TimingConstraint());
00237 
00238 
00245   CartTrajectoryPt(const descartes_core::Frame &wobj_pt, 
00246                    const descartes_core::TimingConstraint& timing = descartes_core::TimingConstraint());
00247 
00248 
00249   virtual ~CartTrajectoryPt() {};
00250 
00251 
00256     //TODO complete
00257     virtual bool getClosestCartPose(const std::vector<double> &seed_state,
00258                                       const descartes_core::RobotModel &model, Eigen::Affine3d &pose) const;
00259 
00260     //TODO complete
00261     virtual bool getNominalCartPose(const std::vector<double> &seed_state,
00262                                       const descartes_core::RobotModel &model, Eigen::Affine3d &pose) const;
00263 
00264     //TODO complete
00265     virtual void getCartesianPoses(const descartes_core::RobotModel &model, EigenSTL::vector_Affine3d &poses) const;
00272     //TODO complete
00273     virtual bool getClosestJointPose(const std::vector<double> &seed_state,
00274                                        const descartes_core::RobotModel &model,
00275                                        std::vector<double> &joint_pose) const;
00276     //TODO complete
00277     virtual bool getNominalJointPose(const std::vector<double> &seed_state,
00278                                        const descartes_core::RobotModel &model,
00279                                        std::vector<double> &joint_pose) const;
00280 
00281     //TODO complete
00282     virtual void getJointPoses(const descartes_core::RobotModel &model,
00283                                  std::vector<std::vector<double> > &joint_poses) const;
00286     //TODO complete
00287     virtual bool isValid(const descartes_core::RobotModel &model) const;
00292   virtual bool setDiscretization(const std::vector<double> &discretization);
00293 
00294   virtual descartes_core::TrajectoryPtPtr copy() const
00295   {
00296     return descartes_core::TrajectoryPtPtr(new CartTrajectoryPt(*this));
00297   }
00298 
00299   inline
00300   void setTool(const descartes_core::Frame &base, const TolerancedFrame &pt)
00301   {
00302     tool_base_ = base;
00303     tool_pt_ = pt;
00304   }
00305 
00306   inline
00307   void setWobj(const descartes_core::Frame &base, const TolerancedFrame &pt)
00308   {
00309     wobj_base_ = base;
00310     wobj_pt_ = pt;
00311   }
00312 
00313 
00314 protected:
00315 
00316   bool computeCartesianPoses(EigenSTL::vector_Affine3d& poses) const;
00317 
00318 protected:
00319   descartes_core::Frame                         tool_base_;     
00320   TolerancedFrame               tool_pt_;       
00321   descartes_core::Frame                         wobj_base_;     
00322   TolerancedFrame               wobj_pt_;       
00324   double                        pos_increment_;    
00325   double                        orient_increment_; 
00327 };
00328 
00329 } /* namespace descartes_trajectory */
00330 
00331 
00332 
00333 #endif /* CART_TRAJECTORY_PT_H_ */


descartes_trajectory
Author(s): Jorge Nicho
autogenerated on Wed Aug 26 2015 11:21:27