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

Εισαγωγή#

Motors and motor groups control how parts of a robot move. A Motor controls one configured Smart Motor, while a MotorGroup controls multiple configured 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 or four 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 motor_1 and motor_group_1 as example names. Replace them with your own configured names as needed.

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

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.

Υπάρχουν πολλοί τρόποι κωδικοποίησης κινητήρων και ομάδων κινητήρων. Παρακάτω είναι μια λίστα με όλες τις μεθόδους Κινητήρα και Ομαδοποίησης Κινητήρων:

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

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

  • spin_for — Spins a motor or motor group for a specific distance.

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

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

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

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

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

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

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

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

  • set_reversed — Changes whether a motor’s spin direction is reversed.

  • reset_position — Changes a motor or motor group’s current position to 0.

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

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

  • is_spinning — 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.

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

  • get_timeout — Returns the motor or motor group’s current timeout duration.

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

Ενέργειες#

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.

Usage:
motor_1.spin(direction, velocity, units)

Παράμετροι

Περιγραφή

direction

The direction the motor or motor group spins: FORWARD or REVERSE.

velocity

Optional. The velocity to spin with from 0% to 100% when using PERCENT. This can be an integer or decimal (float).

units

Optional. The velocity unit:

  • PERCENT
  • RPM (default) — Rotations per minute
  • VelocityUnits.DPS — Degrees per second
  • VOLT — Voltage

# Spin the motor, then stop
motor_1.spin(FORWARD)
wait(1, SECONDS)
motor_1.stop()

spin_for#

spin_for spins a motor or motor group for a specific distance. The spin is relative to the current position of the motor or motor group. The project will wait until the motor or motor group is done spinning before the next line of code runs.

Usage:
motor_1.spin_for(direction, angle, units, velocity, units_v, wait)

Παράμετροι

Περιγραφή

direction

The direction the motor or motor group spins: FORWARD or REVERSE.

angle

The distance the motor or motor group spins. This can be an integer or decimal (float).

units

Optional. The distance unit: DEGREES (default) or TURNS.

velocity

Optional. The velocity to spin with from 0% to 100% when using PERCENT. This can be an integer or decimal (float).

units_v

Optional. The velocity unit:

  • PERCENT
  • RPM (default) — Rotations per minute

wait

Optional.

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

# Spin the motor forward once, then reset
motor_1.spin_for(FORWARD, 90, DEGREES)
wait(1, SECONDS)
motor_1.spin_for(REVERSE, 90, DEGREES)

spin_to_position#

spin_to_position 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 set_position method.

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

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

Usage:
motor_1.spin_to_position(rotation, units, velocity, units_v, wait)

Παράμετροι

Περιγραφή

rotation

The position value the motor or motor group will spin to. This can be an integer or decimal (float).

units

The position unit: DEGREES or TURNS.

velocity

Optional. The velocity to spin with from 0% to 100% when using PERCENT. This can be an integer or decimal (float).

units_v

Optional. The velocity unit:

  • PERCENT
  • RPM — Rotations per minute
  • VelocityUnits.DPS — Degrees per second

wait

Optional.

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

# Spin the motor to the new 0 position
motor_1.set_position(180, DEGREES)
motor_1.spin_to_position(0, DEGREES)

stop#

stop stops a motor or motor group from spinning.

Usage:
motor_1.stop(mode)

Παράμετροι

Περιγραφή

mode

Optional. How the motor or motor group will stop:

  • BRAKE — Stops immediately.
  • COAST — Slows to a stop.
  • HOLD — Stops immediately and holds the motor’s position.

# Spin the motor, then stop
motor_1.spin(FORWARD)
wait(1, SECONDS)
motor_1.stop()

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

set_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. set_position changes the motor or motor group’s current position to a new value.

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

Usage:
motor_1.set_position(position, units)

Παράμετροι

Περιγραφή

position

The position value to set for the motor or motor group. This can be an integer or decimal (float).

units

Optional. The position unit: DEGREES (default) or TURNS.

# Spin the motor to the new 0 position
motor_1.set_position(180, DEGREES)
motor_1.spin_to_position(0, DEGREES)

set_velocity#

set_velocity 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% από προεπιλογή.

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

Usage:
motor_1.set_velocity(velocity, units)

Παράμετροι

