ReduxLib C++ 2024.1.1-beta0
Loading...
Searching...
No Matches
redux::sensors::canandcolor Namespace Reference

Namespaces

namespace  details
 
namespace  digout
 

Classes

class  Canandcolor
 
class  CanandcolorColorData
 
class  CanandcolorFaults
 
class  CanandcolorProximityConfig
 
class  CanandcolorSettings
 
class  CanandcolorStatus
 
class  DigoutMode
 

Enumerations

enum  CanandcolorColorPeriod : uint8_t {
  k40ms = 0 , k80ms = 1 , k160ms = 2 , k320ms = 3 ,
  k640ms = 4 , k1280ms = 5
}
 
enum class  CanandcolorDigout : uint8_t { kDigout1 = 0 , kDigout2 = 1 }
 
enum  CanandcolorDataSource : uint8_t {
  kProximity = 0 , kRed = 1 , kGreen = 2 , kBlue = 3 ,
  kWhite = 4 , kHue = 5 , kSaturation = 6 , kValue = 7
}
 

Detailed Description

Namespace for all classes relating to the Canandcolor

Enumeration Type Documentation

◆ CanandcolorColorPeriod

Enum representing the internal configuration of the Canandcolor's color IC. Passed to CanandcolorSettings which may be then used with Canandcolor::SetSettings to configure the device.

The color sensor IC supports a single parameter that serves as both the integration and sampling period, which can be adjusted from 40 ms to 1280 ms. This period functions as a kind of "exposure time" – longer periods mean colors at lower light can be read more accurately, but also mean they saturate faster in higher light conditions and have higher latency.

The default is 40 ms.

Enumerator
k40ms 

Sample the color sensor every 40 ms.

k80ms 

Sample the color sensor every 80 ms.

k160ms 

Sample the color sensor every 160 ms.

k320ms 

Sample the color sensor every 320 ms.

k640ms 

Sample the color sensor every 640 ms.

k1280ms 

Sample the color sensor every 1280 ms.

◆ CanandcolorDataSource

Data sources that digout slots can use to perform comparisons or output data directly as a duty cycle.

All values are typically considered to be scaled between 0.0 and 1.0. For proximity, red, green, blue, white, and HSV, the values that digout slots consider (and what the Rio would read if it read the PWM outputs), are generally equivalent to the values read through functions like Canandcolor.GetProximity() or Canandcolor.GetColor().

The normalized difference data sources operate a bit differently. For example, the red-blue source approximately calculates via the following algorithm:

// red and blue are assumed to be between [0.0..1.0)
red_blue_diff = (red - blue) / (2 * (red + blue + 0.000015)) + 0.5

This means that at red=1, blue=0, the difference is close to 1.0, while when red=0, blue=1, the difference is around 0. If red and blue are equal, the difference is 0.5. By normalizing on the sum of both red and blue, it removes the influence of their magnitudes on the output, focusing more on how they compare to each other ratio-wise.

This makes normalized difference effective at discriminating between, say, red and blue objects, but for full effacacy e.g. for intake rejection, one may want to combine it with the proximity output to verify an object actually exists. Whether or not this is more or less effective than measuring hue is up to the end-user to experiment with.

Enumerator
kProximity 

Proximity value

kRed 

Red reading

kGreen 

Green reading

kBlue 

Blue reading

kWhite 

White reading

kHue 

Hue reading

kSaturation 

Saturation reading

kValue 

Value reading

◆ CanandcolorDigout

Represents the digital outputs on the Canandcolor.

The Canandcolor has two digital output pads: DIGOUT1 and DIGOUT2. They can be configured to output high or low values at 3.3v logic depending on sensor value conditions.

Enumerator
kDigout1 

Enum representing the pad silkscreened as OUT1 on the Canandcolor.

kDigout2 

Enum representing the pad silkscreened as OUT2 on the Canandcolor.