Κινητήρας και Ομάδα Κινητήρων#

Εισαγωγή#

Motors and motor groups control how parts of a robot move. A motor object controls one configured IQ Smart Motor, while a motor_group object controls multiple configured IQ Smart Motors together so they move in tandem. Motors and motor groups can be used to raise an arm, turn a claw, spin a wheel, or move another part of a build. Two motors can work together as a drivetrain to move and turn the whole robot.

Each motor or motor group is configured in the Devices window. Depending on the build, motor and motor group names can change. This page uses Motor1 and MotorGroup1 as example names. Replace them with your own configured names as needed.

Ένας κινητήρας VEX IQ που δείχνει την κατεύθυνση προς τα εμπρός που υποδεικνύεται από ένα σύμβολο συν και ένα βέλος που υποδεικνύει ότι περιστρέφεται αριστερά ή αριστερόστροφα. Ένας κινητήρας VEX IQ που δείχνει την αντίστροφη κατεύθυνση που υποδεικνύεται από ένα σύμβολο μείον και ένα βέλος που υποδεικνύει ότι περιστρέφεται δεξιά ή δεξιόστροφα.

By default, forward spins a motor counterclockwise, and reverse spins a motor clockwise. If a motor is set to reverse, those directions will be switched.

Μοτέρ#

Class Constructors#

1 Creates a motor object for the IQ Smart Motor connected to the specified Smart Port. The motor automatically uses the detected internal gearSetting.

motor(
  int32_t index );

2 Creates a motor object on the specified Smart Port and optionally reverses its direction. The motor automatically uses the detected internal gearSetting.

motor(
 int32_t index,
 bool    reverse );

3 Creates a motor object on the specified Smart Port with the specified gearSetting.

motor(
 int32_t     index,
 gearSetting gears );

4 Creates a motor object on the specified Smart Port with the specified gearSetting and optional reversed direction.

motor(
 int32_t     index,
 gearSetting gears,
 bool        reverse );

Class Destructor#

Destroys the motor object and releases associated resources.

~motor();

Parameters#

Παράμετρος

Τύπος

Περιγραφή

index

int32_t

The Smart Port that the motor is connected to, written as PORTx, where x is the port number (for example, PORT1).

reverse

bool

Sets whether the motor’s spin direction is reversed:

  • false (default) — Does not reverse the motor’s direction.
  • true — Reverses the motor’s direction.

gears

gearSetting

Specifies the internal gear cartridge ratio.

  • ratio1_1 — A 1:1 gear ratio
  • ratio2_1 — A 2:1 gear ratio
  • ratio3_1 — A 3:1 gear ratio

Notes#

  • Η ρύθμιση του γραναζιού πρέπει να ταιριάζει με το φυσικό φυσίγγιο που είναι εγκατεστημένο στον κινητήρα.

Example#

// Create the motor instance in Smart Port 1
motor LeftMotor = motor(PORT1);

// Creates the motor instance with different settings
motor RightMotor = motor(
  PORT2,      // Smart Port 2
  ratio2_1,  // Gear ratio is 2:1
  true);

Ομάδα Μηχανοκίνητων#

Class Constructors#

motor_group( motor &m1, Args&... m2 );

Class Destructor#

Destroys the motor_group object and releases associated resources.

~motor_group();

Parameters#

Παράμετρος

Τύπος

Περιγραφή

m1

motor &

Ο πρώτος κινητήρας προστέθηκε στην ομάδα.

m2

motor &

Προστέθηκαν επιπλέον κινητήρες στην ομάδα. Ο μέγιστος αριθμός είναι τέσσερις κινητήρες σε μία ομάδα κινητήρων.

Example#

// Create individual motor instances
motor LeftMotor  = motor(PORT1);
motor RightMotor = motor(PORT2);

// Create a motor group with both motors
motor_group DriveMotors = motor_group(LeftMotor, RightMotor);

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

There are many ways to code motors and motor groups. Below is a list of all motor and motor_group member functions:

Ενέργειες — Διακοπή και περιστροφή κινητήρων και ομάδων κινητήρων.

  • spin — Spins a motor or motor group forward or reverse forever.

  • spinFor — Spins a motor or motor group for a specific distance or amount of time.

  • spinToPosition — Spins a motor or motor group to a specific position.

  • stop — Stops a motor or motor group from spinning.

Μεταλλαγμένοι — Προσαρμόστε τις ρυθμίσεις του κινητήρα και της ομάδας κινητήρων.

  • setVelocity — Tells a motor or motor group how fast to spin.

  • setMaxTorque — Sets how hard a motor or motor group is allowed to push while spinning.

  • setPosition — Changes the motor or motor group’s current position to a new value.

  • setStopping — Sets how a motor or motor group will stop moving: by braking, coasting, or holding.

  • setTimeout — Sets how much time a motor or motor group will try to finish a movement.

