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

what is the best way to follow a moving target? [closed]

asked 2012-03-02 02:57:42 -0600

Procópio gravatar image

Hi there!

I am trying to make my robot to follow a moving target, using move_base. However, so far my results are very bad. If I use move_base default global planner, and even if the target moves very little, my robot seems to spend most of the time planning/replanning and pretty much does not move.

I tried to use other global planners as carrot_planner (the robot keeps turning around without following a path) and goal_passer (the robot turns around some times and move_base aborts saying it could not find a path).

Does anyone have any suggestions on how to use move_base to follow a target? The algorithm can be as dumb as it can get, I just need to move along with the target.

Thanks

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Procópio
close date 2016-04-28 10:19:32.073855

3 Answers

Sort by » oldest newest most voted
8

answered 2012-03-06 02:39:27 -0600

DimitriProsser gravatar image

move_base is a state-based controller. It has three states of operation: PLANNING, CONTROLLING, and RECOVERY. The problem that you're going to encounter in your application is that every time the target (the object being tracked) moves, move_base will re-enter the planning state, and it cannot drive in that state. It's unlikely that you'll be able to use move_base for this purpose.

It seems that what you're trying to do is similar to a visual servo. You want to publish motor commands that will keep you a certain distance from your target. It doesn't seem to me like this would require much path-planning. It might be solved using simple motor commands (drive forward, turn left, etc) and using the sensor data as feedback.

edit flag offensive delete link more

Comments

2

@Procópio Silveira Stein If you'd like some sample code to do the kind of visual servoing that @DimitriProsser describes, you might want to check out the TurtleBot follower program. Assuming you have the turtlebot_apps stack installed, just do a 'roscd turtlebot_follower/src' and look at follower.cpp.

Pi Robot gravatar image Pi Robot  ( 2012-03-06 13:19:10 -0600 )edit

thanks for your suggestion @Pi Robot

Procópio gravatar image Procópio  ( 2012-03-06 21:13:12 -0600 )edit
3

answered 2012-03-26 05:41:41 -0600

anonymous user

Anonymous

Hello Procópio!

Hope this late answer can be of some help. We have been confronted to the same issue, and we ended up writing our own local planner.

It is a very simple node subscribing to a moving goal topic. It gets the free space description by subscribing to the local costmap topic. It makes a search of the best (v, w) speed couple within the free space.

An illustration is available here . The somewhat documented CPP code is here .

Hope it can be of any use, Arnaud

edit flag offensive delete link more

Comments

Thanks a lot! I will take a look!

Procópio gravatar image Procópio  ( 2012-03-27 23:20:41 -0600 )edit

@arnaudramey Im really interested in the local planner that you wrote but the link no longer works, could you provide a new link to the CPP code you created. Also, Im curious about what package you used to create a local costmap from a laserscan. Thanks very much!

tgilmour gravatar image tgilmour  ( 2017-06-21 14:02:11 -0600 )edit
1

here is a fork of that repo: https://github.com/awesomebytes/hist_...

Procópio gravatar image Procópio  ( 2017-06-27 02:00:51 -0600 )edit
3

answered 2014-05-24 21:23:52 -0600

Lingzhu Xiang gravatar image

As Dimitri said, move_base uses three states PLANNING, CONTROLLING, and CLEARING. In the planning state, move_base invokes the global planner to get a valid plan, and in the controlling state, it passes the global plan to local planners to actuate controllers.

In my opinion there is no reason why the local planner can't use the last valid global plan to continue local motion while the global planner makes new global plan which is already happening continuously in another thread (controlled by planner_frequency). The mutual exclusion of state seems to be a self-imposed constraint.

I had the same problem, and my solution is this one-line hack in move_base.cpp:

//the move_base state machine, handles the control logic for navigation
switch(state_){
  //if we are in a planning state, then we'll attempt to make a plan
  case PLANNING:
    {
      boost::mutex::scoped_lock lock(planner_mutex_);
      runPlanner_ = true;
      planner_cond_.notify_one();
    }
    ROS_DEBUG_NAMED("move_base","Waiting for plan, in the planning state.");
    break;

  //if we're controlling, we'll attempt to find valid velocity commands
  case CONTROLLING:

Remove break;. This let the switch fall through to controlling when it's nominally in the planning state. In the controlling block, it executes according to the last global plan, which is what you need.

I tested this patch with Navfn and Carrot. This is definitely not an elegant solution. It is probably not even correct on the whole. But it works, and might be a good start to properly patch move_base to make the global and local planner truly work in parallel.

Btw, you can reduce the number of goals you send to move_base by thresholding with distance and time from last goal.

edit flag offensive delete link more

Comments

1

thanks a lot for your input, I will test it right away.

Procópio gravatar image Procópio  ( 2014-05-27 22:06:31 -0600 )edit

hi Procópio, have you already tried this hack? does is work as you needed? we also have similar situation where we would like local-planner to keep executing current plan while the global-planner is calculating the next plan (which can take several seconds in our case).

harmish gravatar image harmish  ( 2015-10-22 05:44:58 -0600 )edit

hi @harmish, sorry but in the end I did not test it.

Procópio gravatar image Procópio  ( 2015-10-23 01:55:48 -0600 )edit

Have you try teb_local_planner ?

TomSon gravatar image TomSon  ( 2016-04-28 07:00:35 -0600 )edit

no, I have not. I believe that when I asked this question there was no teb_local_planner.

Procópio gravatar image Procópio  ( 2016-04-28 10:19:19 -0600 )edit

hi, @Procópio do you have any update on this? have you tried teb_local_lanner? I'm checking which solution is the best. but from my point of view maybe Arnaud's simple local plan node is best for us. thanks!!

lanyaye gravatar image lanyaye  ( 2017-10-20 23:37:24 -0600 )edit

how do i get to move_base.cpp? i dont have it in movebase package and when i get it with apt-get source, i dont know how to put it in movebase directory?

topkek gravatar image topkek  ( 2018-08-26 10:08:56 -0600 )edit

you can download it from github and integrate it into your catkin workspace. Has anyone actually been able to implement it this way? or are there any other packages that allow the robot to follow a moving target, while avoiding obsctacles?

stuggibo gravatar image stuggibo  ( 2019-03-26 06:52:03 -0600 )edit

Question Tools

7 followers

Stats

Asked: 2012-03-02 02:57:42 -0600

Seen: 5,229 times

Last updated: May 24 '14