0
$\begingroup$

Simple task, robot with total knowledge about the world or at least a few side mounted IR sensors which can accurately measure where the robot is relative to a long straight corridor.

We want to BOTH:

  1. Keep the robot moving straight down said corridor

  2. Keep an equal distance from each wall

Noting that the robot is two wheeled or four wheeled. Point being sometimes it will be necessary to not drive straight in order to correct for drift we have accumulated which has pushed us either left or right relative to the virtual center-line we want to stay on.

I'm looking for an approach. Maybe some pseudocode, but even that's not necessary.

Don't say PID, a simple PID controller only accounts for one error term. We have two, the error as an angle between our heading and the desired straight heading and the error as a distance between us and the virtual center-line we'd like to be on at all times.

My previous approach was to attempt to use two PD loops. That didn't work out so well.

$\endgroup$
4
  • 1
    $\begingroup$ Doesn't "keep an equal distance" imply "driving straight"? $\endgroup$
    – FooTheBar
    Commented Oct 17, 2018 at 13:46
  • $\begingroup$ what is your actual question? $\endgroup$
    – jsotola
    Commented Oct 17, 2018 at 20:30
  • $\begingroup$ you need to think clearly about the goal of your project ..... the title of your post has a goal that makes no sense .... stay pointed forward .... the robot is always pointing forward, no matter which direction it is facing ...... of the two goals in the text, the first one is redundant .... all you need is the second one. unless there is some information that you forgot to share $\endgroup$
    – jsotola
    Commented Oct 17, 2018 at 20:35
  • $\begingroup$ How are you measuring your "distance between us and the virtual center-line?" The IR sensors? But aren't they also affected by the robot angle? Sounds like you really only have one error. Why not make a steering PD based on either angle error or distance error (but not both)? $\endgroup$
    – MindS1
    Commented Oct 18, 2018 at 14:12

1 Answer 1

1
$\begingroup$

Implement two low-level PID controllers, one for each wheel. Then compute the targets for both wheels using a path planner which determines next wheel setpoints based on the error computed after reading the IR sensors. If you cannot determine both position and orientation errors using your sensors (you cannot), then keep track of the last few positions to determine actual angle of travel.

I would add a third PID loop for “squashing” the orientation error, but that isn’t required if you can accept some wavering about the centerline of travel.

$\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.