Λήπτες — Έλεγχος κατάστασης κινητήρα και ομάδας κινητήρων.

  • isDone — Returns whether the motor or motor group is finished moving, as a Boolean value.

  • isSpinning — Returns whether the motor or motor group is spinning, as a Boolean value.

  • position — Returns the motor or motor group’s current position.

  • velocity — Returns how fast the motor or motor group is spinning.

  • current — Returns how much electrical current the motor or motor group is using.

  • power — Returns how much power the motor or motor group is using.

  • torque — Returns how much torque the motor or motor group is using.

  • efficiency — Returns how efficiently the motor or motor group is using power.

  • temperature — Returns the temperature of the motor or motor group.

  • voltage — Returns the electrical voltage supplied to the motor or motor group.

  • direction — Returns the direction the motor or motor group is spinning.

  • installed — Returns whether the motor or motor group is connected to the Brain.

  • count — Returns the number of motors in a motor group.

Before calling any motor or motor_group member functions, an instance must be created, as shown below:

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

// Create the motor instance in Smart Port 1
motor Motor1 = motor(PORT1);

Ενέργειες#

spin#

spin spins a motor or motor group forward or reverse forever. The motor or motor group will continue to spin until it is given another action, like spinning in a different direction or stopping.

Available Functions

1 Περιστρέφει τον κινητήρα ή την ομάδα κινητήρων χρησιμοποιώντας την τρέχουσα διαμορφωμένη ταχύτητα κινητήρα.

void spin(
 directionType dir );

2 Περιστρέφει τον κινητήρα ή την ομάδα κινητήρων με την καθορισμένη ταχύτητα.

void spin(
 directionType dir,
 double        velocity,
 velocityUnits units );

3 Περιστρέφει τον κινητήρα ή την ομάδα κινητήρων χρησιμοποιώντας την καθορισμένη τάση.

void spin(
 directionType dir,
 double        voltage,
 voltageUnits  units );

Parameters

Παράμετρος

Τύπος

Περιγραφή

dir

directionType

The direction the motor or motor group spins: forward or reverse.

velocity

double

The velocity to spin with from 0% to 100% when using percent.

units

velocityUnits

The unit used to represent velocity:

  • percent / pct — percent
  • rpm — rotations per minute
  • dps — degrees per second

voltage

double

The voltage to spin with. A negative value spins opposite the given dir.

units

voltageUnits

The unit used to represent voltage:

  • volt — volts
  • voltageUnits::mV — millivolts

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Αυτή η συνάρτηση δεν είναι σε αναμονή και το έργο θα συνεχίσει να εκτελείται αμέσως μετά την κλήση.

  • The motor or motor group will continue spinning until stop is called or another movement function is executed.

  • Functions such as isDone and isSpinning are not applicable to spin, since it does not use target-based movement (doesn’t have a rotation or time parameter).

Examples
// Spin forward, then stop
Motor1.spin(forward);
wait(1, seconds);
Motor1.stop();

spinFor#

spinFor spins a motor or motor group for a specific distance or amount of time. A rotation-based spin is relative to the current position of the motor or motor group. By default, the project will wait until the motor or motor group is done spinning before the next line of code runs.

Available Functions

1 Περιστρέφεται για μια συγκεκριμένη απόσταση με την ταχύτητα που παρέχεται στην κλήση της συνάρτησης.

bool spinFor(
 double        rotation,
 rotationUnits units,
 double        velocity,
 velocityUnits units_v,
 bool          waitForCompletion = true );

2 Δέχεται μια παράμετρο κατεύθυνσης και περιστρέφεται για μια συγκεκριμένη απόσταση με την ταχύτητα που παρέχεται στην κλήση της συνάρτησης.

bool spinFor(
 directionType dir,
 double        rotation,
 rotationUnits units,
 double        velocity,
 velocityUnits units_v,
 bool          waitForCompletion = true );

3 Περιστρέφεται για μια συγκεκριμένη απόσταση χρησιμοποιώντας την τρέχουσα διαμορφωμένη ταχύτητα κινητήρα.

bool spinFor(
 double        rotation,
 rotationUnits units,
 bool          waitForCompletion = true );

4 Δέχεται μια παράμετρο κατεύθυνσης και περιστρέφεται για μια συγκεκριμένη απόσταση χρησιμοποιώντας την τρέχουσα διαμορφωμένη ταχύτητα κινητήρα.

