Local costmap's OccupancyGrid doesn't update origin [closed]
Hi,
I'm using ROS Indigo on Ubuntu 14.04
I am in the process of writing an autonomous drive algorithm for my Turtlebot, and I've written a function that is meant to search the local costmap for a safe goal to send to the actionclient for move_base.
So, in my function, I call a function that picks up the most recent OccupancyGrid published to move_base/local_costmap/costmap
. I then copy the callback to a global variable called "localgrid", which my function examines for obstacles.
void localmapcallback(const nav_msgs::OccupancyGrid::ConstPtr& msg)
{
localgrid.info = msg->info;
localgrid.header = msg->header;
localgrid.data = msg->data;
gotmap = true;
ROS_INFO("Got a local map! Origin is %f,%f", msg->info.origin.position.x,msg->info.origin.position.y);
}
// ^ localmapcallback
What I've noticed, however, is that, no matter where I am in the global map, the origin on the occupancy grid never changes!
Move_base is being launched from the default AMCL demo launch, so I can see that the local costmap is configured properly, i.e., rolling_window
is set true
. The local costmap also looks fine in RViz.
Also, in my program, I have my own self-updating global Costmap 2DROS named localmap_
localmap_ = new costmap_2d::Costmap2DROS(std::string("newlocal_costmap"), tf_);
So what I have done, is add a lot of debug statements in my "safe goal" function. I compare the difference between the origin of the OccupancyGrid ("localgrid") and the Costmap2DROS ("localmap_") after running the above callback:
ROS_INFO("Looking for a safe goal. The local OG origin is %f,%f",localgrid.info.origin.position.x,localgrid.info.origin.position.y);
costmap_2d::Costmap2D* mymap = localmap_->getCostmap();
boost::unique_lock< boost::recursive_mutex> lock(*(localmap_->getCostmap()->getMutex()));
ROS_INFO("Looking for a safe goal. The local costmap origin is %f,%f",mymap->getOriginX(),mymap->getOriginY());
boost::unique_lock< boost::recursive_mutex> unlock(*(mymap->getMutex()));
And this is what I get when I run the code while the robot is far from its starting point:
(Apologies for the photo instead of pasted text -- I can't figure out how to copy output from GDB. Also, apologies for my coding conventions. They're sloppy and I need to fix them eventually)
So, why doesn't the OccupancyGrid have a meaningful origin like the local Costmap2DROS does?
My code is quite long, so that is why I've refrained from posting everything here, but please do let me know if I need to put anything else here.
Thanks!