|
ME 405 Romi
|
Line_Sensor class which will calibrate the sensors, read data from the entire line, and find the centroid of the darkest spot. More...
Public Member Functions | |
| __init__ (self, ir1, ir2, ir3, ir4, ir5, ir6, ir7, ir8, ir9, ir10, ir11, ir12, ir13) | |
| init is the Line_Sensor object initializer which takes 13 arguments. | |
| check_Calibrate (self) | |
| check_Calibrate returns the status of the calibration variable. | |
| calibrate (self) | |
| calibrate will try to read the calibration text IR_cal.txt and return whether or not the file exists. | |
| getCentroid (self) | |
| getCentroid will return the value of the centroid of the darkest spot the sensors can see along the length of the line. | |
| readSensors (self) | |
| readSensors will read every ir sensor with a time multi read and then normalize with the calibration data. | |
| read_Calibrate_Data (self) | |
| readSensors will read every ir sensor with a time multi read but will return the raw unnormalized data to be saved as calibration data. | |
| check_Line (self) | |
| check_Line is a debugging function to check that the line sensor is correctly setup with all the sensors. | |
| check_Indv (self, which_sensor) | |
| check_Indv is a debugging function to look at the data from a single IR sensor if you think it is reading poorly. | |
Public Attributes | |
| ir1 = ir1 | |
| ir2 = ir2 | |
| ir3 = ir3 | |
| ir4 = ir4 | |
| ir5 = ir5 | |
| ir6 = ir6 | |
| ir7 = ir7 | |
| ir8 = ir8 | |
| ir9 = ir9 | |
| ir10 = ir10 | |
| ir11 = ir11 | |
| ir12 = ir12 | |
| ir13 = ir13 | |
| tim = Timer(6, freq = 20000) | |
| bool | calibrated = False |
| buf1 = array.array('H', (0 for i in range(DATA_AMT))) | |
| buf2 = array.array('H', (0 for i in range(DATA_AMT))) | |
| buf3 = array.array('H', (0 for i in range(DATA_AMT))) | |
| buf4 = array.array('H', (0 for i in range(DATA_AMT))) | |
| buf5 = array.array('H', (0 for i in range(DATA_AMT))) | |
| buf6 = array.array('H', (0 for i in range(DATA_AMT))) | |
| buf7 = array.array('H', (0 for i in range(DATA_AMT))) | |
| buf8 = array.array('H', (0 for i in range(DATA_AMT))) | |
| buf9 = array.array('H', (0 for i in range(DATA_AMT))) | |
| buf10 = array.array('H', (0 for i in range(DATA_AMT))) | |
| buf11 = array.array('H', (0 for i in range(DATA_AMT))) | |
| buf12 = array.array('H', (0 for i in range(DATA_AMT))) | |
| buf13 = array.array('H', (0 for i in range(DATA_AMT))) | |
| list | ir_array = [self.ir1, self.ir2, self.ir3, self.ir4, self.ir5, self.ir6, self.ir7, self.ir8, self.ir9, self.ir10, self.ir11, self.ir12, self.ir13] |
| list | ir_adc_array = [self.ir1.adc, self.ir2.adc, self.ir3.adc, self.ir4.adc, self.ir5.adc, self.ir6.adc, self.ir7.adc, self.ir8.adc, self.ir9.adc, self.ir10.adc, self.ir11.adc, self.ir12.adc, self.ir13.adc] |
| list | data_buffer = [self.buf1, self.buf2, self.buf3,self.buf4,self.buf5,self.buf6,self.buf7,self.buf8,self.buf9,self.buf10,self.buf11,self.buf12,self.buf13 ] |
| list | data_avg = [0]*13 |
| list | act_data = [0.0]*13 |
| list | sens_dist = [0, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, 0] * PITCH |
| list | black = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] |
| list | white = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] |
Line_Sensor class which will calibrate the sensors, read data from the entire line, and find the centroid of the darkest spot.
Definition at line 27 of file line_sensor.py.
| line_sensor.Line_Sensor.__init__ | ( | self, | |
| ir1, | |||
| ir2, | |||
| ir3, | |||
| ir4, | |||
| ir5, | |||
| ir6, | |||
| ir7, | |||
| ir8, | |||
| ir9, | |||
| ir10, | |||
| ir11, | |||
| ir12, | |||
| ir13 ) |
init is the Line_Sensor object initializer which takes 13 arguments.
The arguments the 13 IR sensor objects.
| irX | : irX is IR sensor object X on the physical line. Must be passed in order they appear on sensor. |
Definition at line 33 of file line_sensor.py.
| line_sensor.Line_Sensor.calibrate | ( | self | ) |
calibrate will try to read the calibration text IR_cal.txt and return whether or not the file exists.
It will set the calibration status variable.
Attempts to open a file name IR_cal.txt. If it can't find it, it will return False. When it does find it, it assumes the file is a file with calibration constants of the form "BLACK_CALIBRATION_VAL,WHITE_CALIBRATION_VAL". Each row should be one IR sensor's data in the order of the ir sensors as passed to the class init.
Definition at line 91 of file line_sensor.py.
| line_sensor.Line_Sensor.check_Calibrate | ( | self | ) |
check_Calibrate returns the status of the calibration variable.
True is sensor is calibrated.
Definition at line 85 of file line_sensor.py.
| line_sensor.Line_Sensor.check_Indv | ( | self, | |
| which_sensor ) |
check_Indv is a debugging function to look at the data from a single IR sensor if you think it is reading poorly.
Definition at line 168 of file line_sensor.py.
| line_sensor.Line_Sensor.check_Line | ( | self | ) |
check_Line is a debugging function to check that the line sensor is correctly setup with all the sensors.
Definition at line 159 of file line_sensor.py.