bool spinFor(
 directionType dir,
 double        rotation,
 rotationUnits units,
 bool          waitForCompletion = true );

5 Περιστρέφεται για ένα συγκεκριμένο χρονικό διάστημα με την ταχύτητα που παρέχεται στην κλήση της συνάρτησης.

bool spinFor(
 double        time,
 timeUnits     units,
 double        velocity,
 velocityUnits units_v );

6 Δέχεται μια παράμετρο κατεύθυνσης και περιστρέφεται για ένα συγκεκριμένο χρονικό διάστημα με την ταχύτητα που παρέχεται στην κλήση της συνάρτησης.

bool spinFor(
 directionType dir,
 double        time,
 timeUnits     units,
 double        velocity,
 velocityUnits units_v );

7 Περιστρέφεται για συγκεκριμένο χρονικό διάστημα χρησιμοποιώντας την τρέχουσα διαμορφωμένη ταχύτητα κινητήρα.

bool spinFor(
 double    time,
 timeUnits units );

8 Δέχεται μια παράμετρο κατεύθυνσης και περιστρέφεται για ένα συγκεκριμένο χρονικό διάστημα χρησιμοποιώντας την τρέχουσα διαμορφωμένη ταχύτητα κινητήρα.

bool spinFor(
 directionType dir,
 double        time,
 timeUnits     units );

Parameters

Παράμετρος

Τύπος

Περιγραφή

dir

directionType

The direction the motor or motor group spins: forward or reverse.

rotation

double

Η απόσταση που περιστρέφεται ο κινητήρας ή η ομάδα κινητήρων.

units

rotationUnits

The rotation unit:

  • deg / degrees — degrees
  • turns / rev — revolutions

time

double

Ο χρόνος που περιστρέφεται ο κινητήρας ή η ομάδα κινητήρων.

units

timeUnits

The unit of time:

  • seconds / sec — seconds
  • msec — milliseconds

velocity

double

The velocity to spin with from 0% to 100% when using percent.

units_v

velocityUnits

The unit used to represent velocity:

  • percent / pct — percent
  • rpm — rotations per minute
  • dps — degrees per second

waitForCompletion

bool

  • true (default) — Makes the project wait until the motor or motor group is done spinning before the next line of code runs.
  • false — Makes the next line of code run right away.

Return Values

Επιστρέφει μια δυαδική τιμή που δείχνει εάν ο κινητήρας ή η ομάδα κινητήρων έφτασε την τιμή-στόχο.

  • true — The motor or motor group reached the target value.
  • false — The motor or motor group was not able to reach the target value or waitForCompletion is set to false.
Notes
  • Executing another motor movement function (such as spin or stop) while spinFor is in progress will interrupt the current movement.

  • Because spinFor is target-based (uses a rotation or time parameter), functions such as isDone and isSpinning work with spinFor.

Examples
// Spin 1 turn fast, then 1 turn slow
Motor1.spinFor(forward, 1, turns, true);
Motor1.spinFor(reverse, 1, turns, 20, velocityUnits::pct, true);

spinToPosition#

spinToPosition spins a motor or motor group to a specific position.

A motor or motor group’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. At the beginning of a project, the motor or motor group position is set to 0 degrees. The motor or motor group position can also be set using the setPosition function.

Οι τιμές θέσης είναι απόλυτες. Αυτό σημαίνει ότι η κατεύθυνση της περιστροφής εξαρτάται από την τρέχουσα θέση του κινητήρα ή της ομάδας κινητήρων.

Για παράδειγμα, εάν ο κινητήρας ή η ομάδα κινητήρων ξεκινήσει από τις 0 μοίρες και περιστραφεί σε μια θέση 720 μοιρών, θα περιστραφεί προς τα εμπρός κατά δύο στροφές. Εάν στη συνέχεια περιστραφεί σε μια θέση 360 μοιρών, θα περιστραφεί προς τα πίσω κατά μία στροφή, επειδή οι 360 μοίρες είναι μικρότερες από 720 μοίρες.

Available Functions

1 Περιστρέφεται σε μια συγκεκριμένη θέση με την ταχύτητα που παρέχεται στην κλήση της συνάρτησης.

bool spinToPosition(
 double        rotation,
 rotationUnits units,
 double        velocity,
 velocityUnits units_v,
 bool          waitForCompletion = true );

2 Περιστρέφεται σε μια συγκεκριμένη θέση χρησιμοποιώντας την τρέχουσα διαμορφωμένη ταχύτητα κινητήρα.

bool spinToPosition(
 double        rotation,
 rotationUnits units,
 bool          waitForCompletion = true );

Parameters

Παράμετρος

Τύπος

Περιγραφή

