Ask Your Question
1

Access ObstacleLayer Costmap2D in localplanner

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

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 -0600

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

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

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

Seen: 223 times

Last updated: Jan 09 '15