Skip to content
This repository has been archived by the owner on Jul 31, 2022. It is now read-only.

Commit

Permalink
Removed debug, and tank spin, updated comments
Browse files Browse the repository at this point in the history
Ive added a lot more comments, so ill re-release the Headerfiles
  • Loading branch information
KenwoodFox committed Oct 30, 2018
1 parent 61d8795 commit c3cb9ca
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 57 deletions.
27 changes: 0 additions & 27 deletions Joe/Tumbler Bot/TumbleBot Line Follower Basic/debug.c

This file was deleted.

17 changes: 13 additions & 4 deletions Joe/Tumbler Bot/TumbleBot Line Follower Basic/lineFollowing.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,30 @@ void findLine()
halt(); //stop motors
}

void linePID(int speed) //serious maths
void linePID(int speed, char statusLight) //serious maths
{
float Kp = 0.005; //proportional
//float Ki = 0.05; //integral
//float Kd = 0.05; //derivative

float error = SensorValue[starboardReflector] - SensorValue[portReflector];
// In a PID loop, the goal is to aproach the target, but not overshoot it, a good PID loop can swoosh right to the target, while many others simply just, rush past it and come back right after, this mathamtical form of position control has been around since the first basic electronic navigation systems
/* In a PID loop, the goal is to aproach the target, but not overshoot it, a good PID loop can swoosh right to the target,
* while many others simply just, rush past it and come back right after, this mathamtical form of position control has been
* around since the first basic electronic navigation systems
*/

if((abs(error)) <= 10) //deadzone
if((abs(error)) <= 100) //While the absolute value of the error (pos || neg) is less than the deadzone, do nothing, just drive ahead
{
//nothing
SensorValue[statusLight] = true; //Turn on the LED while tracking center
portDriveTrain(speed); //drive at speed
starboardDriveTrain(speed); //drive at speed
/* It is well understood that the motors very often do not drive at the same rate, so its likely we'll wobble or hug one side of
* line, this is not all that bad tbh
*/
}
else
{
SensorValue[statusLight] = false;
portDriveTrain(speed + (Kp * error)); //Subtract or add to the value speed, the error multplied by its weight (Kp)
starboardDriveTrain(speed + (Kp * (error * -1))); //Subtract or add to the value speed, the error multplied by its weight (Kp)
}
Expand Down
6 changes: 4 additions & 2 deletions Joe/Tumbler Bot/TumbleBot Line Follower Basic/source.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,16 @@

task main()
{
int threshold = 800; //The value at witch we can differ a black line from a white table, we could make this a self calibrating value!!

while(true)
{
startup(bumpSwitch, LED);
findLine(); //our first task is to find where the line is, duh, so we can follow it!

while(true)
while(SensorValue[masterReflector] >= threshold)
{
linePID(20); //call the PID loop with a speed of 20
linePID(20, LED); //call the PID loop with a speed of 20
}
}
}
24 changes: 0 additions & 24 deletions Joe/Tumbler Bot/TumbleBot Line Follower Basic/tankSpin.h

This file was deleted.

0 comments on commit c3cb9ca

Please sign in to comment.