Hacker News new | ask | show | jobs
by Cyph0n 3429 days ago
As u/gumby said, I was thinking of a PID controller. Basically, the car would continuously measure how far away it is from the line and compare that with the "expected" (computed) value. Based on the error between the two values, the controller would adjust some variable (e.g., wheel angle).

Computing how much of an adjustment is required is where the PID part comes in. The controller uses the Derivative (rate of change) of the error as well the the Integral of the error to improve its estimate. These two values can intuitively be thought of as the predicted error and history of the error, respectively.

[1]: https://www.wikiwand.com/en/PID_controller

5 comments

I think it's important to ponder that a PID controller is , in almost every case it is used, a heuristic controller which achieves pretty mediocre performance. Unless the plant is second-order linear system, with constant gains, and maybe some non-constant biasing (what the I term is supposed to handle), a PID controller is theoretically inappropriate, and requires tuning.

The handful of parameters you need to adjust in a PID controller parameterizes a very small class of controllers. For a given control problem, the controller you want might fall outside that class. People try to expand the class of "PID" controllers in all sorts of ways (e.g. anti-windup), but from where I stand it's just hacks on top of hacks.

It makes sense to consider a much wider class of controllers, with many more parameters, to possibly achieve better performance, or at least to avoid having an expert tune some gains in place of collecting bucket-loads of data.

As someone who's tried to control a car with PID, there is more to it than that. The angle of the car relative to the lines and the distance from the line need to be taken into account separately, since they each independently contribute to the distance from the lines as you move forward, and the PID controller can't separate them by itself. Think of how hard it is to keep straight in heavy fog when you can only see a few feet in front of the car, and you'll get the idea.

The delay in your steering response (how fast you can measure the error and turn the wheel) is large enough here that if you aren't actively taking the non-linearities of the problem into account you will oscillate off the road. The other way to fix this is to aim for a point far ahead of you such that your steering response time is significantly less than your "following distance", but that results in cutting corners.

Cool. I'd never heard of a PID controller... although it sounds vaguely related to a Kalman filter. Indeed: https://www.quora.com/Is-there-any-intrinsic-connection-betw...

Thanks also for the link to wikiwand!

Huh, I'll need to read up on Kalman filters then!

Yeah, Wikiwand is amazing. Be sure to grab the browser plugin: it automatically redirects any Wikipedia links to Wikiwand.

This is part of the reason I love HN.. I just spent my lunch learning about PID controllers! Thank you!
For context, a hardware PID controller is a commodity part you can buy for a couple of dollars.