sparse_planner.h
Go to the documentation of this file.
00001 /*
00002  * Software License Agreement (Apache License)
00003  *
00004  * Copyright (c) 2014, Southwest Research Institute
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  * sparse_planner.h
00020  *
00021  *  Created on: Dec 17, 2014
00022  *      Author: ros developer 
00023  */
00024 
00025 #ifndef SPARSE_PLANNER_H_
00026 #define SPARSE_PLANNER_H_
00027 
00028 #include <descartes_core/path_planner_base.h>
00029 #include <descartes_planner/planning_graph.h>
00030 #include <tuple>
00031 
00032 namespace descartes_planner
00033 {
00034 
00035 class SparsePlanner: public descartes_core::PathPlannerBase
00036 {
00037 
00038 public:
00039   typedef std::vector<std::tuple<int,descartes_core::TrajectoryPtPtr,descartes_trajectory::JointTrajectoryPt> > SolutionArray;
00040 public:
00041   SparsePlanner(descartes_core::RobotModelConstPtr model,double sampling = 0.1f);
00042   SparsePlanner();
00043   virtual ~SparsePlanner();
00044 
00045   virtual bool initialize(descartes_core::RobotModelConstPtr model);
00046   virtual bool setConfig(const descartes_core::PlannerConfig& config);
00047   virtual void getConfig(descartes_core::PlannerConfig& config) const;
00048   virtual bool planPath(const std::vector<descartes_core::TrajectoryPtPtr>& traj);
00049   virtual bool addAfter(const descartes_core::TrajectoryPt::ID& ref_id,descartes_core::TrajectoryPtPtr cp);
00050   virtual bool addBefore(const descartes_core::TrajectoryPt::ID& ref_id,descartes_core::TrajectoryPtPtr cp);
00051   virtual bool modify(const descartes_core::TrajectoryPt::ID& ref_id,descartes_core::TrajectoryPtPtr cp);
00052   virtual bool remove(const descartes_core::TrajectoryPt::ID& ref_id);
00053   virtual bool getPath(std::vector<descartes_core::TrajectoryPtPtr>& path) const;
00054   virtual int getErrorCode() const;
00055   virtual bool getErrorMessage(int error_code, std::string& msg) const;
00056 
00057 
00058   void setSampling(double sampling);
00059   const std::map<descartes_core::TrajectoryPt::ID,descartes_trajectory::JointTrajectoryPt>& getSolution();
00060   bool getSolutionJointPoint(const descartes_trajectory::CartTrajectoryPt::ID& cart_id,descartes_trajectory::JointTrajectoryPt& j);
00061 
00062 protected:
00063 
00064   bool plan();
00065   bool interpolateJointPose(const std::vector<double>& start,const std::vector<double>& end,
00066                    double t,std::vector<double>& interp);
00067   int interpolateSparseTrajectory(const SolutionArray& sparse_solution,int &sparse_index, int &point_pos);
00068   void sampleTrajectory(double sampling,const std::vector<descartes_core::TrajectoryPtPtr>& dense_trajectory_array,
00069                         std::vector<descartes_core::TrajectoryPtPtr>& sparse_trajectory_array);
00070 
00071   int getDensePointIndex(const descartes_core::TrajectoryPt::ID& ref_id);
00072   int getSparsePointIndex(const descartes_core::TrajectoryPt::ID& ref_id);
00073   int findNearestSparsePointIndex(const descartes_core::TrajectoryPt::ID& ref_id,bool skip_equal = true);
00074   bool isInSparseTrajectory(const descartes_core::TrajectoryPt::ID& ref_id);
00075   bool checkJointChanges(const std::vector<double>& s1,
00076                                         const std::vector<double>& s2, const double& max_change);
00077 
00078   bool getOrderedSparseArray(std::vector<descartes_core::TrajectoryPtPtr>& sparse_array);
00079   bool getSparseSolutionArray(SolutionArray& sparse_solution_array);
00080 
00081 protected:
00082 
00083   enum class InterpolationResult: int
00084   {
00085     ERROR = -1,
00086     REPLAN,
00087     SUCCESS
00088   };
00089 
00090   double sampling_;
00091   int error_code_;
00092   std::map<int,std::string> error_map_;
00093   descartes_core::PlannerConfig config_;
00094   boost::shared_ptr<PlanningGraph> planning_graph_;
00095   std::vector<descartes_core::TrajectoryPtPtr> cart_points_;
00096   SolutionArray sparse_solution_array_;
00097   std::map<descartes_core::TrajectoryPt::ID,descartes_trajectory::JointTrajectoryPt> joint_points_map_;
00098   std::vector<descartes_core::TimingConstraint> timing_cache_;
00099 
00100 
00101 };
00102 
00103 } /* namespace descartes_planner */
00104 #endif /* SPARSE_PLANNER_H_ */


descartes_planner
Author(s): Jorge Nicho
autogenerated on Wed Aug 26 2015 11:21:35