-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathLineCalibrator.h
More file actions
80 lines (60 loc) · 2.56 KB
/
Copy pathLineCalibrator.h
File metadata and controls
80 lines (60 loc) · 2.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
/*Written by Jacob Smith for Brandeis Robotics club
Calibrates the zumo robots line sensors
April 4 2018
*/
//set up the LineCalibratorShield header file
#ifndef LineCalibrator_h
#define LineCalibrator_h
//only compile this class i the board is correct
#ifdef ARDUINO_AVR_UNO
//include all the libraries necessary to make this one work
#include <ZumoReflectanceSensorArray.h>
#include <Arduino.h>
#include <Wire.h>
#include<LineShield.h>
#include<Sorter.h>
//the number of regions the robot has
class LineCalibrator : public LineShield {
private:
//the LineReader object that will allow this class to use the line sensors
LineShield lineReader;
////the number of times the robot will take a measrument per region
int NUM_READINGS = 3;
//the number of regions the ring has
int numRegions;
//an array of ring regions
String* regions;
//an array of String regions in the order of their importance
String *regionsPriority;
//an array of the minimum sensor readig for each region
int* regionMins;
//an array of the maximum brightness reading for each region
int* regionMaxes;
//an array to thresholds between the regions
int* regionThresholds;
//the minimum and maximum brightness values globally
int minGlobal;
int maxGlobal;
//reads the line sensors the specified number of times
void takeReadingRegion(String region);
//updates the minimum and maimum bightness readings
//passing the trial number so min an max can be initilized
void updateMinMax(int reading);
//displays the brightness and region arrays to the screen
void displayArrays();
public:
//creates a new LineCalibratorShield object with lineReader object to read sensor data
LineCalibrator(String* regions, int numRegions);
//moves the robot over the series of colors, and determines threshold values
void calibrateLineSensors();
//returns the array of thresholds
int* getThresholds();
//returns the array of regions
String* getRegions();
};
#elif defined (DONT_NEED_LINE)
#warning : May lead to "error: 'LineCalibrator' does not name a type" ; Program to Board Incompatibility ; One of the libraries you are using will not work with your board ; For more information, go to cse230.artifice.cc/lecture/splitting-code.html
#else
#error : Program to Board Incompatibility ; One of the libraries you are using will not work with your board ; Quick fix: add <#define DONT_NEED_LINE> to top ; For more information, go to cse230.artifice.cc/lecture/splitting-code.html
#endif
#endif