line_following
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
line_following [2025/02/20 12:39] – [Special Section - Wall Following with PID Control] arim | line_following [2025/02/20 12:44] (current) – [Special Section - Wall Following with PID Control] arim | ||
---|---|---|---|
Line 207: | Line 207: | ||
===== Special Section - Wall Following with PID Control | ===== Special Section - Wall Following with PID Control | ||
- | Code: | + | Code: {{ : |
\\ Video: [[https:// | \\ Video: [[https:// | ||
\\ {{ : | \\ {{ : | ||
Line 246: | Line 246: | ||
\\ Refer to this example for the PID gain values, but adjust them to best suit your Domabot. | \\ Refer to this example for the PID gain values, but adjust them to best suit your Domabot. | ||
+ | //Variable initializations --------------------------------------------------- | ||
+ | xWall = 0; // | ||
+ | dWall = 10; //Desired distance from wall [cm] | ||
+ | wKp = 1.25; //Wall P gain e.g. (PID) = [1.5, 0.005, 30.0] | ||
+ | wKi = 0.001; | ||
+ | wKd = 7.5; //Wall D gain | ||
+ | | ||
+ | // | ||
+ | wE = xWall - dWall; | ||
+ | wEInt +=wE; | ||
+ | wEDot = wE - wEPrev; | ||
+ | wCorr = (wKp * wE) + (wKi * wEInt) + (wKd * wEDot); | ||
+ | | ||
//(1A) Check for motor staturation i.e. resulting wCorr forces | //(1A) Check for motor staturation i.e. resulting wCorr forces | ||
//motor getting > 2*speedBase (if speedBase > 50, this means >100) | //motor getting > 2*speedBase (if speedBase > 50, this means >100) |
line_following.1740083959.txt.gz · Last modified: by arim