Παρακολούθηση γραμμών#

Εισαγωγή#

The line class is used with the Line Tracker, an analog sensor that uses an infrared LED and light sensor to detect the reflectivity of the surface in front of it. It is designed to be mounted under the chassis of a robot so that the robot can follow a pre-marked path.

Το VEX Line Tracker.

Κατασκευαστής κλάσης#

line(
  triport::port &port );

Καταστροφέας κλάσης#

Destroys the line object and releases associated resources.

virtual ~line();

Παράμετροι#

Παράμετρος

Τύπος

Περιγραφή

port

triport::port &

The 3-Wire Port that the Line Tracker is connected to, written as Brain.ThreeWirePort.X or ExpanderName.X, where X is the port letter (for example, Brain.ThreeWirePort.A or Expander1.A).

Παραδείγματα#

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

Συναρτήσεις Μελών#

The line class includes the following member functions:

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

Before calling any line member functions, a line instance must be created, as shown below:

/* 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#

Returns an int32_t that represents the amount of light reflected from the surface as a percent. This can be used to help a robot follow a pre-marked path.

Σημείωμα:

  • Η ανακλαστικότητα 0% σημαίνει ότι το αντικείμενο είναι πολύ σκοτεινό.

  • Η ανακλαστικότητα 100% σημαίνει ότι το αντικείμενο είναι πολύ φωτεινό.

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

Parameters

Παράμετρος

Τύπος

Περιγραφή

units

percentUnits

The unit that represents the reflectivity: percent / pct (default) — percent

Return Values

Returns an int32_t representing the reflectivity measured by the Line Tracker as a percent in the range 0 - 100%.

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