കളർ സെൻസർ#

ആമുഖം#

കളർ സെൻസറിൽ നിന്നുള്ള ഡാറ്റ ആക്‌സസ് ചെയ്യാൻ colorsensor ക്ലാസ് ഉപയോഗിക്കുന്നു. വസ്തുക്കളെ കണ്ടെത്താനും, നിറങ്ങൾ തിരിച്ചറിയാനും, തെളിച്ചവും നിറവും അളക്കാനും ഇത് പ്രതിഫലിച്ച പ്രകാശം ഉപയോഗിക്കുന്നു.

ക്ലാസ് കൺസ്ട്രക്റ്റർ#

colorsensor Color1 = colorsensor(index);

ക്ലാസ് ഡിസ്ട്രക്റ്റർ#

colorsensor ഒബ്‌ജക്റ്റിനെ നശിപ്പിക്കുകയും അനുബന്ധ ഉറവിടങ്ങൾ പുറത്തുവിടുകയും ചെയ്യുന്നു.

virtual ~colorsensor();

പാരാമീറ്ററുകൾ#

പാരാമീറ്റർ

ടൈപ്പ് ചെയ്യുക

വിവരണം

index

int32_t

കളർ സെൻസർ ബന്ധിപ്പിച്ചിരിക്കുന്ന സ്മാർട്ട് പോർട്ട്, PORTxഎന്ന് എഴുതിയിരിക്കുന്നു, ഇവിടെ x എന്നത് പോർട്ട് നമ്പറാണ് (ഉദാഹരണത്തിന്, PORT1).

ഉദാഹരണങ്ങൾ#

// Create an colorsensor instance in Port 1
colorsensor Color1 = colorsensor(PORT1);

അംഗ പ്രവർത്തനങ്ങൾ#

colorsensor ക്ലാസ്സിൽ ഇനിപ്പറയുന്ന അംഗ ഫംഗ്ഷനുകൾ ഉൾപ്പെടുന്നു:

  • setLight – കളർ സെൻസറിന്റെ LED ഓൺ, ഓഫ്, അല്ലെങ്കിൽ ഒരു നിശ്ചിത തെളിച്ച നിലയിലേക്ക് മാറ്റുന്നു.

  • isNearObject – ഒരു വസ്തു കളർ സെൻസറിന് സമീപമാണോ അല്ലയോ എന്ന് നൽകുന്നു.

  • detectsകണ്ടെത്തുന്നു – കളർ സെൻസർ ഒരു നിർദ്ദിഷ്ട നിറം കണ്ടെത്തിയോ ഇല്ലയോ എന്ന് നൽകുന്നു.

  • colorname – കളർ സെൻസർ കണ്ടെത്തിയ നിറത്തിന്റെ പേര് നൽകുന്നു.

  • brightness – ഒരു വസ്തുവിന്റെ കണ്ടെത്തിയ തെളിച്ചം നൽകുന്നു.

  • hue – കണ്ടെത്തിയ ഹ്യൂ മൂല്യം നൽകുന്നു.

ഏതെങ്കിലും colorsensor അംഗ ഫംഗ്ഷനുകൾ വിളിക്കുന്നതിന് മുമ്പ്, താഴെ കാണിച്ചിരിക്കുന്നതുപോലെ ഒരു colorsensor ഉദാഹരണം സൃഷ്ടിക്കണം:

/* This constructor is required when using VS Code.
Color Sensor configuration is generated automatically
in VEXcode using the Device Menu. Replace the values
as needed. */

// Create an colorsensor instance in Port 1
colorsensor Color1 = colorsensor(PORT1);

setLight#

കളർ സെൻസറിന്റെ എൽഇഡിയുടെ പ്രകാശ പവർ സജ്ജമാക്കുന്നു. വസ്തുക്കളെയും നിറങ്ങളെയും കൂടുതൽ വ്യക്തമായി കണ്ടെത്താൻ കളർ സെൻസറിനെ പ്രകാശം സഹായിക്കും.

കളർ സെൻസറിന്റെ ലൈറ്റ് ഓഫാണെങ്കിൽ, ലൈറ്റ് പവർ 0% ൽ കൂടുതൽ സജ്ജീകരിക്കുന്നത് ലൈറ്റ് ഓണാക്കും.

കളർ സെൻസറിന്റെ ലൈറ്റ് ഓണാണെങ്കിൽ, ലൈറ്റ് പവർ 0% ആയി സജ്ജീകരിക്കുന്നത് ലൈറ്റ് ഓഫ് ആക്കും.

ഉയർന്ന ശതമാനം പ്രകാശത്തെ കൂടുതൽ പ്രകാശപൂരിതമാക്കുന്നു. കുറഞ്ഞ ശതമാനം പ്രകാശത്തെ മങ്ങിക്കുന്നു.

Available Functions

1 — ledState ഉപയോഗിച്ച് LED ഓൺ അല്ലെങ്കിൽ ഓഫ് ചെയ്യുന്നു.

void setLight( 
  ledState  state );

2 — ലെഡ് ഒരു പ്രത്യേക തീവ്രതയിലേക്ക് ഓണാക്കുന്നു.

