ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
1

Segmentation fault while modifying move_base

asked 2015-08-19 18:28:53 -0600

NiranjanDeshpande gravatar image

Hello all,

I am currently trying to modify the move_base a bit such that the plan thread runs continuously and not dependent on the executeCB function of the action server.

However, when I try doing this I get Segmentation error due to accessing the mutex of costmap_2d in the makePlan function.

I have been trying to figure out the issue since a few days now, but have no clue whats going wrong.

I am not an expert programmer and new to threads. SO please pardon me if this query sounds naive.

Waiting for your reply.

Thank you in advance.

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2015-08-20 10:19:08 -0600

Raul Gui gravatar image

updated 2015-08-20 10:22:28 -0600

You are accessing a part of memory that doesn't exist. I change move_base the last week. The code were made to be initialize once, if you try to initialize again without destroy the objects, you will get Segmentation error.

If you don't do that, the problem is the global variables, for example this parameters: runPlanner_=false; state_ = PLANNING; recovery_index_ = 0; recovery_trigger_ = PLANNING_R; you need to be careful with that. Most important, any time you want acess something of the planner_costmap_ros_ or controller_costmap_ros_, you need to do

planner_costmap_ros_->stop();
        controller_costmap_ros_->stop();

or pause (planner_costmap_ros_->pause();) depending what you want and then do planner_costmap_ros_->start(); to free the mutex.

They use the mutex to have threads, and to limit acess to objects that multiple threads try do acess, is like a traffic light, if is red none can acess, if green, a thread can ask acess and if obtain the acess, the traffic light become red, the thread to something, and then free the object, and turn traffic light to green.

When you see boost::unique_lock<boost::mutex> lock(planner_mutex_); and lock.unlock(); is what happening. I don't konw if this coment help you anything, but this was my experience.

Good luck, I lost almost two weeks on move_base. 1 week to understand why the segmentation error, the other doing my code.

edit flag offensive delete link more
0

answered 2015-08-25 11:07:19 -0600

NiranjanDeshpande gravatar image

Hello,

Sorry for a delay reply. And thank you for your answer. It was very helpful. I could get the segmentation error solved. However, I still had one query. What I am doing currently is separating costmaps from move base. So in movebase I use costmaps which are created basically in other node. You mentioned I need to do planner_costmap_ros_->stop() and/or controller_costmap_ros_->stop() before using the costmaps. So even for my requirement I should do this in move_base before using the costmaps?

edit flag offensive delete link more

Comments

Depends, if you have several process to get access of your costmaps my answer is yes. This in move_base is needed, because, when you are refreshing the data of costmap through the laser readings, your move_base could not read that data, or will get a segmentation error.

Raul Gui gravatar image Raul Gui  ( 2015-08-28 12:55:00 -0600 )edit

Two process trying to get the same data at the same time will create conflicts. That's why the mutex. If I helped put a vote on my first answer.

Raul Gui gravatar image Raul Gui  ( 2015-08-28 12:56:37 -0600 )edit

Question Tools

Stats

Asked: 2015-08-19 18:28:53 -0600

Seen: 421 times

Last updated: Aug 25 '15