線路追蹤器#

介紹#

line 類感測器與循線器配合使用,循線器是一種類比感測器,它利用紅外線LED和光感測器來檢測前方表面的反射率。此感測器設計用於安裝在機器人底盤下方,以便機器人能夠沿著預先標記的路徑行進。

VEX線路追蹤器。

類別建構函數#

line(
  triport::port &port );

類別析構函數#

銷毀第 line 物件並釋放相關資源。

virtual ~line();

參數#

範圍

類型

描述

port

triport::port &

線路追蹤器連接的 3 線端口,寫成 Brain.ThreeWirePort.X 或 ExpanderName.X,其中 X 是端口字母(例如, Brain.ThreeWirePort.A 或 Expander1.A)。

範例#

// Create a line instance in Port A
line LineTrackerA = line(Brain.ThreeWirePort.A);

成員功能#

第 line 類包含以下成員函數:

  • reflectivity — Returns an int32_t that represents the amount of light reflected from the surface as a percent.

在呼叫 line 函數之前,必須先建立 line:

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

// Create a line instance in Port A
line LineTrackerA = line(Brain.ThreeWirePort.A);

reflectivity#

傳回一個 int32_t 型值,表示表面反射光量的百分比。這可用於幫助機器人沿著預先標記的路徑移動。

筆記:

  • 0%反射率意味著物體非常暗。

  • 100%反射率意味著物體非常明亮。

Available Functions
int32_t reflectivity(
  percentUnits units = percentUnits::pct );

Parameters

範圍

類型

描述

units

percentUnits

反射率單位: percent / pct (預設)—%

Return Values

傳回一個 int32_t 表示線路追蹤器測量的反射率,以百分比表示,範圍為 0 - 100%。

Examples
// Display the detected reflectivity
int32_t value = LineTrackerA.reflectivity();
Brain.Screen.print(value);