0
$\begingroup$

Rosanswers logo

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

plugins:
  - {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.


Originally posted by skpro19 on ROS Answers with karma: 310 on 2021-04-10

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

I think it shows the cost of the occupancy grid as a letter, not a number. I think you can solve this problem by casting it as a number.

example

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

cout << (int)global_og[10] << endl; // cast to int

Originally posted by miura with karma: 1908 on 2021-04-10

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by skpro19 on 2021-04-15:
Thank you!

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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