ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Access ObstacleLayer Costmap2D in localplanner

asked 2015-01-08 23:17:54 -0500

aswin gravatar image

Hi,

Is there a way I can access Costmap2D of a layer in the local planner? I saw this question here, but I couldnt get it to work. The only way I can access the costmap is though layered_costmap_, but it is protected.

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2015-01-09 00:20:56 -0500

aswin gravatar image

I got confused with the CostmapLayer doxygen docs here which doesnt show inheritance from Costmap2D

std::vector<boost::shared_ptr<costmap_2d::Layer> >* plugins = costmap_ros_->getLayeredCostmap()->getPlugins();

for (std::vector<boost::shared_ptr<costmap_2d::Layer> >::iterator pluginp = plugins->begin(); pluginp != plugins->end(); ++pluginp) {

boost::shared_ptr<costmap_2d::Layer> plugin = *pluginp;

if(plugin->getName().find(layer_search_string_)!=std::string::npos) {
    boost::shared_ptr<costmap_2d::CostmapLayer> costmap;
    costmap = boost::static_pointer_cast<costmap_2d::CostmapLayer>(plugin);
    unsigned char* grid = costmap->getCharMap();

    // do sth with it

}

}

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-01-08 23:17:54 -0500

Seen: 415 times

Last updated: Jan 09 '15