rotation

double

Η τιμή θέσης στην οποία θα περιστραφεί ο κινητήρας ή η ομάδα κινητήρων.

units

rotationUnits

The rotation unit:

  • deg / degrees — degrees
  • turns / rev — revolutions

velocity

double

The velocity to spin with from 0% to 100% when using percent.

units_v

velocityUnits

The unit used to represent velocity:

  • pct — percent
  • rpm — rotations per minute
  • dps — degrees per second

waitForCompletion

bool

  • true (default) — Makes the project wait until the motor or motor group is done spinning before the next line of code runs.
  • false — Makes the next line of code run right away.

Return Values

Επιστρέφει μια δυαδική τιμή που δείχνει εάν ο κινητήρας ή η ομάδα κινητήρων ξεκίνησε την αιτούμενη κίνηση βάσει στόχου.

  • true — The motor or motor group begins the requested target-based movement.
  • false — The call fails or waitForCompletion is set to false.
Notes
  • Executing another motor movement function (such as spin or spinFor) while spinToPosition is in progress will interrupt the current movement.

  • Because spinToPosition is target-based (uses a rotation parameter), functions such as isDone and isSpinning work with spinToPosition.

Examples
// Spin forward, then go to 90°
Motor1.spin(forward);
wait(1, seconds);
Motor1.spinToPosition(90, degrees);

stop#

stop stops a motor or motor group from spinning.

Available Functions

1 Διακόπτει τον κινητήρα ή την ομάδα κινητήρων χρησιμοποιώντας την τρέχουσα διαμορφωμένη λειτουργία πέδησης.

void stop();

2 Διακόπτει τον κινητήρα ή την ομάδα κινητήρων χρησιμοποιώντας τη λειτουργία πέδησης που παρέχεται στην κλήση συνάρτησης.

void stop(
  brakeType mode );

Parameters

Παράμετρος

Τύπος

Περιγραφή

mode

brakeType

Optional. How the motor or motor group will stop:

  • coast — Slows to a stop.
  • brake — Stops immediately.
  • hold — Stops immediately and holds the motor or motor group position.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes Examples
// Spin and coast to a stop
Motor1.setVelocity(100, percent);
Motor1.spin(forward);
wait(1, seconds);
Motor1.stop(coast);

Μεταλλάκτες#

setVelocity#

setVelocity tells a motor or motor group how fast to spin. A higher percentage makes the motor or motor group spin faster and a lower percentage makes the motor or motor group spin slower.

Κάθε έργο ξεκινά με κάθε κινητήρα ή ομάδα κινητήρων να περιστρέφεται με ταχύτητα 50% από προεπιλογή.

Σημείωση: Μια υψηλότερη ταχύτητα κάνει τον κινητήρα ή την ομάδα κινητήρων να περιστρέφεται πιο γρήγορα, αλλά μπορεί να είναι λιγότερο ακριβής. Μια χαμηλότερη ταχύτητα κάνει τον κινητήρα ή την ομάδα κινητήρων να περιστρέφεται πιο αργά, αλλά μπορεί να είναι πιο ακριβής.

Available Functions
void setVelocity(
    double        velocity,
    velocityUnits units );

Parameters

Παράμετρος

Τύπος

Περιγραφή

velocity

double

The velocity to spin with from 0% to 100% when using percent.

units

velocityUnits

The unit used to represent velocity:

  • percent / pct — percent
  • rpm — rotations per minute
  • dps — degrees per second

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Any subsequent motor movement function (such as spin, spinFor, or spinToPosition) that does not explicitly specify a velocity will use this value.

Examples
// Try default, then slow, then fast
Motor1.spinFor(forward, 180, degrees);
wait(1, seconds);
Motor1.setVelocity(20, percent);
Motor1.spinFor(reverse, 180, degrees);
wait(1, seconds);
Motor1.setVelocity(100, percent);
Motor1.spinFor(forward, 180, degrees);

setMaxTorque#

Η ροπή δείχνει πόσο δυνατά μπορεί να ωθήσει ή να έλξει ένας κινητήρας ή μια ομάδα κινητήρων ενώ περιστρέφεται.

setMaxTorque sets the most torque a motor or motor group is allowed to use.

Ένα υψηλότερο ποσοστό επιτρέπει στον κινητήρα ή την ομάδα κινητήρων να πιέζει πιο δυνατά, όπως κατά την ανύψωση ενός βαρέος αντικειμένου. Ένα χαμηλότερο ποσοστό περιορίζει την ισχύ που μπορεί να πιέσει ο κινητήρας ή η ομάδα κινητήρων. Αυτό μπορεί να βοηθήσει στην προστασία του ρομπότ εάν ο κινητήρας ή η ομάδα κινητήρων κολλήσει ή φτάσει στο όριο της απόστασης που μπορεί να κινηθεί.

