This process has a single task :
The Control Daemon uses PID to calculate the accumulative error and apply the optimal factor to the actuation.
TCO_SHMEM_NAME_PLAN
as raw steering. The Plan Daemon and Control Daemon pair need to be updated to follow the more sophisticated coordinate idea.Read shmem for new desired X {-1,1}.
Push to PID for new value
Throttle/brake is a sigmoid activation function (test-speed!).
$f\left(x\right)\:=1-fabs(\:\left(\frac{1}{1+e^{-sx}}-.5\right)\cdot 2)$
#include <math.h>
/**
* @brief apply sigmoid activation on @p x with curvature defined with @p sense
* @param x input
* @param sense the avg gradient of sigmoid function (factor of x)
* @result A function that follow a sigmoid function
* @note LaTeX : `f\\left(x\\right)\\:=\\:\\left(\\frac{1}{1+e^{-sx}}-.5\\right)\\cdot 2`
*/
float sigmoid_acvitvation(float x, float sense) {
float e = 2.71828; /* Eulers Number */
float denom = 1 + powf(e, (sense * x) * -1); /* Defined in `math.h` stdlib */
return ((1/denom) - 0.5) * 2;
}
/* Proto func */
int steer_algo {
float steer = read_from_shmem; // Proto
float throttle = 1 - fabs(sigmoid_activation(steer, 4.0f));
write_to_shmem(steer, throttle); // Proto
}