ColorSensorV3
- class rev.ColorSensorV3(port: wpilib._wpilib.I2C.Port)
Bases:
pybind11_object
REV Robotics Color Sensor V3.
This class allows access to a REV Robotics color sensor V3 on an I2C bus.
Constructs a ColorSensorV3.
Note that the REV Color Sensor is really two devices in one package: a color sensor providing red, green, blue and IR values, and a proximity sensor.
- Parameters:
port – The I2C port the color sensor is attached to
- class ColorMeasurementRate(value: int)
Bases:
pybind11_object
Members:
k25ms
k50ms
k100ms
k200ms
k500ms
k1000ms
k2000ms
- k1000ms = <ColorMeasurementRate.k1000ms: 5>
- k100ms = <ColorMeasurementRate.k100ms: 2>
- k2000ms = <ColorMeasurementRate.k2000ms: 7>
- k200ms = <ColorMeasurementRate.k200ms: 3>
- k25ms = <ColorMeasurementRate.k25ms: 0>
- k500ms = <ColorMeasurementRate.k500ms: 4>
- k50ms = <ColorMeasurementRate.k50ms: 1>
- property name
- property value
- class ColorResolution(value: int)
Bases:
pybind11_object
Members:
k20bit
k19bit
k18bit
k17bit
k16bit
k13bit
- k13bit = <ColorResolution.k13bit: 80>
- k16bit = <ColorResolution.k16bit: 64>
- k17bit = <ColorResolution.k17bit: 48>
- k18bit = <ColorResolution.k18bit: 32>
- k19bit = <ColorResolution.k19bit: 16>
- k20bit = <ColorResolution.k20bit: 0>
- property name
- property value
- class GainFactor(value: int)
Bases:
pybind11_object
Members:
k1x
k3x
k6x
k9x
k18x
- k18x = <GainFactor.k18x: 4>
- k1x = <GainFactor.k1x: 0>
- k3x = <GainFactor.k3x: 1>
- k6x = <GainFactor.k6x: 2>
- k9x = <GainFactor.k9x: 3>
- property name
- property value
- class LEDCurrent(value: int)
Bases:
pybind11_object
Members:
kPulse2mA
kPulse5mA
kPulse10mA
kPulse25mA
kPulse50mA
kPulse75mA
kPulse100mA
kPulse125mA
- kPulse100mA = <LEDCurrent.kPulse100mA: 6>
- kPulse10mA = <LEDCurrent.kPulse10mA: 2>
- kPulse125mA = <LEDCurrent.kPulse125mA: 7>
- kPulse25mA = <LEDCurrent.kPulse25mA: 3>
- kPulse2mA = <LEDCurrent.kPulse2mA: 0>
- kPulse50mA = <LEDCurrent.kPulse50mA: 4>
- kPulse5mA = <LEDCurrent.kPulse5mA: 1>
- kPulse75mA = <LEDCurrent.kPulse75mA: 5>
- property name
- property value
- class LEDPulseFrequency(value: int)
Bases:
pybind11_object
Members:
k60kHz
k70kHz
k80kHz
k90kHz
k100kHz
- k100kHz = <LEDPulseFrequency.k100kHz: 56>
- k60kHz = <LEDPulseFrequency.k60kHz: 24>
- k70kHz = <LEDPulseFrequency.k70kHz: 64>
- k80kHz = <LEDPulseFrequency.k80kHz: 40>
- k90kHz = <LEDPulseFrequency.k90kHz: 48>
- property name
- property value
- class ProximityMeasurementRate(value: int)
Bases:
pybind11_object
Members:
k6ms
k12ms
k25ms
k50ms
k100ms
k200ms
k400ms
- k100ms = <ProximityMeasurementRate.k100ms: 5>
- k12ms = <ProximityMeasurementRate.k12ms: 2>
- k200ms = <ProximityMeasurementRate.k200ms: 6>
- k25ms = <ProximityMeasurementRate.k25ms: 3>
- k400ms = <ProximityMeasurementRate.k400ms: 7>
- k50ms = <ProximityMeasurementRate.k50ms: 4>
- k6ms = <ProximityMeasurementRate.k6ms: 1>
- property name
- property value
- class ProximityResolution(value: int)
Bases:
pybind11_object
Members:
k8bit
k9bit
k10bit
k11bit
- k10bit = <ProximityResolution.k10bit: 16>
- k11bit = <ProximityResolution.k11bit: 24>
- k8bit = <ProximityResolution.k8bit: 0>
- k9bit = <ProximityResolution.k9bit: 8>
- property name
- property value
- class RawColor(r: int, g: int, b: int, _ir: int)
Bases:
pybind11_object
- property blue
- property green
- property ir
- property red
- configureColorSensor(res: rev._rev.ColorSensorV3.ColorResolution, rate: rev._rev.ColorSensorV3.ColorMeasurementRate) None
Configure the color sensor.
These settings are only needed for advanced users, the defaults will work fine for most teams. Consult the APDS-9151 for more information on these configuration settings and how they will affect color sensor measurements.
- Parameters:
res – Bit resolution output by the respective light sensor ADCs
rate – Measurement rate of the light sensor
- configureProximitySensor(res: rev._rev.ColorSensorV3.ProximityResolution, rate: rev._rev.ColorSensorV3.ProximityMeasurementRate) None
Configure the proximity sensor.
These settings are only needed for advanced users, the defaults will work fine for most teams. Consult the APDS-9151 for more information on these configuration settings and how they will affect proximity sensor measurements.
- Parameters:
res – Bit resolution output by the proximity sensor ADC.
rate – Measurement rate of the proximity sensor
- configureProximitySensorLED(freq: rev._rev.ColorSensorV3.LEDPulseFrequency, current: rev._rev.ColorSensorV3.LEDCurrent, pulses: int) None
Configure the the IR LED used by the proximity sensor.
These settings are only needed for advanced users, the defaults will work fine for most teams. Consult the APDS-9151 for more information on these configuration settings and how they will affect proximity sensor measurements.
- Parameters:
freq – The pulse modulation frequency for the proximity sensor LED
curr – The pulse current for the proximity sensor LED
pulses – The number of pulses per measurement of the proximity sensor LED
- getCIEColor() rev._rev.CIEColor
Get the color converted to CIE XYZ color space using factory calibrated constants.
https://en.wikipedia.org/wiki/CIE_1931_color_space
- Returns:
CIEColor value from sensor
- getColor() wpilib._wpilib.Color
Get the normalized RGB color from the sensor (normalized based on total R + G + B)
- Returns:
frc::Color class with normalized sRGB values
- getIR() float
Get the normalzied IR value from the sensor. Works best when within 2 inches and perpendicular to surface of interest.
- Returns:
Color class with normalized values
- getProximity() int
Get the raw proximity value from the sensor ADC. This value is largest when an object is close to the sensor and smallest when far away.
- Returns:
Proximity measurement value, ranging from 0 to 2047 in default configuration
- getRawColor() rev._rev.ColorSensorV3.RawColor
Get the raw color value from the sensor.
- Returns:
Raw color values from sensopr
- hasReset() bool
Indicates if the device reset. Based on the power on status flag in the status register. Per the datasheet:
Part went through a power-up event, either because the part was turned on or because there was power supply voltage disturbance (default at first register read).
This flag is self clearing
- Returns:
true if the device was reset
- isConnected() bool
Indicates if the device can currently be communicated with.
- Returns:
true if the device is currently connected and responsive
- setGain(gain: rev._rev.ColorSensorV3.GainFactor) None
Set the gain factor applied to color ADC measurements.
By default, the gain is set to 3x.
- Parameters:
gain – Gain factor applied to color ADC measurements measurements