Κάθε έργο ξεκινά με τη ροπή κάθε κινητήρα ή ομάδας κινητήρων στο 50% από προεπιλογή.

Available Functions

1 Ορίζει τη μέγιστη ροπή ως ποσοστό της ονομαστικής ροπής του κινητήρα ή της ομάδας κινητήρων.

void setMaxTorque(
 double       value,
 percentUnits units );

2 Ορίζει τη μέγιστη ροπή χρησιμοποιώντας φυσικές μονάδες ροπής.

void setMaxTorque(
 double      value,
 torqueUnits units );

3 Ορίζει τη μέγιστη ροπή περιορίζοντας το ρεύμα του κινητήρα.

void setMaxTorque(
 double       value,
 currentUnits units );

Parameters

Παράμετρος

Τύπος

Περιγραφή

value

double

Η μέγιστη ροπή που μπορεί να χρησιμοποιήσει ο κινητήρας ή η ομάδα κινητήρων.

units

percentUnits

Specifies torque as a percentage: percent / pct — percent

units

torqueUnits

Specifies torque in physical units such as:

  • Nm — Newton-meters
  • InLb — inch-pounds

units

currentUnits

Specifies torque by limiting motor current:

  • amp

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • When using currentUnits, torque is limited by restricting how much electrical current the motor or motor group can use.

setPosition#

A motor or motor group’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. setPosition changes the motor or motor group’s current position to a new value.

Για παράδειγμα, εάν ένας κινητήρας ή μια ομάδα κινητήρων έχει περιστραφεί στις 180 μοίρες, η ρύθμιση της θέσης σε 0 μοίρες θα επαναφέρει αυτήν τη θέση από 180 σε 0 μοίρες. Στη συνέχεια, ο κινητήρας ή η ομάδα κινητήρων μπορεί να περιστραφεί σε θέσεις με βάση αυτήν τη νέα τιμή.

Available Functions
void setPosition(
    double        value,
    rotationUnits units );

Parameters

Παράμετρος

Τύπος

Περιγραφή

value

double

Η τιμή θέσης που θα οριστεί για τον κινητήρα ή την ομάδα κινητήρων.

units

rotationUnits

The position unit:

  • deg / degrees — degrees
  • turns / rev — revolutions

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • After calling setPosition, subsequent calls to spinToPosition will use the updated position as the reference.

setStopping#

setStopping sets how a motor or motor group will stop moving: by braking, coasting, or holding.

Available Functions
void setStopping(
  brakeType mode );

Parameters

Παράμετρος

Τύπος

Περιγραφή

mode

brakeType

How the motor or motor group will stop:

  • brake — Stops immediately.
  • coast — Slows to a stop.
  • hold — Stops immediately and holds the motor or motor group position.

Return Values

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Any subsequent call to stop without a specified brake mode will use this value.

setTimeout#

setTimeout sets how much time a motor or motor group will try to finish a movement. If the motor or motor group cannot finish in that time, it will stop trying and move on to the next line of code. This keeps the motor or motor group from getting stuck on a movement.

Available Functions
void setTimeout(
    int32_t   time,
    timeUnits units );

Parameters

Παράμετρος

Τύπος

Περιγραφή

time

int32_t

Ο χρόνος που μπορεί να προσπαθήσει η μηχανή ή η ομάδα κινητών για να ολοκληρώσει μια κίνηση. Πρέπει να είναι θετικός ακέραιος αριθμός.

units

timeUnits

The unit of time:

  • msec — milliseconds
  • seconds / sec — seconds

Επιστρεφόμενες τιμές

Αυτή η συνάρτηση δεν επιστρέφει τιμή.

Notes
  • Το χρονικό όριο του κινητήρα ή της ομάδας κινητήρων χρησιμοποιείται για να εμποδίσει τις κινήσεις που δεν φτάνουν στη θέση-στόχο τους να σταματήσουν την εκτέλεση άλλων εντολών στη στοίβα.

  • Εάν ο κινητήρας ή η ομάδα κινητήρων δεν φτάσει στη θέση-στόχο του πριν από τη λήξη του χρονικού ορίου, θα σταματήσει την προσπάθεια και θα προχωρήσει στην επόμενη γραμμή κώδικα.

  • The timeout applies to functions that have a target value such as spinFor and spinToPosition.

Examples
// Stop a long move after 1 second
Motor1.setTimeout(1, seconds);
Motor1.spinFor(forward, 2, turns);
Motor1.spinToPosition(0, degrees);

