Segmentation fault when trying to access costmap

asked 2021-11-19 02:07:02 -0600

aleena_infinitynbeyond gravatar image

updated 2022-03-25 17:28:27 -0600

lucasw gravatar image

What is this cpp code trying to do? It is subscribing to /move_base/global_costmap/costmap topic and then I am calling the constructor in Line 41 costmap_2d::Costmap2D(msg.info.width, msg.info.height, msg.info.resolution, msg.info.origin.position.x, msg.info.origin.position.y); to initialize the costmap The make plan is generating a path from start node to goal node(both these nodes are now being hard coded) and the path is published to a topic so that I can visualize it on Rviz

Problem: This is my code. https://github.com/Akashleena/RRTSTAR... Check function Line269: bool RRTstarPlannerROS::collision(float wx, float wy) When I comment everything inside this function block I don't get segmentation fault otherwise I am getting segmentation fault. I think the segmentation fault is being cause bY these function call

Line 280 costmap_->getCost(mx, my))
Line 261 float origin_x = costmap_->getOriginX(), origin_y = costmap_->getOriginY();
Line 262   float resolution = costmap_->getResolution();

Can someone suggest a solution?

edit retag flag offensive close merge delete

Comments

Why did you comment: //worldToMap(wx, wy, mx, my); ? - Line 274

osilva gravatar image osilva  ( 2021-11-19 10:43:02 -0600 )edit

This code is very similar to: https://github.com/rafaelbarretorb/rr...

But if you don't update mx, my this may cause the issue later on.

osilva gravatar image osilva  ( 2021-11-19 10:46:18 -0600 )edit

@osilva I commented worldToMap() just to find out whether I am still getting a Segmentation fault even after commenting it and yes I was getting a segfault after commenting

aleena_infinitynbeyond gravatar image aleena_infinitynbeyond  ( 2021-11-19 13:02:01 -0600 )edit

Yup as I said I will be uncommenting those lines and updating mx and my but the thing is when I uncomment I get a segfault, I want to get the costmap values and use those functions costmap_->getCost(mx, my)) Line 261 float origin_x = costmap_->getOriginX(), origin_y = costmap_->getOriginY(); Line 262 float resolution = costmap_->getResolution();

Yes, I have seen that repo https://github.com/rafaelbarretorb/rr... the only difference is this guy has wriiten athe RRT star plugin for the move_base node whereas I want to have a rrt star executable and so I am explicitly subscribing to the costmap and not using the costmap_ros wrapper which is being used when you want to have a global planner as a plugin to move_base.

aleena_infinitynbeyond gravatar image aleena_infinitynbeyond  ( 2021-11-19 13:08:01 -0600 )edit