artivis / distance_map

A ROS package for converting OccupancyGrid/Costmap2D to 2D distance map.
Apache License 2.0
60 stars 23 forks source link

Always give zero #4

Open GPrathap opened 3 years ago

GPrathap commented 3 years ago

I want to use this package to estimate free distances to close-in obstacles. However, distance always gives zero, despite distmap seems to be correct in Rviz.

  if(dist_map_ptr_->process(costmap_)){
    auto dist_grid_ptr = dist_map_ptr_->getDistanceFieldObstacle();
    double distance = dist_grid_ptr->atCell(mx, my);
    std::cout<< distance << std::endl;

    auto field_msg = distmap::toMsg(*dist_grid_ptr);
    field_msg.header.stamp = ros::Time::now();
    field_msg.header.frame_id = global_frame_;
    field_obstacles_pub_.publish(field_msg);
  }

Any idea why this happens? I used the following way to initialize the map: dist_map_ptr_ = distmap::make_distance_mapper("distmap/DistanceMapDeadReck")

GPrathap commented 3 years ago

seems to be empty, no wonder why it gives zeros https://github.com/artivis/distance_map/blob/devel/distance_map_deadreck/src/distance_map_deadreck.cpp#L77 any reasons why this was not implemented

artivis commented 3 years ago

Hi,

Indeed that's unfortunate and shouldn't have been pushed. Note that the OpenCV-based plugin is implemented tho. Feel free to implement this function and open a pull request if you like.

GPrathap commented 3 years ago

Hi, Yeah I checked Opencv version works fine, sure I will try after finishing ongoing work, anyway thanks for sharing this