Αποκτητές#

isDone#

isDone returns whether the motor or motor group is finished moving, as a Boolean value. This can be used to control the timing of other behaviors based on the motor or motor group’s movement.

  • true — The motor or motor group is finished moving.

  • false — The motor or motor group is still moving.

This function works together with the following Motion functions that have the waitForCompletion parameter: spinFor and spinToPosition.

Available Functions
bool isDone();

Parameters

Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.

Return Values

Επιστρέφει εάν ο κινητήρας ή η ομάδα κινητήρων έχει ολοκληρώσει την κίνηση, ως λογική τιμή.

  • true — The motor or motor group is finished moving.
  • false — The motor or motor group is still moving.
Notes
  • isDone works together with the following Motion functions that have the waitForCompletion parameter: spinFor and spinToPosition.

Examples
// Spin forward until the motor is done spinning
Motor1.spinFor(forward, 200, degrees, false);
while (true) {
  if (Motor1.isDone()) {
    Drivetrain.stop();
  } else {
    Drivetrain.drive(forward);
  }
}

isSpinning#

isSpinning returns whether the motor or motor group is spinning, as a Boolean value. This can be used to control the timing of other behaviors based on the motor or motor group’s movement.

  • true — The motor or motor group is spinning.

  • false — The motor or motor group is not spinning.

This function works together with Motion movement functions such as spin, spinFor, and spinToPosition.

Available Functions
bool isSpinning();

Parameters

Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.

Return Values

Επιστρέφει εάν ο κινητήρας ή η ομάδα κινητήρων περιστρέφεται, ως λογική τιμή.

  • true — The motor or motor group is spinning.
  • false — The motor or motor group is not spinning.
Notes Examples
// Spin forward until the motor is done spinning
Motor1.spinFor(forward, 200, degrees, false);
while (true) {
  if (Motor1.isSpinning()) {
    Drivetrain.drive(forward);
  } else {
    Drivetrain.stop();
  }
}

position#

A motor or motor group’s position is how far it has spun, measured in degrees or turns. One turn is equal to 360 degrees. position returns the motor or motor group’s current position.

Στην αρχή ενός έργου, η θέση του κινητήρα ή της ομάδας κινητήρων ορίζεται σε 0 μοίρες. Εάν ο κινητήρας ή η ομάδα κινητήρων περιστραφεί μία στροφή προς τα εμπρός, η θέση θα είναι 360 μοίρες ή 1 στροφή. Εάν ο κινητήρας ή η ομάδα κινητήρων περιστραφεί προς την αντίθετη κατεύθυνση, η θέση θα είναι αρνητική.

Available Functions
double position(
  rotationUnits units );

Parameters

Παράμετρος

Τύπος

Περιγραφή

units

rotationUnits

The unit to return the motor or motor group position in:

  • deg / degrees — degrees
  • turns / rev — revolutions

Return Values

Returns a double representing the motor or motor group’s current position in the specified units.

Notes
  • Calling setPosition changes the reference point for this value.

  • Η επιστρεφόμενη τιμή αντικατοπτρίζει την τρέχουσα ένδειξη του κωδικοποιητή και δεν υποδεικνύει εάν ο κινητήρας ή η ομάδα κινητήρων κινείται ενεργά.

  • When called on a motor_group, this function returns the position of the first motor in the group.

Examples
// Spin, then show the final position
Motor1.spin(forward);
wait(1, seconds);
Motor1.stop();
Brain.Screen.print("Pos: %f", Motor1.position(degrees));

velocity#

velocity returns how fast the motor or motor group is spinning.

Μια θετική τιμή σημαίνει ότι ο κινητήρας ή η ομάδα κινητήρων περιστρέφεται προς τα εμπρός. Μια αρνητική τιμή σημαίνει ότι περιστρέφεται προς τα πίσω.

Available Functions
double velocity(
    velocityUnits units );

Parameters

Παράμετρος

Τύπος

Περιγραφή

units

velocityUnits

The unit used to represent velocity:

  • percent / pct — percent
  • rpm — rotations per minute
  • dps — degrees per second

Return Values

Returns a double representing how fast the motor or motor group is spinning in the specified units.

Σημειώσεις

  • When called on a motor_group, this function returns the velocity of the first motor in the group.

current#

current returns how much electrical current the motor or motor group is using. Current is the amount of electricity flowing through the motor or motor group. When returned in amps, current is reported from 0.0 to 1.2 A.