void setLight( 
  int32_t      intensity, 
  percentUnits units = percent );

Parameters

പാരാമീറ്റർ

ടൈപ്പ് ചെയ്യുക

വിവരണം

state

ledState

LED ഓണാക്കുകയോ ഓഫാക്കുകയോ ചെയ്യുന്നു. ledState::on LED 100% തെളിച്ചത്തിൽ ഓണാക്കുന്നു. ledState::off അത് ഓഫാക്കുന്നു.

intensity

int32_t

ലൈറ്റ് 0 മുതൽ 100 ​​വരെ സജ്ജീകരിക്കുന്നതിനുള്ള പവർ ലെവൽ.

units

percentUnits

പ്രകാശ തീവ്രതയെ പ്രതിനിധീകരിക്കുന്ന യൂണിറ്റ്: percent / pct — ശതമാനം

Return Values

ഈ ഫംഗ്ഷൻ ഒരു മൂല്യം തിരികെ നൽകുന്നില്ല.

Examples
// Set the light power to 50 percent.
Color1.setLight(50, percent);

isNearObject#

കളർ സെൻസർ സമീപത്തുള്ള ഒരു വസ്തുവിനെ കണ്ടെത്തിയാൽ തിരികെ നൽകുന്നു.

Available Functions
bool  isNearObject();

Parameters

ഈ ഫംഗ്ഷൻ ഒരു പാരാമീറ്ററുകളും സ്വീകരിക്കുന്നില്ല.

Return Values

സമീപത്തുള്ള ഒരു വസ്തു കണ്ടെത്തിയാൽ ഈ ഫംഗ്ഷൻ ഒരു ബൂളിയൻ നൽകുന്നു:

  • true – കളർ സെൻസർ ഒരു വസ്തുവിനെ കണ്ടെത്തുന്നു.

  • false – കളർ സെൻസർ ഒരു വസ്തുവിനെ കണ്ടെത്തുന്നില്ല.

Examples
// If an object is detected by the Color Sensor, print
// "near object".
if (Color1.isNearObject()){
  Brain.Screen.print("near object");
}

detects#

കളർ സെൻസർ ഒരു നിർദ്ദിഷ്ട നിറം കണ്ടെത്തുകയാണെങ്കിൽ തിരികെ നൽകുന്നു.

Available Functions

1 — Detects a colorType.

bool detects( 
  colorType  color );

2 — Detects a vex::color.

bool detects( 
  vex::color  color );

Parameters

പാരാമീറ്ററുകൾ

ടൈപ്പ് ചെയ്യുക

വിവരണം

color

colorType

A valid color:

  • blue – Hue value between 196° and 229°
  • blue_green – Hue value between 140° and 195°
  • blue_violet – Hue value between 230° and 239°
  • green – Hue value between 84° and 139°
  • orange – Hue value between 21° and 30°
  • purple
  • red – Hue value between 350° and 14°
  • red_orange – Hue value between 15° and 20°
  • red_violet – Hue value between 281° and 350°
  • violet – Hue value between 240° and 280°
  • white
  • yellow – Hue value between 54° and 74°
  • yellow_green – Hue value between 75° and 83°
  • yellow_orange – Hue value between 31° and 53°

color

vex::color

ഒരു സാധുവായ ഇച്ഛാനുസൃത നിറം, അല്ലെങ്കിൽ മുകളിൽ പട്ടികപ്പെടുത്തിയിരിക്കുന്ന മുൻകൂട്ടി നിശ്ചയിച്ച നിറങ്ങളിൽ ഒന്ന്.

Return Values
  • true – കളർ സെൻസർ നിറം കണ്ടെത്തുന്നു.

  • false – കളർ സെൻസർ നിറം കണ്ടെത്തുന്നില്ല.

Examples
int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  // Drive until a red object is seen
  Drivetrain.drive(forward);
  while (true) {
    if (Color1.detects(red)) {
      Drivetrain.stop();
      break;
    }
    wait(0.5, seconds);
  }
}

colorname#

കണ്ടെത്തിയ ഏറ്റവും അടുത്ത പൊരുത്തപ്പെടുന്ന നിറം നൽകുന്നു.

Available Functions
colorType colorname();

Parameters

ഈ ഫംഗ്ഷൻ ഒരു പാരാമീറ്ററുകളും സ്വീകരിക്കുന്നില്ല.

Return Values

നേരിട്ട് പ്രിന്റ് ചെയ്യുമ്പോൾ, ആ നിറവുമായി ബന്ധപ്പെട്ട സംഖ്യാ മൂല്യം ഇത് കാണിക്കുന്നു:

നിറം

സംഖ്യാ മൂല്യം

none

0

red

1

green

2

blue

3

white

4

yellow

5

orange

6

purple

7

cyan

8

red_violet

9

violet

10

blue_violet

11

blue_green

12

yellow_green

13

yellow_orange

14

red_orange

15

black

16 ഡൗൺലോഡ്

transparent

17 തീയതികൾ

