Here's how my code looks -

costmap_2d::Costmap2DROS *global_costmap = new costmap_2d::Costmap2DROS("global_costmap", buffer);

I have specified the following params in my configuration file -

global_frame: odom
rolling_window: true
track_unknown_space: true

  - {name: obstacles_laser,           type: "costmap_2d::ObstacleLayer"}
  - {name: inflation,                 type: "costmap_2d::InflationLayer"}

I am able to publish the occupancy grid using the terminal by running rostopic echo -n1 /global_costmap/costmap.

However, when I add the following line to my code -

unsigned char* global_og = global_costmap->getCostmap()->getCharMap() ; 

cout << global_og[10] << endl; 

I see some strange characters being published.


I could resolve the issue by using cout << (int)global_og[10] << endl;

I needed to cast the unsigned char to int.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.