線路追蹤器#
介紹#
line 類感測器與循線器配合使用,循線器是一種類比感測器,它利用紅外線LED和光感測器來檢測前方表面的反射率。此感測器設計用於安裝在機器人底盤下方,以便機器人能夠沿著預先標記的路徑行進。
![]()
類別建構函數#
line(
triport::port &port );
類別析構函數#
銷毀第 line 物件並釋放相關資源。
virtual ~line();
參數#
範圍 |
類型 |
描述 |
|---|---|---|
|
|
線路追蹤器連接的 3 線端口,寫成 |
範例#
// Create a line instance in Port A
line LineTrackerA = line(Brain.ThreeWirePort.A);
成員功能#
第 line 類包含以下成員函數:
reflectivity— Returns anint32_tthat 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%反射率意味著物體非常明亮。
int32_t reflectivity(
percentUnits units = percentUnits::pct );
範圍 |
類型 |
描述 |
|---|---|---|
|
|
反射率單位: |
傳回一個 int32_t 表示線路追蹤器測量的反射率,以百分比表示,範圍為 0 - 100%。
// Display the detected reflectivity
int32_t value = LineTrackerA.reflectivity();
Brain.Screen.print(value);