join_costmap.cpp
Go to the documentation of this file.
1 
19 #include <ros/ros.h>
20 
22 
23 namespace ftc_local_planner
24 {
26  {
27  }
28 
29  void JoinCostmap::initialize(costmap_2d::Costmap2DROS* local_costmap_ros, costmap_2d::Costmap2DROS* global_costmap_ros){
30  local_costmap_ros_ = local_costmap_ros;
31  global_costmap_ros_ = global_costmap_ros;
32 
33  if(local_costmap_ros_->getCostmap()->getResolution() < global_costmap_ros->getCostmap()->getResolution()){
34  ROS_ERROR("JoinCostmap: Resolution of local costmap is higher than global costmap resolution!");
35  init = false;
36  }
37  //Init vector global to right size
39  for (unsigned int i = 0; i < global_costmap_ros_->getCostmap()->getSizeInCellsX(); ++i){
41  }
42 
43  //Push global costmap in global vector
44  for(unsigned int i = 0; i < global_costmap_ros_->getCostmap()->getSizeInCellsX(); i++){
45  for(unsigned int j = 0; j < global_costmap_ros_->getCostmap()->getSizeInCellsY(); j++){
47  }
48  }
49  ROS_INFO("JoinCostmap: Initalize.");
50  init = true;
51  }
52 
54  if(!init){
55  ROS_WARN("JoinCostmap: Dont join costmap, because init faild.");
56  }else{
57  for(unsigned int i = 0; i < global_costmap_ros_->getCostmap()->getSizeInCellsX(); i++){
58  for(unsigned int j = 0; j < global_costmap_ros_->getCostmap()->getSizeInCellsY(); j++){
59  double wx = 0;
60  double wy = 0;
61  global_costmap_ros_->getCostmap()->mapToWorld(i,j, wx, wy);
62 
63  unsigned int mx = 0;
64  unsigned int my = 0;
65  local_costmap_ros_->getCostmap()->worldToMap(wx, wy, mx, my);
66 
67  //Copy the highest cost from global vector or local costmap in the global costmap
68  if(global[i][j] < local_costmap_ros_->getCostmap()->getCost(mx, my)){
70  }else{
72  }
73  }
74  }
75  }
76  }
77 
78 }
void setCost(unsigned int mx, unsigned int my, unsigned char cost)
void mapToWorld(unsigned int mx, unsigned int my, double &wx, double &wy) const
void joinMaps()
joinMaps join the local costmap in the global costmap.
costmap_2d::Costmap2DROS * local_costmap_ros_
Definition: join_costmap.h:54
#define ROS_WARN(...)
void initialize(costmap_2d::Costmap2DROS *local_costmap_ros, costmap_2d::Costmap2DROS *global_costmap_ros)
initialize the two costmaps and check if resolution global costmap > resolution local costmap...
unsigned char getCost(unsigned int mx, unsigned int my) const
#define ROS_INFO(...)
JoinCostmap()
JoinCostmap constructor.
costmap_2d::Costmap2DROS * global_costmap_ros_
Definition: join_costmap.h:53
unsigned int getSizeInCellsY() const
vector< vector< int > > global
Definition: join_costmap.h:57
unsigned int getSizeInCellsX() const
double getResolution() const
Costmap2D * getCostmap()
#define ROS_ERROR(...)
bool worldToMap(double wx, double wy, unsigned int &mx, unsigned int &my) const


asr_ftc_local_planner
Author(s): Marek Felix
autogenerated on Mon Jun 17 2019 19:56:22