线路跟踪器#
介绍#
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);