Περιγραφή

velocity

The velocity to spin with from 0% to 100% when using PERCENT. This can be an integer or decimal (float).

units

Optional. The velocity unit:

  • PERCENT
  • RPM (default) — Rotations per minute
  • VelocityUnits.DPS — Degrees per second

# Spin forward at the default velocity
motor_1.spin_for(FORWARD, 100)
wait(1, SECONDS)

# Spin slower
motor_1.set_velocity(20, PERCENT)
motor_1.spin_for(FORWARD, 100)
wait(1, SECONDS)

# Spin faster
motor_1.set_velocity(100, PERCENT)
motor_1.spin_for(FORWARD, 100)
wait(1, SECONDS)

set_stopping#

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

Usage:
motor_1.set_stopping(mode)

Παράμετροι

Περιγραφή

mode

How the motor or motor group will stop:

  • BRAKE — Stops immediately.
  • COAST — Slows to a stop.
  • HOLD — Stops immediately and holds the motor’s position.

If this method is not used, the motor will use BRAKE when stopping.

set_max_torque#

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

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

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

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

Usage:
motor_1.set_max_torque(value, units)

Παράμετροι

Περιγραφή

value

The max torque the motor or motor group can use. This can be an integer or decimal (float).

units

Optional. The torque unit:

  • PERCENT
  • TorqueUnits.NM (default) — Newton meters
  • TorqueUnits.INLB — Inch pounds
  • CurrentUnits.AMP

set_timeout#

set_timeout 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.

Usage:
motor_1.set_timeout(value, units)

Παράμετροι

Περιγραφή

value

The amount of time the motor or motor group can try to finish a movement. This can be a positive integer or decimal (float).

units

Optional. The unit of time:

  • SECONDS
  • MSEC (default) — Milliseconds

set_reversed#

set_reversed changes whether a motor’s spin direction is reversed. This method works the same as setting the reverse parameter to True when constructing a Motor.

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

Usage:
motor_1.set_reversed(value)

Παράμετροι

Περιγραφή

value

Whether the motor’s direction is reversed:

  • True — Reverses the motor’s direction.
  • False — Returns the motor’s direction to its default.

reset_position#

reset_position changes the motor or motor group’s current position to 0.

Usage:
motor_1.reset_position()

Παράμετροι

Περιγραφή

Αυτή η μέθοδος δεν έχει παραμέτρους.

Αποκτητές#

is_done#

is_done 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’s movement.

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

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

This method works together with the following Motion methods that have the wait parameter: spin_for and spin_to_position.

Usage:
motor_1.is_done()

Παράμετροι

Περιγραφή

Αυτή η μέθοδος δεν έχει παραμέτρους.

# Drive forward until the motor is done spinning
motor_1.spin_for(FORWARD, 200, wait=False)
while True:
  if motor_1.is_done():
    drivetrain.stop()
  else:
    drivetrain.drive(FORWARD)

is_spinning#

is_spinning 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’s movement.

  • True — The motor or motor group is spinning.

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

This method works together with the following Motion methods that have the wait parameter: spin_for and spin_to_position.

Usage:
motor_1.is_spinning()

Παράμετροι

Περιγραφή

Αυτή η μέθοδος δεν έχει παραμέτρους.

# Drive forward until the motor is done spinning
motor_1.spin_for(FORWARD, 200, wait=False)
while True:
  if motor_1.is_spinning():
    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 στροφή. Εάν ο κινητήρας ή η ομάδα κινητήρων περιστραφεί προς την αντίθετη κατεύθυνση, η θέση θα είναι αρνητική.

Usage:
motor_1.position(units)

Παράμετροι

Περιγραφή

units

Optional. The unit to return the motor or motor group position in: DEGREES (default) or TURNS.

# Display the motor's position after spinning
brain.screen.print(motor_1.position())
brain.screen.next_row()

motor_1.spin(FORWARD)
wait(1, SECONDS)
brain.screen.print(motor_1.position())

motor_1.stop()

velocity#

velocity returns how fast the motor or motor group is spinning, as a percentage from -100% to 100% or as rotations per minute from -127 rpm to 127 rpm.

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

Usage:
motor_1.velocity(units)

Παράμετροι

Περιγραφή

units

