upper_body_grid_map_model.cpp
Go to the documentation of this file.
2 
3 
4 
6 {
8  : GridMapModel(name)
9 {
10 }
11 
12 bool UpperBodyGridMapModel::initialize(const vigir_generic_params::ParameterSet& params)
13 {
14  if (!GridMapModel::initialize(params))
15  return false;
16 
17  // get upper body dimensions
18  getUpperBodySize(nh_, upper_body_size);
19  getUpperBodyOriginShift(nh_, upper_body_origin_shift);
20 
21  return true;
22 }
23 
24 bool UpperBodyGridMapModel::isAccessible(const State& /*s*/) const
25 {
26  // We can't make any checks with a single foot pose
27  return true;
28 }
29 
30 bool UpperBodyGridMapModel::isAccessible(const State& next, const State& current) const
31 {
32  boost::shared_lock<boost::shared_mutex> lock(grid_map_shared_mutex_);
33 
34  if (!occupancy_grid_map_)
35  {
36  ROS_ERROR_THROTTLE(10, "[UpperBodyGridMapModel] No body level grid map available yet.");
37  return true;
38  }
39 
40  if (next.getLeg() == current.getLeg())
41  {
42  ROS_ERROR_THROTTLE(10, "[UpperBodyGridMapModel] Swing foot can't equal support foot.");
43  return false;
44  }
45 
46  const State& left = next.getLeg() == LEFT ? next : current;
47  const State& right = next.getLeg() == RIGHT ? next : current;
48 
49  // approximate upper body dimensions
50  float x = right.getX() + 0.5 * (left.getX() - right.getX());
51  float y = right.getY() + 0.5 * (left.getY() - right.getY());
52 
53  float theta = right.getYaw() + 0.5 * (left.getYaw() - right.getYaw());
54 
55  // determine shift of polygon based on foot orientation
56  float cos_theta = cos(theta);
57  float sin_theta = sin(theta);
58  float shift_x = cos_theta * upper_body_origin_shift.x - sin_theta * upper_body_origin_shift.y;
59  float shift_y = sin_theta * upper_body_origin_shift.x + cos_theta * upper_body_origin_shift.y;
60 
61  // shift pose
62  x += shift_x;
63  y += shift_y;
64 
65  return !collision_check(x, y, cos_theta, sin_theta, upper_body_size.x, upper_body_size.y);
66 }
67 }
68 
69 #include <pluginlib/class_list_macros.h>
70 PLUGINLIB_EXPORT_CLASS(vigir_footstep_planning::UpperBodyGridMapModel, vigir_footstep_planning::CollisionCheckPlugin)
UpperBodyGridMapModel(const std::string &name="upper_body_grid_map_model")
bool collision_check(double x, double y, double cos_theta, double sin_theta, double height, double width) const
Checks if a footstep (represented by its center and orientation) collides with an obstacle...
#define ROS_ERROR_THROTTLE(rate,...)
bool initialize(const vigir_generic_params::ParameterSet &params=vigir_generic_params::ParameterSet()) override


vigir_footstep_planning_default_plugins
Author(s): Alexander Stumpf
autogenerated on Sun Nov 17 2019 03:30:01