

#include "Dragster.h"
#include "Octoliner.h"
#include "PID_dragster.h"
 
Dragster robot(MMAX_16_OHM);
Octoliner octoliner;
 
int lineData[8];
 
float speed = 0.55;
float KP = 0.5;
float KD = 0.5;
float KI = 0.0;
 
double output;
PID regulator(&output, KP, KI, KD);
 
void setup() {
  robot.begin();
  octoliner.begin();
  octoliner.setSensitivity(208);
}
 
void loop() {
  for (int i = 0; i < 8; i++) {
    lineData[i] = octoliner.analogRead(i);
  }
  double error = octoliner.mapLine(lineData);
  regulator.compute(error);
  robot.driveF(speed * (1 - output), speed * (1 + output));
}
