5 #include <pcl/io/pcd_io.h> 6 #include <pcl/kdtree/kdtree_flann.h> 8 #include <vigir_footstep_planning_lib/helper.h> 9 #include <vigir_footstep_planning_lib/math.h> 11 #include <vigir_terrain_classifier/terrain_model.h> 18 : TerrainModelPlugin(name)
24 if (!TerrainModelPlugin::initialize(params))
32 getParam(
"terrain_model_topic", topic, std::string(
"terrain_model"),
true);
40 if (!TerrainModelPlugin::loadParams(params))
47 params.getParam(
"foot_contact_support/max_intrusion_z",
max_intrusion_z);
49 params.getParam(
"foot_contact_support/minimal_support",
minimal_support);
56 TerrainModelPlugin::reset();
84 if (!this->terrain_model)
85 this->terrain_model.reset(
new vigir_terrain_classifier::TerrainModel(*terrain_model));
87 this->terrain_model->fromMsg(*terrain_model);
111 tf::poseMsgToTF(p, p_tf);
125 else if (support < 0.95)
134 bool TerrainModel::getFootContactSupport(
const tf::Pose& p,
double &support,
unsigned int sampling_steps_x,
unsigned int sampling_steps_y, pcl::PointCloud<pcl::PointXYZI>::Ptr checked_positions)
const 141 unsigned int contacts = 0;
142 unsigned int unknown = 0;
143 unsigned int total = 0;
145 tf::Vector3 orig_pos;
148 double foot_size_half_x = 0.5*
foot_size.x;
149 double foot_size_half_y = 0.5*
foot_size.y;
151 double sampling_step_x =
foot_size.x/(double)(sampling_steps_x-1);
152 double sampling_step_y =
foot_size.y/(double)(sampling_steps_y-1);
154 for (
double y = -foot_size_half_y; y <= foot_size_half_y; y+=sampling_step_y)
157 for (
double x = -foot_size_half_x; x <= foot_size_half_x; x+=sampling_step_x)
164 const tf::Vector3 &trans_pos = p * orig_pos;
167 if (!
getHeight(trans_pos.getX(), trans_pos.getY(), height))
175 double diff = trans_pos.getZ()-height;
178 if (checked_positions)
180 pcl::PointXYZI p_checked;
181 p_checked.x = trans_pos.getX();
182 p_checked.y = trans_pos.getY();
183 p_checked.z = trans_pos.getZ();
184 p_checked.intensity = std::abs(diff);
185 checked_positions->push_back(p_checked);
198 if (unknown == total)
205 support =
static_cast<double>(contacts)/static_cast<double>(total);
234 pcl::PointNormal p_n;
246 s.setNormal(p_n.normal_x, p_n.normal_y, p_n.normal_z);
250 double support = 0.0;
258 s.setGroundContactSupport(support);
265 #include <pluginlib/class_list_macros.h>