I am new to PID controller, so I got very confused. I am trying to solve the Cartpole problem. I saw this simple solution for that. I don't understand why that guy used sigmoid to determine which action to take, does the PID controller work on every actuator? (in this case, he used sigmoid, which is so confusing)
1 Answer
does the PID controller work on every actuator?
The short answer to this is yes
.
PID controllers are used to stabilise a plant/system. They are heavily used in different industries, though they can be a bit costly to implement sometimes. Drone Industry (UAV / drones) is one of them. PID controllers would help them to stabilize and auto-hold (or altitude-hold some might say).
why that guy used sigmoid to determine which action to take
Now to answer this question we have to look into the code posted in the GitHub link. Let's look into the code snippets from HenryJia's repository.
def sigmoid(x):
return 1.0 / (1.0 + np.exp(-x))
and,
pid = np.dot(P * error + I * integral + D * derivative, desired_mask)
action = sigmoid(pid)
In these snippets, he/she/they used the sigmoid function to limit the coefficients of the PID controller within the predefined range of the sigmoid function.
This would help them to keep the PID coefficients within the stable range so that it doesn't get too high or too low to reach the verge of instability.
-
2$\begingroup$ I think it's wrong to say that every conceivable actuator can profitably use a PID controller. Certainly any actuator that has a reasonably linear input/output relationship can (with pretty broad limits on "reasonable"), but I think there are more things in heaven and earth than are dream't of in your philosophy. A quick counter-example is a latching relay with separate set and reset inputs -- a simple SISO PID controller isn't going to "know" what to do with such a relay. $\endgroup$ Sep 18, 2022 at 22:09
-
$\begingroup$ Yes, true and that is the reason so many other types of controllers were made for specific applications. And even those controllers might not work well out of their specific genre... PID is a more generic one that suits almost all actuators. $\endgroup$ Sep 19, 2022 at 6:01
-
$\begingroup$ @WittyDimension I think code that I linked is trying to squash range of pid controller error from 0 to 1. I am new to PID, so I currently think that PID gives 'right' error so that actuator can control, it's not controller computes error. $\endgroup$ Sep 20, 2022 at 20:19
-
$\begingroup$ @datonefaridze - In a broader sense, the controller takes the error as input and compares it with the actual input signal that the actuator needs to follow ( or track ) and then tries to reduce it accordingly. $\endgroup$ Sep 21, 2022 at 7:46