Μια υψηλότερη τιμή ρεύματος σημαίνει ότι ο κινητήρας ή η ομάδα κινητήρων χρησιμοποιεί περισσότερο ηλεκτρικό ρεύμα. Αυτό μπορεί να συμβεί όταν ο κινητήρας ή η ομάδα κινητήρων σηκώνει κάτι βαρύ, πιέζει ένα αντικείμενο ή προσπαθεί να κινηθεί όταν αυτό έχει κολλήσει.

Αυτό μπορεί να χρησιμοποιηθεί για να ελεγχθεί εάν ο κινητήρας ή η ομάδα κινητήρων παρουσιάζει δυσκολίες κατά τη διάρκεια μιας κίνησης. Εάν το ρεύμα παραμείνει υψηλό, ο κινητήρας μπορεί να θερμανθεί ή να χρησιμοποιήσει την ισχύ λιγότερο αποτελεσματικά.

Available Functions

1 Επιστρέφει το ηλεκτρικό ρεύμα του κινητήρα ή της ομάδας κινητήρων σε αμπέρ.

double current(
  currentUnits units = amp );

2 Επιστρέφει το ηλεκτρικό ρεύμα του κινητήρα ή της ομάδας κινητήρων ως ποσοστό του μέγιστου ονομαστικού ρεύματος.

double current(
  percentUnits units );

Parameters

Παράμετρος

Τύπος

Περιγραφή

units

currentUnits

The unit used to represent current:amp (default) — amperes

units

percentUnits

Represents the current as a percentage of the motor’s maximum rated current:percent / pct — percent

Return Values

Returns a double representing how much electrical current the motor or motor group is drawing in the specified units.

Σημειώσεις

  • When called on a motor_group, this function returns the total electrical current for all motors in the group.

power#

power returns how much power the motor or motor group is using in watts. Power shows how quickly the motor or motor group is using energy.

Μια υψηλότερη τιμή ισχύος σημαίνει ότι ο κινητήρας ή η ομάδα κινητήρων χρησιμοποιεί ενέργεια πιο γρήγορα. Αυτό μπορεί να συμβεί όταν ο κινητήρας ή η ομάδα κινητήρων σηκώνει κάτι βαρύ, πιέζει ένα αντικείμενο ή προσπαθεί να κινηθεί όταν αυτό έχει κολλήσει.

Αυτό μπορεί να χρησιμοποιηθεί για τη σύγκριση κινήσεων ή για τον έλεγχο αν ο κινητήρας ή η ομάδα κινητήρων αντιμετωπίζει δυσκολίες. Εάν η ισχύς παραμείνει υψηλή, ο κινητήρας μπορεί να θερμανθεί ή να χρησιμοποιήσει την ενέργεια λιγότερο αποτελεσματικά.

Available Functions
double power(
  powerUnits units = watt );

Παράμετροι

Παράμετρος

Τύπος

Περιγραφή

units

powerUnits

The unit used to represent the motor power:

  • watt (default) — watts

Επιστρεφόμενες τιμές

Returns a double representing how much power the motor or motor group is using in watts.

Σημειώσεις

  • When called on a motor_group, this function returns the electrical power of the first motor in the group.

torque#

Η ροπή δείχνει πόσο δυνατά περιστρέφεται, σπρώχνει ή τραβάει ένας κινητήρας ή μια ομάδα κινητήρων ενώ περιστρέφεται.

torque returns how much torque the motor or motor group is using.

Μια υψηλότερη τιμή ροπής σημαίνει ότι ο κινητήρας ή η ομάδα κινητήρων πιέζει ή τραβάει πιο δυνατά. Αυτό μπορεί να συμβεί όταν ο κινητήρας ή η ομάδα κινητήρων σηκώνει κάτι βαρύ, πιέζει ένα αντικείμενο ή προσπαθεί να κινηθεί όταν αυτό έχει κολλήσει.

Αυτό μπορεί να χρησιμοποιηθεί για να ελέγξετε αν ο κινητήρας ή η ομάδα κινητήρων δυσκολεύεται ή για να συγκρίνετε πόση ώθηση χρειάζονται οι διαφορετικές κινήσεις.

To set the torque of a motor or motor group, use setMaxTorque.

Available Functions
double torque(
  torqueUnits units = Nm );

Παράμετροι

Παράμετρος

Τύπος

Περιγραφή

units

torqueUnits

The unit used to represent the motor torque:

  • Nm (default) — Newton-meters
  • InLb — inch-pounds

Επιστρεφόμενες τιμές

Returns a double representing how much torque the motor or motor group is using in the specified units.

Σημειώσεις

  • When called on a motor_group, this function returns the mechanical output torque of the first motor in the group.

efficiency#

efficiency returns how efficiently the motor or motor group is using power, as a percentage from 0% to 100%.

