Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037 #ifndef JSK_FOOTSTEP_PLANNER_FOOTSTEP_GRAPH_H_
00038 #define JSK_FOOTSTEP_PLANNER_FOOTSTEP_GRAPH_H_
00039 #include <ros/ros.h>
00040 #include <jsk_footstep_msgs/FootstepArray.h>
00041
00042 #include "jsk_footstep_planner/graph.h"
00043 #include "jsk_footstep_planner/footstep_state.h"
00044 #include "jsk_footstep_planner/astar_solver.h"
00045 #include "jsk_footstep_planner/ann_grid.h"
00046 #include "jsk_footstep_planner/transition_limit.h"
00047
00048 namespace jsk_footstep_planner
00049 {
00050 class FootstepGraph: public Graph<FootstepState>
00051 {
00052 public:
00053 typedef boost::shared_ptr<FootstepGraph> Ptr;
00054 FootstepGraph(const Eigen::Vector3f& resolution,
00055 const bool use_pointcloud_model = false,
00056 const bool lazy_projection = true,
00057 const bool local_movement = false):
00058 max_successor_distance_(0.0), max_successor_rotation_(0.0),
00059 pos_goal_thr_(0.1), rot_goal_thr_(0.17), publish_progress_(false),
00060 resolution_(resolution),
00061 use_pointcloud_model_(use_pointcloud_model),
00062 lazy_projection_(lazy_projection),
00063 local_movement_(local_movement),
00064 pointcloud_model_2d_(new pcl::PointCloud<pcl::PointNormal>),
00065 tree_model_(new pcl::KdTreeFLANN<pcl::PointNormal>),
00066 tree_model_2d_(new pcl::search::Octree<pcl::PointNormal>(0.2)),
00067 grid_search_(new ANNGrid(0.05)),
00068 local_move_x_(0.1), local_move_y_(0.05), local_move_theta_(0.2),
00069 local_move_x_num_(3), local_move_y_num_(3), local_move_theta_num_(3),
00070 plane_estimation_max_iterations_(100),
00071 plane_estimation_min_inliers_(100),
00072 plane_estimation_outlier_threshold_(0.02),
00073 support_check_x_sampling_(3),
00074 support_check_y_sampling_(3),
00075 support_check_vertex_neighbor_threshold_(0.02)
00076 {}
00077 virtual std::vector<StatePtr> successors(StatePtr target_state);
00078 virtual bool isGoal(StatePtr state);
00079 virtual void setBasicSuccessors(
00080 std::vector<Eigen::Affine3f> left_to_right_successors);
00081
00082 virtual void setGoalState(
00083 FootstepState::Ptr left, FootstepState::Ptr right)
00084 {
00085 left_goal_state_ = left;
00086 right_goal_state_ = right;
00087 }
00088
00089 virtual void setLeftGoalState(FootstepState::Ptr goal)
00090 {
00091 left_goal_state_ = goal;
00092 }
00093
00094 virtual void setRightGoalState(FootstepState::Ptr goal)
00095 {
00096 right_goal_state_ = goal;
00097 }
00098
00103 virtual std::string infoString() const;
00104
00105 virtual FootstepState::Ptr getGoal(int leg)
00106 {
00107 if (leg == jsk_footstep_msgs::Footstep::LEFT) {
00108 return left_goal_state_;
00109 }
00110 else if (leg == jsk_footstep_msgs::Footstep::RIGHT) {
00111 return right_goal_state_;
00112 }
00113 else {
00114 return goal_state_;
00115 }
00116 }
00117
00118 virtual double maxSuccessorDistance()
00119 {
00120 return max_successor_distance_;
00121 }
00122 virtual double maxSuccessorRotation()
00123 {
00124 return max_successor_rotation_;
00125 }
00126
00127 virtual void setProgressPublisher(ros::NodeHandle& nh, std::string topic)
00128 {
00129 publish_progress_ = true;
00130 pub_progress_ = nh.advertise<jsk_footstep_msgs::FootstepArray>(topic, 1);
00131 }
00132
00133 virtual void setPointCloudModel(pcl::PointCloud<pcl::PointNormal>::Ptr model)
00134 {
00135 pointcloud_model_ = model;
00136 tree_model_->setInputCloud(pointcloud_model_);
00137
00138 pcl::ProjectInliers<pcl::PointNormal> proj;
00139 proj.setModelType(pcl::SACMODEL_PLANE);
00140 pcl::ModelCoefficients::Ptr
00141 plane_coefficients (new pcl::ModelCoefficients);
00142 plane_coefficients->values.resize(4.0);
00143 plane_coefficients->values[2] = 1.0;
00144 proj.setModelCoefficients(plane_coefficients);
00145 proj.setInputCloud(pointcloud_model_);
00146 proj.filter(*pointcloud_model_2d_);
00147 tree_model_2d_->setInputCloud(pointcloud_model_2d_);
00148 grid_search_->build(*model);
00149 }
00150 virtual bool projectGoal();
00151 virtual bool projectStart();
00152
00153 virtual bool usePointCloudModel() const { return use_pointcloud_model_; }
00154 virtual bool lazyProjection() const { return lazy_projection_; }
00155 virtual bool localMovement() const { return local_movement_; }
00156 virtual void setPositionGoalThreshold(double x) { pos_goal_thr_ = x; }
00157 virtual void setRotationGoalThreshold(double x) { rot_goal_thr_ = x; }
00158 virtual void setLocalXMovement(double x) { local_move_x_ = x; }
00159 virtual void setLocalYMovement(double x) { local_move_y_ = x; }
00160 virtual void setLocalThetaMovement(double x) { local_move_theta_ = x; }
00161 virtual void setLocalXMovementNum(size_t n) { local_move_x_num_ = n; }
00162 virtual void setLocalYMovementNum(size_t n) { local_move_y_num_ = n; }
00163 virtual void setLocalThetaMovementNum(size_t n) { local_move_theta_num_ = n; }
00164 virtual void setPlaneEstimationMaxIterations(int n) { plane_estimation_max_iterations_ = n; }
00165 virtual void setPlaneEstimationMinInliers(int n) { plane_estimation_min_inliers_ = n; }
00166 virtual void setPlaneEstimationOutlierThreshold(double d) { plane_estimation_outlier_threshold_ = d; }
00167 virtual void setSupportCheckXSampling(int n) { support_check_x_sampling_ = n; }
00168 virtual void setSupportCheckYSampling(int n) { support_check_y_sampling_ = n; }
00169 virtual void setSupportCheckVertexNeighborThreshold(double d) { support_check_vertex_neighbor_threshold_ = d; }
00170 virtual void setTransitionLimit(TransitionLimit::Ptr limit) { transition_limit_ = limit; }
00171 virtual TransitionLimit::Ptr getTransitionLimit() { return transition_limit_; }
00172 virtual FootstepState::Ptr projectFootstep(FootstepState::Ptr in);
00173 virtual FootstepState::Ptr projectFootstep(FootstepState::Ptr in, unsigned int& state);
00174
00175 virtual std::vector<FootstepState::Ptr> localMoveFootstepState(FootstepState::Ptr in);
00176 protected:
00177 pcl::PointCloud<pcl::PointNormal>::Ptr pointcloud_model_;
00178 pcl::PointCloud<pcl::PointNormal>::Ptr pointcloud_model_2d_;
00179 pcl::KdTreeFLANN<pcl::PointNormal>::Ptr tree_model_;
00180
00181 pcl::search::Octree<pcl::PointNormal>::Ptr tree_model_2d_;
00182 ANNGrid::Ptr grid_search_;
00183 std::vector<Eigen::Affine3f> successors_from_left_to_right_;
00184 std::vector<Eigen::Affine3f> successors_from_right_to_left_;
00185 FootstepState::Ptr left_goal_state_;
00186 FootstepState::Ptr right_goal_state_;
00187 double max_successor_distance_;
00188 double max_successor_rotation_;
00189 double pos_goal_thr_;
00190 double rot_goal_thr_;
00191 bool publish_progress_;
00192 const bool use_pointcloud_model_;
00193 const bool lazy_projection_;
00194 const bool local_movement_;
00195 TransitionLimit::Ptr transition_limit_;
00196 double local_move_x_;
00197 double local_move_y_;
00198 double local_move_theta_;
00199 size_t local_move_x_num_;
00200 size_t local_move_y_num_;
00201 size_t local_move_theta_num_;
00202
00203 ros::Publisher pub_progress_;
00204 const Eigen::Vector3f resolution_;
00205
00206 int plane_estimation_max_iterations_;
00207 int plane_estimation_min_inliers_;
00208 double plane_estimation_outlier_threshold_;
00209 int support_check_x_sampling_;
00210 int support_check_y_sampling_;
00211 double support_check_vertex_neighbor_threshold_;
00212 private:
00213
00214 };
00215
00216
00217 double footstepHeuristicZero(
00218 SolverNode<FootstepState, FootstepGraph>::Ptr node, FootstepGraph::Ptr graph);
00219 double footstepHeuristicStraight(
00220 SolverNode<FootstepState, FootstepGraph>::Ptr node, FootstepGraph::Ptr graph);
00221 double footstepHeuristicStraightRotation(
00222 SolverNode<FootstepState, FootstepGraph>::Ptr node, FootstepGraph::Ptr graph);
00223 double footstepHeuristicStepCost(
00224 SolverNode<FootstepState, FootstepGraph>::Ptr node, FootstepGraph::Ptr graph,
00225 double first_rotation_weight,
00226 double second_rotation_weight);
00227 }
00228
00229 #endif