Infrared Wrapper

class compLib.IRWrapper.IRWrapper

Wrapper around the IRSensor to enable calibration of the sensor

static adjust_for_calibration(raw_value: float) → float

Adjust a raw sensor value to 0 to 1000

Returns

Value between 0 and 1000, White and Black

Return type

float

static bottom_left_calibrated() → float

Returns calibrated value of the bottom left analog sensor

Returns

Value between 0 and 1000, White and Black

Return type

float

static bottom_middle_calibrated() → float

Returns calibrated value of the bottom middle analog sensor

Returns

Value between 0 and 1000, White and Black

Return type

float

static bottom_right_calibrated() → float

Returns calibrated value of the bottom right analog sensor

Returns

Value between 0 and 1000, White and Black

Return type

float

static calibrate()

Calibrate the black and white values of the IRSensors This is done by putting the bot on black line with the middle sensor Afterwards, all sensors are read for 2 seconds and filtered. The minimum value is used for white, maximum is black.

Examples

Calibrating analog sensors

from compLib import IRWrapper

ir = IRWrapper.IRWrapper()

 ir.calibrate()
 print("left {} middle {} right {}".format(ir.bottom_left_calibrated(), ir.bottom_middle_calibrated(), ir.bottom_right_calibrated()))