Η απόδοση δείχνει πόση από την ισχύ του κινητήρα ή της ομάδας κινητήρων χρησιμοποιείται για κίνηση. Μια υψηλότερη τιμή απόδοσης σημαίνει ότι περισσότερη από την ισχύ του κινητήρα ή της ομάδας κινητήρων χρησιμοποιείται για κίνηση. Μια χαμηλότερη τιμή απόδοσης μπορεί να συμβεί όταν ο κινητήρας ή η ομάδα κινητήρων εργάζεται σκληρά αλλά δεν κινείται πολύ, όπως όταν έχει κολλήσει ή πιέζει ένα αντικείμενο.

Αυτό μπορεί να χρησιμοποιηθεί για τη σύγκριση κινήσεων ή για τον έλεγχο εάν ο κινητήρας ή η ομάδα κινητήρων σπαταλά ενέργεια αντί να τη χρησιμοποιεί για κίνηση.

Available Functions
double efficiency(
  percentUnits units = percent );

Παράμετροι

Παράμετρος

Τύπος

Περιγραφή

units

percentUnits

The unit used to represent motor efficiency:

  • percent / percentUnits::pct (default) — percent

Επιστρεφόμενες τιμές

Returns a double representing how efficiently the motor or motor group is using power as a percentage.

Σημειώσεις

  • When called on a motor_group, this function returns the efficiency of the first motor in the group.

temperature#

temperature returns the temperature of the motor or motor group.

Motor temperature shows how warm the motor or motor group is. A higher temperature means the motor or motor group is getting warmer while it works. The motor should stay below 55°C to keep working at full performance.

If the motor or motor group gets too hot, it will lower its maximum current to protect itself. At 70°C, a motor will stop running until it cools down.

Αυτό μπορεί να χρησιμοποιηθεί για να ελέγξετε εάν ο κινητήρας ή η ομάδα κινητήρων υπερθερμαίνεται κατά τη διάρκεια επαναλαμβανόμενων κινήσεων, μεγάλων διαδρομών ή όταν πιέζει ένα αντικείμενο.

Available Functions

1 Επιστρέφει τη θερμοκρασία του κινητήρα ή της ομάδας κινητήρων ως ποσοστό της μέγιστης θερμοκρασίας λειτουργίας.

double temperature(
  percentUnits units = percent );

2 Επιστρέφει τη θερμοκρασία του κινητήρα ή της ομάδας κινητήρων σε φυσικές μονάδες θερμοκρασίας.

double temperature(
  temperatureUnits units );

Παράμετροι

Παράμετρος

Τύπος

Περιγραφή

units

percentUnits

The unit used to represent motor or motor group temperature as a percentage:

  • percent / percentUnits::pct (default) — percent

units

temperatureUnits

The unit used to represent motor or motor group temperature in degrees:

  • celsius — degrees Celsius
  • fahrenheit — degrees Fahrenheit

Επιστρεφόμενες τιμές

Returns a double representing the temperature of the motor or motor group in the specified units.

Σημειώσεις

  • The operating temperature range for the motor is approximately 20°C (68°F) to 70°C (158°F).

  • When called on a motor_group, this function returns the temperature of the first motor in the group.

voltage#

voltage returns the electrical voltage supplied to the motor or motor group.

Available Functions
double voltage(
  voltageUnits units = volt );

Παράμετροι

Παράμετρος

Τύπος

Περιγραφή

units

voltageUnits

The unit to represent the voltage:

  • volt (default)
  • voltageUnits::mV — millivolts

Επιστρεφόμενες τιμές

Returns a double representing the electrical voltage supplied to the motor or motor group in the specified units.

Σημειώσεις

  • When called on a motor_group, this function returns the electrical voltage of the first motor in the group.

direction#

direction returns the direction that the motor or motor group is spinning.

Available Functions
directionType direction();

Παράμετροι

Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.

Επιστρεφόμενες τιμές

Returns a directionType indicating the motor’s or motor group’s current direction:

  • forward — The motor or motor group is spinning forward.
  • reverse — The motor or motor group is spinning in reverse.

installed#

installed returns whether the motor or motor group is connected to the IQ (1st gen) Brain.

Available Functions
bool installed();

Παράμετροι

Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.

Επιστρεφόμενες τιμές

Returns a bool indicating whether the motor or motor group is connected.

  • true — The motor or motor group is connected.
  • false — The motor or motor group is not connected.

count#

count returns the number of motors in a motor group.

Available Functions
int32_t count();

Παράμετροι

Αυτή η συνάρτηση δεν δέχεται καμία παράμετρο.

Επιστρεφόμενες τιμές

Returns an int32_t representing the number of motors in the motor group.