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:
Keep the robot moving straight down said corridor
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.
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$