Optional. The velocity unit to return:

  • PERCENT
  • RPM (default) — Rotations per minute
  • VelocityUnits.DPS — Degrees per second

current#

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

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

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

Usage:
motor_1.current(units)

Παράμετροι

Περιγραφή

units

Optional. The current unit to return:

  • CurrentUnits.AMP (default) — Amps

power#

power returns how much power the motor or motor group is using, measured in watts from 0.0 to 22.0 W. Power shows how quickly the motor or motor group is using energy.

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

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

Usage:
motor_1.power(units)

Παράμετροι

Περιγραφή

units

Optional. The power unit to return:

  • PowerUnits.WATT (default) — Watt

torque#

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

torque returns how much torque the motor or motor group is using, measured in inch-pounds (InLb) from 0.0 to 22.0 or Newton-meters (Nm) from 0.0 to 2.1.

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

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

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

Usage:
motor_1.torque(units)

Παράμετροι

Περιγραφή

units

The torque unit to return:

  • TorqueUnits.NM (default) — Newton meters
  • TorqueUnits.INLB — Inch pounds

efficiency#

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

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

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

Usage:
motor_1.efficiency(units)

Παράμετροι

Περιγραφή

units

Optional. The efficiency unit to return:

  • PERCENT (default)

temperature#

temperature returns the temperature of the motor or motor group.

Η θερμοκρασία του κινητήρα δείχνει πόσο ζεστός είναι ο κινητήρας ή η ομάδα κινητήρων. Μια υψηλότερη θερμοκρασία σημαίνει ότι ο κινητήρας ή η ομάδα κινητήρων θερμαίνεται ενώ λειτουργεί. Ο κινητήρας θα πρέπει να παραμένει κάτω από τους 55°C για να συνεχίσει να λειτουργεί σε πλήρη απόδοση.

Εάν ο κινητήρας ή η ομάδα κινητήρων υπερθερμανθεί, θα μειώσει το μέγιστο ρεύμα του για να προστατευτεί. Στους 70°C, ένας κινητήρας θα σταματήσει να λειτουργεί μέχρι να κρυώσει.

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

Usage:
motor_1.temperature(units)

Παράμετροι

Περιγραφή

units

Optional. The temperature unit to return:

  • TemperatureUnits.CELSIUS (default)
  • TemperatureUnits.FAHRENHEIT
  • PERCENT

count#

count returns the number of motors in a motor group.

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

Usage:
motor_group_1.count()

Παράμετροι

Περιγραφή

Αυτή η μέθοδος δεν έχει παραμέτρους.

get_timeout#

get_timeout returns the motor or motor group’s current timeout in milliseconds.

Usage:
motor_1.get_timeout()

Παράμετροι

Περιγραφή

Αυτή η μέθοδος δεν έχει παραμέτρους.

Κατασκευαστές#

Constructors are used to manually create Motor and MotorGroup objects outside of the Devices window.

Motor#

Motor creates a motor.

Usage:
Motor(port, gears, reverse)

Παράμετρος

Περιγραφή

port

The Smart Port that the motor is connected to, written as Ports.PORTx, where x is the port number.

gears

Optional. The motor’s gear ratio:

  • GearSetting.RATIO_1_1 (default) — 1:1 ratio
  • GearSetting.RATIO_2_1 — 2:1 ratio
  • GearSetting.RATIO_3_1 — 3:1 ratio

reverse

Optional. Sets whether the motor’s spin direction is reversed:

  • True — Makes FORWARD spin clockwise.
  • False (default) — Makes FORWARD spin counterclockwise.

# Create a Motor in Port 1 with default values
motor_1 = Motor(Ports.PORT1)

"""
Create a motor with the following values:
- In Port 1
- 2:1 ratio
- Reversed
"""
motor_1 = Motor(Ports.PORT1, GearSetting.RATIO_2_1, True)

MotorGroup#

MotorGroup creates a motor group.

Usage:
MotorGroup(motors)

Παράμετρος

Περιγραφή

motors

The names of previously created Motor objects to put in the motor group, separated by commas (,). Up to 12 Motor objects can be added to the group.

# Create the Motors
motor_1 = Motor(Ports.PORT1)
motor_2 = Motor(Ports.PORT2)

# Create a Motor Group
motor_group_1 = MotorGroup(motor_1, motor_2)