37 #ifndef JSK_FOOTSTEP_PLANNER_FOOTSTEP_STATE_H_ 38 #define JSK_FOOTSTEP_PLANNER_FOOTSTEP_STATE_H_ 40 #include <jsk_footstep_msgs/Footstep.h> 42 #include <pcl/kdtree/kdtree_flann.h> 43 #include <pcl/filters/crop_box.h> 44 #include <pcl/sample_consensus/method_types.h> 45 #include <pcl/sample_consensus/model_types.h> 46 #include <pcl/segmentation/sac_segmentation.h> 47 #include <pcl/segmentation/sac_segmentation.h> 48 #include <pcl/filters/project_inliers.h> 49 #include <pcl/search/octree.h> 58 namespace projection_state
85 const Eigen::Affine3f& pose,
86 const Eigen::Vector3f& dimensions,
88 leg_(leg),
pose_(pose), dimensions_(dimensions), resolution_(resolution)
91 float x =
pose_.translation()[0];
92 float y =
pose_.translation()[1];
94 pcl::getEulerAngles(
pose_, roll, pitch, yaw);
95 index_x_ = x / resolution_[0];
96 index_y_ = y / resolution_[1];
97 index_yaw_ = yaw / resolution_[2];
101 const Eigen::Affine3f& pose,
102 const Eigen::Vector3f& dimensions,
107 leg_(leg),
pose_(pose), dimensions_(dimensions), resolution_(resolution),
108 index_x_(index_x), index_y_(index_y), index_yaw_(index_yaw)
110 debug_print_ =
false;
115 const Eigen::Vector3f&
size,
118 inline float cross2d(
const Eigen::Vector2f& a,
const Eigen::Vector2f& b)
const 120 return a[0] * b[1] - a[1] * b[0];
122 virtual jsk_footstep_msgs::Footstep::Ptr toROSMsg();
123 virtual jsk_footstep_msgs::Footstep::Ptr toROSMsg(
const Eigen::Vector3f& ioffset);
126 projectToCloud(pcl::KdTreeFLANN<pcl::PointNormal>&
tree,
127 pcl::PointCloud<pcl::PointNormal>::Ptr
cloud,
129 pcl::search::Octree<pcl::PointNormal>& tree_2d,
130 pcl::PointCloud<pcl::PointNormal>::Ptr cloud_2d,
131 const Eigen::Vector3f&
z,
132 unsigned int& error_state,
133 double outlier_threshold,
136 int foot_x_sampling_num = 3,
137 int foot_y_sampling_num = 3,
138 double vertex_threshold = 0.02,
139 const bool skip_cropping =
true,
140 const bool use_normal =
false,
141 double normal_distance_weight = 0.2,
142 double normal_opening_angle = 0.2,
143 double min_ratio_of_inliers = 0.8);
146 projectToCloud(pcl::KdTreeFLANN<pcl::PointNormal>& tree,
147 pcl::PointCloud<pcl::PointNormal>::Ptr cloud,
149 pcl::search::Octree<pcl::PointNormal>& tree_2d,
150 pcl::PointCloud<pcl::PointNormal>::Ptr cloud_2d,
151 const Eigen::Vector3f& z,
152 unsigned int& error_state,
156 pcl::PointIndices::Ptr
158 pcl::search::Octree<pcl::PointNormal>& tree);
160 pcl::PointIndices::Ptr
161 cropPointCloud(pcl::PointCloud<pcl::PointNormal>::Ptr cloud,
163 double padding_x = 0.0,
double padding_y = 0.0);
165 pcl::PointIndices::Ptr
166 cropPointCloudExact(pcl::PointCloud<pcl::PointNormal>::Ptr cloud,
167 pcl::PointIndices::Ptr near_indices,
168 double padding_x = 0.0,
double padding_y = 0.0);
170 template <
class Po
intT>
174 p.getVector3fMap() = Eigen::Vector3f(
pose_.translation());
182 double collision_padding = 0)
184 const Eigen::Vector3f ux = Eigen::Vector3f::UnitX();
185 const Eigen::Vector3f uy = Eigen::Vector3f::UnitY();
186 double dim0 = dimensions_[0] + collision_padding;
187 double dim1 = dimensions_[1] + collision_padding;
188 a = Eigen::Vector3f((
pose_ * Eigen::Translation3f( ux * dim0 / 2 + uy * dim1 / 2)).translation());
189 b = Eigen::Vector3f((
pose_ * Eigen::Translation3f(- ux * dim0 / 2 + uy * dim1 / 2)).translation());
190 c = Eigen::Vector3f((
pose_ * Eigen::Translation3f(- ux * dim0 / 2 - uy * dim1 / 2)).translation());
191 d = Eigen::Vector3f((
pose_ * Eigen::Translation3f( ux * dim0 / 2 - uy * dim1 / 2)).translation());
201 virtual void setPose(
const Eigen::Affine3f& pose)
206 virtual int getLeg()
const {
return leg_; }
210 return ((index_x_ == other.
index_x_) &&
218 inline virtual int indexX() {
return index_x_; }
219 inline virtual int indexY() {
return index_y_; }
220 inline virtual int indexT() {
return index_yaw_; }
224 isSupportedByPointCloud(
const Eigen::Affine3f&
pose,
225 pcl::PointCloud<pcl::PointNormal>::Ptr cloud,
226 pcl::KdTreeFLANN<pcl::PointNormal>& tree,
227 pcl::PointIndices::Ptr inliers,
228 const int foot_x_sampling_num,
229 const int foot_y_sampling_num,
230 const double vertex_threshold);
232 isSupportedByPointCloudWithoutCropping(
const Eigen::Affine3f& pose,
233 pcl::PointCloud<pcl::PointNormal>::Ptr cloud,
234 pcl::KdTreeFLANN<pcl::PointNormal>& tree,
235 pcl::PointIndices::Ptr inliers,
236 const int foot_x_sampling_num,
237 const int foot_y_sampling_num,
238 const double vertex_threshold);
240 virtual Eigen::Affine3f midcoords(
const FootstepState& other);
256 return std::abs(s->indexX()) << (25 + 14) + std::abs(s->indexY()) << 14
257 + std::abs(s->indexT());
const geometry_msgs::Pose * pose_
void cropPointCloud(const typename pcl::PointCloud< PointT >::Ptr &cloud, const jsk_recognition_msgs::BoundingBox &bbox_msg, std::vector< int > *indices, bool extract_removed_indices=false)