| line_sensor.Line_Sensor.getCentroid | ( | self | ) |
getCentroid will return the value of the centroid of the darkest spot the sensors can see along the length of the line.
This will read the latest data saved and do a basic centroid calculation on it. Right now it divides by idx-2 because 2 sensors are turned off.
Definition at line 116 of file line_sensor.py.

| line_sensor.Line_Sensor.read_Calibrate_Data | ( | self | ) |
readSensors will read every ir sensor with a time multi read but will return the raw unnormalized data to be saved as calibration data.
It will save this and return it.
Definition at line 146 of file line_sensor.py.
| line_sensor.Line_Sensor.readSensors | ( | self | ) |
readSensors will read every ir sensor with a time multi read and then normalize with the calibration data.
It will save that data in the class and return it.
Definition at line 128 of file line_sensor.py.

| list line_sensor.Line_Sensor.act_data = [0.0]*13 |
Definition at line 74 of file line_sensor.py.
| list line_sensor.Line_Sensor.black = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] |
Definition at line 80 of file line_sensor.py.
| line_sensor.Line_Sensor.buf1 = array.array('H', (0 for i in range(DATA_AMT))) |
Definition at line 53 of file line_sensor.py.
| line_sensor.Line_Sensor.buf10 = array.array('H', (0 for i in range(DATA_AMT))) |
Definition at line 62 of file line_sensor.py.
| line_sensor.Line_Sensor.buf11 = array.array('H', (0 for i in range(DATA_AMT))) |
Definition at line 63 of file line_sensor.py.
| line_sensor.Line_Sensor.buf12 = array.array('H', (0 for i in range(DATA_AMT))) |
Definition at line 64 of file line_sensor.py.
| line_sensor.Line_Sensor.buf13 = array.array('H', (0 for i in range(DATA_AMT))) |
Definition at line 65 of file line_sensor.py.
| line_sensor.Line_Sensor.buf2 = array.array('H', (0 for i in range(DATA_AMT))) |
Definition at line 54 of file line_sensor.py.
| line_sensor.Line_Sensor.buf3 = array.array('H', (0 for i in range(DATA_AMT))) |
Definition at line 55 of file line_sensor.py.
| line_sensor.Line_Sensor.buf4 = array.array('H', (0 for i in range(DATA_AMT))) |
Definition at line 56 of file line_sensor.py.
| line_sensor.Line_Sensor.buf5 = array.array('H', (0 for i in range(DATA_AMT))) |
Definition at line 57 of file line_sensor.py.
| line_sensor.Line_Sensor.buf6 = array.array('H', (0 for i in range(DATA_AMT))) |
Definition at line 58 of file line_sensor.py.
| line_sensor.Line_Sensor.buf7 = array.array('H', (0 for i in range(DATA_AMT))) |
Definition at line 59 of file line_sensor.py.
| line_sensor.Line_Sensor.buf8 = array.array('H', (0 for i in range(DATA_AMT))) |
Definition at line 60 of file line_sensor.py.
| line_sensor.Line_Sensor.buf9 = array.array('H', (0 for i in range(DATA_AMT))) |
Definition at line 61 of file line_sensor.py.
| bool line_sensor.Line_Sensor.calibrated = False |
Definition at line 50 of file line_sensor.py.
| list line_sensor.Line_Sensor.data_avg = [0]*13 |
Definition at line 71 of file line_sensor.py.
| line_sensor.Line_Sensor.data_buffer = [self.buf1, self.buf2, self.buf3,self.buf4,self.buf5,self.buf6,self.buf7,self.buf8,self.buf9,self.buf10,self.buf11,self.buf12,self.buf13 ] |
Definition at line 70 of file line_sensor.py.
| line_sensor.Line_Sensor.ir1 = ir1 |
Definition at line 34 of file line_sensor.py.
| line_sensor.Line_Sensor.ir10 = ir10 |
Definition at line 43 of file line_sensor.py.
| line_sensor.Line_Sensor.ir11 = ir11 |
Definition at line 44 of file line_sensor.py.
| line_sensor.Line_Sensor.ir12 = ir12 |
Definition at line 45 of file line_sensor.py.
| line_sensor.Line_Sensor.ir13 = ir13 |
Definition at line 46 of file line_sensor.py.
| line_sensor.Line_Sensor.ir2 = ir2 |
Definition at line 35 of file line_sensor.py.
| line_sensor.Line_Sensor.ir3 = ir3 |
Definition at line 36 of file line_sensor.py.
| line_sensor.Line_Sensor.ir4 = ir4 |
Definition at line 37 of file line_sensor.py.
| line_sensor.Line_Sensor.ir5 = ir5 |
Definition at line 38 of file line_sensor.py.
| line_sensor.Line_Sensor.ir6 = ir6 |
Definition at line 39 of file line_sensor.py.
| line_sensor.Line_Sensor.ir7 = ir7 |
Definition at line 40 of file line_sensor.py.
| line_sensor.Line_Sensor.ir8 = ir8 |
Definition at line 41 of file line_sensor.py.
| line_sensor.Line_Sensor.ir9 = ir9 |
Definition at line 42 of file line_sensor.py.
| line_sensor.Line_Sensor.ir_adc_array = [self.ir1.adc, self.ir2.adc, self.ir3.adc, self.ir4.adc, self.ir5.adc, self.ir6.adc, self.ir7.adc, self.ir8.adc, self.ir9.adc, self.ir10.adc, self.ir11.adc, self.ir12.adc, self.ir13.adc] |
Definition at line 69 of file line_sensor.py.
| list line_sensor.Line_Sensor.ir_array = [self.ir1, self.ir2, self.ir3, self.ir4, self.ir5, self.ir6, self.ir7, self.ir8, self.ir9, self.ir10, self.ir11, self.ir12, self.ir13] |
Definition at line 68 of file line_sensor.py.
| list line_sensor.Line_Sensor.sens_dist = [0, 5, 4, 3, 2, 1, 0, -1, -2, -3, -4, -5, 0] * PITCH |
Definition at line 77 of file line_sensor.py.
| line_sensor.Line_Sensor.tim = Timer(6, freq = 20000) |
Definition at line 48 of file line_sensor.py.
| list line_sensor.Line_Sensor.white = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0] |
Definition at line 81 of file line_sensor.py.