Notes
  • ഡിവൈസസ് വിൻഡോയിൽ ഒരു കളർ സെൻസർ കോൺഫിഗർ ചെയ്യുമ്പോൾ, convertColorToString എന്ന ഫംഗ്ഷൻ VEXcode സ്വയമേവ സൃഷ്ടിക്കുന്നു. ഇത് VEXcode IQ പ്രോജക്റ്റുകൾക്കുള്ളിൽ മാത്രമേ ലഭ്യമാകൂ, മറ്റ് പരിതസ്ഥിതികളിൽ പ്രവർത്തിക്കില്ല.

  • VEXcode ന് പുറത്ത് colorname ഉപയോഗിക്കുമ്പോൾ, താരതമ്യങ്ങൾ നേരിട്ട് colorType മൂല്യവുമായി നടത്തണം - colorType:: ൽ ആരംഭിക്കുന്ന ഏത് നിറവും (ഉദാഹരണത്തിന്, colorType::green അല്ലെങ്കിൽ colorType::red).

Examples
int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  // Continuously check the detected color
  while (true) {

    // Compare the color name with "red"
    if (convertColorToString(Color1.colorname()) == "red") {
      Brain.Screen.print("Red object!");
    } else {
      Brain.Screen.print("Not red");
    }

    wait(0.5, seconds);
    Brain.Screen.clearScreen();
    Brain.Screen.setCursor(1, 1);
  }
}

int main() {
  // Initializing Robot Configuration. DO NOT REMOVE!
  vexcodeInit();

  // Continuously check the detected color
  while (true) {

    // Compare the color name with the colorType
    if (Color1.colorname() == colorType::red) {
      Brain.Screen.print("Red object!");
    } else {
      Brain.Screen.print("Not red");
    }

    wait(0.5, seconds);
    Brain.Screen.clearScreen();
    Brain.Screen.setCursor(1, 1);
  }
}

brightness#

വസ്തുവിൽ നിന്ന് പ്രതിഫലിക്കുന്ന പ്രകാശത്തിന്റെ അളവ് തിരികെ നൽകുന്നു.

ഉയർന്ന ശതമാനം എന്നാൽ കൂടുതൽ പ്രകാശം കളർ സെൻസറിലേക്ക് പ്രതിഫലിക്കുന്നു എന്നാണ്. കുറഞ്ഞ ശതമാനം എന്നാൽ കുറഞ്ഞ പ്രകാശം തിരികെ പ്രതിഫലിക്കുന്നു എന്നാണ്.

Available Functions
double  brightness(bool bRaw = false);

Parameters

പാരാമീറ്റർ

ടൈപ്പ് ചെയ്യുക

വിവരണം

bRaw

bool

ശതമാനത്തിന് പകരം റോ ബ്രൈറ്റ്‌നെസ് ഡാറ്റ വായിക്കുന്നതിനുള്ള ഒരു ബൂളിയൻ മൂല്യം. ഡിഫോൾട്ട് false ആണ്.

Return Values

0 - 100% പരിധിയിൽ കളർ സെൻസർ കണ്ടെത്തിയ തെളിച്ചത്തെ പ്രതിനിധീകരിക്കുന്ന ഒരു ഇരട്ടി, അല്ലെങ്കിൽ സെൻസർ കണ്ടെത്തിയ അസംസ്കൃത ഡാറ്റയെ പ്രതിനിധീകരിക്കുന്ന ഒരു ഇരട്ടി.

Examples
// Set a variable, brightness, to the value of the brightness
// detected by the Color Sensor
double brightness = Color1.brightness();

// Print the brightness detected by the Color Sensor to the
// Brain's screen
Brain.Screen.print(brightness);

hue#

കളർ സെൻസർ കണ്ടെത്തിയ നിറം തിരികെ നൽകുന്നു.

വർണ്ണചക്രത്തിന് ചുറ്റുമുള്ള അക്കങ്ങൾ ഉപയോഗിച്ച് നിറങ്ങളെ വിവരിക്കുന്നതിനുള്ള ഒരു മാർഗമാണ് ഹ്യൂ.

VEX കളർ വീൽ ഒരു വൃത്തത്തിന് ചുറ്റുമുള്ള നിറങ്ങളുടെ ഡിഗ്രികൾ കാണിക്കുന്നു, ചുവപ്പ് 0 ഡിഗ്രിയിൽ ആയിരിക്കും, മൂല്യം വർദ്ധിക്കുന്നതിനനുസരിച്ച് മഴവില്ലിലൂടെ അത് മാറുന്നു.

Available Functions
double hue();

Parameters

ഈ ഫംഗ്ഷൻ ഒരു പാരാമീറ്ററുകളും സ്വീകരിക്കുന്നില്ല.

Return Values

0 — 359.00 ശ്രേണിയിൽ കളർ സെൻസർ കണ്ടെത്തിയ നിറത്തിന്റെ മൂല്യത്തെ പ്രതിനിധീകരിക്കുന്ന ഒരു ഇരട്ടി.

Examples
// Set a variable, hue, to the value of the hue detected
// by the Color Sensor.
double hue = Color1.hue();