I was wondering if anyone had any ideas on what to use the vision sensor for. Right now I have it programmed to detect the flags and align itself with them but it takes to long and over corrects. If anyone has code that makes itline up faster that would be much appreciated.
My code:
while(not linedup) {
Vision.takeSnapshot(SIG_1);
if(Vision.objectCount > 0) {
if(Vision.largestObject.centerX < screen_middle_x -5) {
FLeftMotor.spin(directionType::rev);
LeftMotor.spin(directionType::rev);
FRightMotor.spin(directionType::fwd);
RightMotor.spin(directionType::fwd);
}
else if(Vision.largestObject.centerX > screen_middle_x + 5){
FLeftMotor.spin(directionType::fwd);
LeftMotor.spin(directionType::fwd);
FRightMotor.spin(directionType::rev);
RightMotor.spin(directionType::rev);
}
else {
FLeftMotor.stop(brakeType::brake);
LeftMotor.stop(brakeType::brake);
FRightMotor.stop(brakeType::brake);
RightMotor.stop(brakeType::brake);
}
}