Σύστημα μετάδοσης κίνησης#

Εισαγωγή#

Το ρομπότ VEX IQ (2ης γενιάς) χρησιμοποιεί ένα σύστημα μετάδοσης κίνησης για την οδήγηση και την περιστροφή. Το σύστημα μετάδοσης κίνησης αποτελείται από κινητήρες και τροχούς που συνεργάζονται για την κίνηση του ρομπότ.

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

This page uses drivetrain as the example drivetrain name. Replace it with your own configured name as needed.

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

Ενέργειες — Μετακίνηση και περιστροφή του ρομπότ.

  • drive — Moves the robot forward or reverse forever.

  • drive_for — Moves the robot forward or reverse for a specific distance.

  • turn — Turns the robot left or right forever.

  • turn_for — Turns the robot left or right for a specific number of degrees.

  • turn_to_heading — Turns the robot to face a specific heading from -359 to 359 degrees. The robot will turn the shortest direction to reach the target heading.

  • turn_to_rotation — Turns the robot to a specific rotation.

  • stop — Stops the robot’s movement.

  • calibrate_drivetrain — Calibrates the sensor configured with the drivetrain.

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

  • set_drive_velocity — Tells the robot how fast to drive.

  • set_turn_velocity — Tells the robot how fast to turn.

  • set_stopping — Tells how the robot will stop moving: by braking, coasting, or holding.

  • set_timeout — Sets how much time the robot will try to finish a movement.

  • set_heading — Changes the robot’s current heading to a new heading.

  • set_rotation — Changes the robot’s current rotation to a new rotation.

  • set_turn_threshold — Tells how close the robot must get to a target angle before a turn is complete.

  • set_turn_constant — Changes how strongly the robot corrects its turns.

Λήψη κωδικών πρόσβασης — Ελέγξτε την κατάσταση της κίνησης.

  • heading — Returns the robot’s current heading from 0 to 359 degrees.

  • rotation — Returns the robot’s current rotation.

  • velocity — Returns how fast the robot is driving.

  • current — Returns how much electrical current the drivetrain is using.

  • is_moving — Returns whether the robot is moving, as a Boolean value.

  • is_done — Returns whether the robot is finished moving, as a Boolean value.

  • is_turning — Returns whether the robot is turning, as a Boolean value.

  • power — Returns how quickly the drivetrain is using energy.

  • torque — Returns how much torque the drivetrain is using.

  • efficiency — Returns how efficiently the drivetrain is using power.

  • temperature — Returns how warm the drivetrain is.

Κατασκευαστές — Δημιουργήστε και διαμορφώστε χειροκίνητα το σύστημα μετάδοσης κίνησης.

  • DriveTrain — Creates a drivetrain without a Gyro Sensor or Inertial Sensor.

  • SmartDrive — Creates a drivetrain with a Gyro Sensor or Inertial Sensor.

Ενέργειες#

drive#

drive moves the robot forward or reverse forever. The robot will continue to move until it is given another action, like turning or stopping.

Usage:
drivetrain.drive(direction, velocity, units)

Παράμετροι

Περιγραφή

direction

The direction the robot moves: FORWARD or REVERSE.

velocity

Optional. The velocity to drive with from 0% to 100% when using PERCENT, from 0 to 120 rpm when using RPM, or from 0 to 720 degrees per second when using VelocityUnits.DPS. This can be an integer or decimal (float). If no velocity is provided, the robot drives at the current drive velocity.

units

Optional. The velocity unit: PERCENT (default), RPM (rotations per minute), or VelocityUnits.DPS (degrees per second).

# Drive forward then stop
drivetrain.drive(FORWARD)
wait(2, SECONDS)
drivetrain.stop()

# Drive slowly in reverse then stop
drivetrain.drive(REVERSE, 20, PERCENT)
wait(2, SECONDS)
drivetrain.stop()

drive_for#

drive_for moves the robot forward or reverse for a specific distance. The project will wait until the robot is done moving before the next line of code runs.

Usage:
drivetrain.drive_for(direction, distance, units, velocity, units_v, wait)

Παράμετροι

Περιγραφή

direction

The direction the robot moves: FORWARD or REVERSE.

distance

The distance the robot drives. This can be an integer or decimal (float).

units

Optional. The distance unit: INCHES (default), MM (millimeters), or DistanceUnits.CM (centimeters).

velocity

Optional. The velocity to drive with from 0% to 100% when using PERCENT, from 0 to 120 rpm when using RPM, or from 0 to 720 degrees per second when using VelocityUnits.DPS. This can be an integer or decimal (float). If no velocity is provided, the robot drives at the current drive velocity.

units_v

Optional. The velocity unit: RPM (rotations per minute, default), PERCENT, or VelocityUnits.DPS (degrees per second).

wait

Optional. wait=True (default) makes the project wait until the robot is done moving before the next line of code runs. wait=False makes the next line of code run right away.

# Drive forward and backward
drivetrain.drive_for(FORWARD, 10)
drivetrain.drive_for(REVERSE, 10)

# Quickly drive forward and backward
drivetrain.drive_for(FORWARD, 200, MM, 100, PERCENT)
drivetrain.drive_for(REVERSE, 200, MM, 100, PERCENT)

turn#

turn turns the robot left or right forever. The robot will continue to turn until it is given another action, like driving or stopping.

Usage:
drivetrain.turn(direction, velocity, units)

Παράμετροι

Περιγραφή

direction

The direction the robot turns: LEFT or RIGHT.

velocity

Optional. The velocity to turn with from 0% to 100% when using PERCENT, from 0 to 120 rpm when using RPM, or from 0 to 720 degrees per second when using VelocityUnits.DPS. This can be an integer or decimal (float). If no velocity is provided, the robot turns at the current turn velocity.

units

Optional. The velocity unit: RPM (rotations per minute, default), PERCENT, or VelocityUnits.DPS (degrees per second).

# Turn right and left, then stop
drivetrain.turn(RIGHT)
wait(2, SECONDS)
drivetrain.turn(LEFT)
wait(2, SECONDS)
drivetrain.stop()

# Quickly turn right and left, then stop
drivetrain.turn(RIGHT, 100, PERCENT)
wait(2, SECONDS)
drivetrain.turn(LEFT, 100, PERCENT)
wait(2, SECONDS)
drivetrain.stop()

turn_for#

turn_for turns the robot left or right for a specific number of degrees or turns. The turn is relative to the current position of the robot. The project will wait until the robot is done turning before the next line of code runs.

Usage:
drivetrain.turn_for(direction, angle, units, velocity, units_v, wait)

Παράμετροι

Περιγραφή

direction

The direction the robot turns: LEFT or RIGHT.

angle

The amount the robot turns. This can be an integer or decimal (float).

units

Optional. The turn unit: DEGREES (default) or TURNS. One turn is equal to 360 degrees.

velocity

Optional. The velocity to turn with from 0% to 100% when using PERCENT, from 0 to 120 rpm when using RPM, or from 0 to 720 degrees per second when using VelocityUnits.DPS. This can be an integer or decimal (float). If no velocity is provided, the robot turns at the current turn velocity.

units_v

Optional. The velocity unit: RPM (rotations per minute, default), PERCENT, or VelocityUnits.DPS (degrees per second).

wait

Optional. wait=True (default) makes the project wait until the robot is done turning before the next line of code runs. wait=False makes the next line of code run right away.

# Turn the robot right and left
drivetrain.turn_for(RIGHT, 90, DEGREES)
wait(1, SECONDS)
drivetrain.turn_for(LEFT, 90, DEGREES)

# Quickly turn the robot right and left
drivetrain.turn_for(RIGHT, 90, DEGREES, 100, PERCENT)
wait(1, SECONDS)
drivetrain.turn_for(LEFT, 90, DEGREES, 100, PERCENT)

turn_to_heading#

A heading is the direction the robot is facing, measured in degrees. turn_to_heading turns the robot to face a specific heading from -359 to 359 degrees. The robot will turn the shortest direction to reach the target heading.

Η αρχική κατεύθυνση του ρομπότ είναι 0 μοίρες.

Το έργο θα περιμένει μέχρι να ολοκληρώσει την περιστροφή του ρομπότ προτού εκτελεστεί η επόμενη γραμμή κώδικα.

Usage:
drivetrain.turn_to_heading(angle, units, velocity, units_v, wait)

Παράμετροι

Περιγραφή

angle

The direction the robot should face, in degrees. This can be an integer or decimal (float) from -359 to 359.

units

Optional. The heading unit: DEGREES (default).

velocity

Optional. The velocity to turn with from 0% to 100% when using PERCENT, from 0 to 120 rpm when using RPM, or from 0 to 720 degrees per second when using VelocityUnits.DPS. This can be an integer or decimal (float). If no velocity is provided, the robot turns at the current turn velocity.

units_v

Optional. The velocity unit: PERCENT (default), RPM (rotations per minute), or VelocityUnits.DPS (degrees per second).

wait

Optional. wait=True (default) makes the project wait until the robot is done turning before the next line of code runs. wait=False makes the next line of code run right away.

# Turn to face the cardinal directions
drivetrain.turn_to_heading(90, DEGREES)
wait(1, SECONDS)
drivetrain.turn_to_heading(180, DEGREES)
wait(1, SECONDS)
drivetrain.turn_to_heading(270, DEGREES)
wait(1, SECONDS)
drivetrain.turn_to_heading(0, DEGREES)

# Turn twice slowly
drivetrain.turn_to_heading(90, DEGREES, 20, PERCENT)
wait(1, SECONDS)
drivetrain.turn_to_heading(180, DEGREES, 20, PERCENT)

turn_to_rotation#

turn_to_rotation turns the robot to a specific rotation.

Rotation is how much the robot has turned, measured in degrees or turns. At the beginning of a project, the rotation value is set to 0 degrees. Rotation can also be set using the set_rotation method.

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

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

Το έργο θα περιμένει μέχρι να ολοκληρώσει την περιστροφή του ρομπότ προτού εκτελεστεί η επόμενη γραμμή κώδικα.

Usage:
drivetrain.turn_to_rotation(angle, units, velocity, units_v, wait)

Παράμετροι

Περιγραφή

angle

The rotation value, in degrees or turns, that the robot will turn to. This can be an integer or decimal (float).

units

Optional. The rotation unit: DEGREES (default) or TURNS. One turn is equal to 360 degrees.

velocity

Optional. The velocity to turn with from 0% to 100% when using PERCENT, from 0 to 120 rpm when using RPM, or from 0 to 720 degrees per second when using VelocityUnits.DPS. This can be an integer or decimal (float). If no velocity is provided, the robot turns at the current turn velocity.

units_v

Optional. The velocity unit: PERCENT (default), RPM (rotations per minute), or VelocityUnits.DPS (degrees per second).

wait

Optional. wait=True (default) makes the project wait until the robot is done turning before the next line of code runs. wait=False makes the next line of code run right away.

# Turn left, then spin in a circle
# clockwise and face right
drivetrain.turn_to_rotation(-90, DEGREES)
wait(1, SECONDS)
drivetrain.turn_to_rotation(450, DEGREES)

# Turn left then slowly spin in a
# circle clockwise
drivetrain.turn_to_rotation(-90, DEGREES)
wait(1, SECONDS)
drivetrain.turn_to_rotation(450, DEGREES, 20, PERCENT)

stop#

stop stops the robot’s movement.

Usage:
drivetrain.stop(mode)

Παράμετροι

Περιγραφή

mode

Optional. How the robot will stop: BRAKE (default), COAST, or HOLD.

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

# Drive forward then stop
drivetrain.drive(FORWARD)
wait(2, SECONDS)
drivetrain.stop()

# Drive forward and coast to a stop
drivetrain.set_drive_velocity(100, PERCENT)
drivetrain.drive(FORWARD)
wait(2, SECONDS)
drivetrain.stop(COAST)

calibrate_drivetrain#

calibrate_drivetrain is a built-in function that calibrates the Gyro Sensor or Inertial Sensor configured with the drivetrain.

Η βαθμονόμηση βοηθά τον αισθητήρα να μετρήσει σωστά την κίνηση. Κρατήστε το ρομπότ ακίνητο για περίπου 2 δευτερόλεπτα κατά τη διάρκεια της βαθμονόμησης. Εάν το ρομπότ κινηθεί κατά τη διάρκεια της βαθμονόμησης, ο αισθητήρας ενδέχεται να μην μετρήσει σωστά την κίνηση.

Το έργο θα περιμένει μέχρι να ολοκληρωθεί η βαθμονόμηση πριν εκτελεστεί η επόμενη γραμμή κώδικα.

Σημείωση: Αυτή η συνάρτηση δεν μπορεί να χρησιμοποιηθεί εντός του VS Code.

Usage:
calibrate_drivetrain()

Παράμετροι

Περιγραφή

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

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

set_drive_velocity#

set_drive_velocity tells the robot how fast to drive. A higher percentage makes the robot drive faster and a lower percentage makes the robot drive slower.

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

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

Usage:
drivetrain.set_drive_velocity(velocity, units)

Παράμετροι

Περιγραφή

velocity

The velocity to drive with from 0% to 100% when using PERCENT, from 0 to 120 rpm when using RPM, or from 0 to 720 degrees per second when using VelocityUnits.DPS. This can be an integer or decimal (float).

units

Optional. The velocity unit: PERCENT (default), RPM (rotations per minute), or VelocityUnits.DPS (degrees per second).

# Drive forward at different velocities
# Default velocity
drivetrain.drive_for(FORWARD, 150, MM)
wait(1, SECONDS)
# Drive slower
drivetrain.set_drive_velocity(20, PERCENT)
drivetrain.drive_for(FORWARD, 150, MM)
wait(1, SECONDS)
# Drive faster
drivetrain.set_drive_velocity(100, PERCENT)
drivetrain.drive_for(FORWARD, 150, MM)

set_turn_velocity#

set_turn_velocity tells the robot how fast to turn. A higher percentage makes the robot turn faster and a lower percentage makes the robot turn slower.

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

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

Usage:
drivetrain.set_turn_velocity(velocity, units)

Παράμετροι

Περιγραφή

velocity

The velocity to turn with from 0% to 100% when using PERCENT, from 0 to 120 rpm when using RPM, or from 0 to 720 degrees per second when using VelocityUnits.DPS. This can be an integer or decimal (float).

units

Optional. The velocity unit: PERCENT (default), RPM (rotations per minute), or VelocityUnits.DPS (degrees per second).

# Turn at different velocities
# Default velocity
drivetrain.turn_for(RIGHT, 360)
wait(1, SECONDS)
# Turn slower
drivetrain.set_turn_velocity(20, PERCENT)
drivetrain.turn_for(RIGHT, 360)
wait(1, SECONDS)
# Turn faster
drivetrain.set_turn_velocity(100, PERCENT)
drivetrain.turn_for(RIGHT, 360)

set_stopping#

set_stopping sets how the robot will stop moving: by braking, coasting, or holding.

Usage:
drivetrain.set_stopping(mode)

Παράμετροι

Περιγραφή

mode

How the robot will stop:

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

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

set_timeout#

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

Usage:
drivetrain.set_timeout(value, units)

Παράμετροι

Περιγραφή

value

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

units

Optional. The unit of time: MSEC (milliseconds, default) or SECONDS.

# Turn right after driving forward
drivetrain.set_timeout(1, SECONDS)
drivetrain.drive_for(FORWARD, 25, INCHES)
drivetrain.turn_for(RIGHT, 90)

set_heading#

A heading is the direction the robot is facing, measured in degrees. set_heading changes the robot’s current heading to a new heading value.

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

Usage:
drivetrain.set_heading(heading, units)

Παράμετροι

Περιγραφή

heading

The heading value, in degrees or turns, to set for the robot. This can be an integer or decimal (float).

units

Optional. The heading unit: DEGREES (default) or TURNS. One turn is equal to 360 degrees.

# Face the new 0 degrees
drivetrain.set_heading(90, DEGREES)
drivetrain.turn_to_heading(0, DEGREES)

set_rotation#

Rotation is how much the robot has turned, measured in degrees or turns. At the beginning of a project, the rotation value is set to 0 degrees. set_rotation changes the robot’s current rotation to a new value.

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

Usage:
drivetrain.set_rotation(rotation, units)

Παράμετροι

Περιγραφή

rotation

The rotation value, in degrees or turns, to set for the robot. This can be an integer or decimal (float).

units

Optional. The rotation unit: DEGREES (default) or TURNS. One turn is equal to 360 degrees.

# Spin counterclockwise two times
drivetrain.set_rotation(720, DEGREES)
drivetrain.turn_to_rotation(0, DEGREES)

set_turn_threshold#

set_turn_threshold sets how close the robot must get to a target angle before a turn is complete.

Ένα μικρότερο κατώφλι μπορεί να κάνει τις στροφές πιο ακριβείς, αλλά το ρομπότ μπορεί να χρειαστεί περισσότερο χρόνο για να ολοκληρώσει τις στροφές. Ένα μεγαλύτερο κατώφλι μπορεί να κάνει τις στροφές να ολοκληρωθούν νωρίτερα, αλλά μπορεί να είναι λιγότερο ακριβείς.

Usage:
drivetrain.set_turn_threshold(value)

Παράμετροι

Περιγραφή

value

The turn threshold, in degrees. This can be an integer or decimal (float). The default turn threshold is 1 degree.

# Set the turn threshold to 5 degrees
drivetrain.set_turn_threshold(5)

set_turn_constant#

set_turn_constant changes how strongly the robot corrects its turns.

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

Usage:
drivetrain.set_turn_constant(value)

Παράμετροι

Περιγραφή

value

The turn constant. This can be a decimal (float) from 0.1 to 4.0. The default is 1.0.

# Increase the turn constant to 2.0
drivetrain.set_turn_constant(2.0)

Αποκτητές#

heading#

A heading is the direction the robot is facing, measured in degrees. heading returns the robot’s current heading from 0 to 359 degrees.

Η αρχική κατεύθυνση του ρομπότ είναι 0 μοίρες.

Usage:
drivetrain.heading(units)

Παράμετροι

Περιγραφή

units

Optional. The unit to return heading in: DEGREES (default) or TURNS. One turn is equal to 360 degrees.

# Display the heading after turning
drivetrain.turn_for(RIGHT, 450, DEGREES)
brain.screen.print("Heading: ")
brain.screen.print(drivetrain.heading())

rotation#

Rotation is how much the robot has turned, measured in degrees or turns. At the beginning of a project, the rotation value is set to 0 degrees. rotation returns the robot’s current rotation.

Η δεξιά στροφή αυξάνει την περιστροφή και η αριστερά τη μειώνει. Για παράδειγμα, κάνοντας δύο πλήρεις στροφές προς τα δεξιά θα επιστρέψει μια περιστροφή 720 μοιρών.

Usage:
drivetrain.rotation(units)

Παράμετροι

Περιγραφή

units

Optional. The unit to return rotation in: DEGREES (default) or TURNS. One turn is equal to 360 degrees.

# Display the rotation after turning
drivetrain.turn_for(RIGHT, 450, DEGREES)
brain.screen.print("Rotation: ")
brain.screen.print(drivetrain.rotation())

velocity#

velocity returns how fast the robot is driving.

It can return velocity as a percentage from -100% to 100%, in RPM from -127 rpm to 127 rpm, or in VelocityUnits.DPS. A positive value means the robot is driving forward. A negative value means the robot is driving in reverse.

Usage:
drivetrain.velocity(units)

Παράμετροι

Περιγραφή

units

Optional. The unit to return velocity in: PERCENT (default), RPM (rotations per minute), or VelocityUnits.DPS (degrees per second).

current#

current returns how much electrical current the drivetrain is using, measured in amps (amperes). Current is the amount of electricity flowing through the drivetrain.

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

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

Usage:
drivetrain.current(units)

Παράμετροι

Περιγραφή

units

Optional. The unit to return current in: CurrentUnits.AMP (amps, default).

is_moving#

is_moving returns whether the robot is moving, as a Boolean value. This can be used to control the timing of other behaviors based on the robot’s movement.

  • True — The robot is moving.

  • False — The robot is not moving.

This method works together with the following Drivetrain methods that have the wait parameter: drive_for, turn_for, turn_to_heading, and turn_to_rotation.

Usage:
drivetrain.is_moving()

Παράμετροι

Περιγραφή

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

is_done#

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

  • True — The robot is finished moving.

  • False — The robot is still moving.

This method works together with the following Drivetrain methods that have the wait parameter: drive_for, turn_for, turn_to_heading, and turn_to_rotation.

Usage:
drivetrain.is_done()

Παράμετροι

Περιγραφή

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

is_turning#

is_turning returns whether the robot is turning, as a Boolean value. This can be used to control the timing of other behaviors based on the robot’s movement.

  • True — The robot is turning.

  • False — The robot is not turning.

This method works together with the following Drivetrain methods that have the wait parameter: turn_for, turn_to_heading, and turn_to_rotation.

Usage:
drivetrain.is_turning()

Παράμετροι

Περιγραφή

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

power#

power returns how much power the drivetrain is using, measured in watts. Power shows how quickly the drivetrain is using energy.

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

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

Usage:
drivetrain.power()

Παράμετροι

Περιγραφή

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

torque#

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

torque returns how much torque the drivetrain is using, measured in Newton-meters (Nm) or inch-pounds (InLb).

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

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

Usage:
drivetrain.torque(units)

Παράμετροι

Περιγραφή

units

Optional. The unit to return torque in: TorqueUnits.NM (newton meters, default) or TorqueUnits.INLB (inch pounds).

efficiency#

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

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

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

Usage:
drivetrain.efficiency()

Παράμετροι

Περιγραφή

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

temperature#

temperature returns the average temperature of the drivetrain in the selected temperature unit.

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

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

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

Usage:
drivetrain.temperature(units)

Παράμετροι

Περιγραφή

units

Optional. The unit to return temperature in: TemperatureUnits.CELSIUS (default) or TemperatureUnits.FAHRENHEIT.

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

Constructors are used to create DriveTrain and SmartDrive objects in code. This is useful when configuring a drivetrain without using the Devices window.

At least two Motor or MotorGroup objects must be created before creating a drivetrain.

DriveTrain#

DriveTrain creates a drivetrain without an Inertial Sensor or Gyro Sensor.

Usage:
DriveTrain(lm, rm, wheelTravel, trackWidth, wheelBase, units, externalGearRatio)

Παράμετρος

Περιγραφή

lm

Ο αριστερός κινητήρας ή ομάδα κινητήρων.

rm

Ο δεξιός κινητήρας ή ομάδα κινητήρων.

wheelTravel

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

trackWidth

Προαιρετικό. Το πλάτος μεταξύ του αριστερού και του δεξιού τροχού. Η προεπιλογή είναι 320 χιλιοστά.

wheelBase

Προαιρετικά. Η απόσταση μεταξύ των μπροστινών και των πίσω τροχών. Η προεπιλογή είναι 320 χιλιοστά.

units

Optional. The unit for wheelTravel, trackWidth, and wheelBase: MM (default), INCHES, or DistanceUnits.CM (centimeters).

externalGearRatio

Optional. The gear ratio used to adjust drive distances if gears are used. This can be an integer or decimal (float). The default is 1.0.

# Create left and right drive motor objects
left_drive_smart = Motor(Ports.PORT1, 1.0, False)
right_drive_smart = Motor(Ports.PORT2, 1.0, True)

'''
Create a Drivetrain with the following values:
wheelTravel: 200
trackWidth: 173
wheelBase: 76
units: MM
externalGearRatio: 1
'''
drivetrain = DriveTrain(left_drive_smart, right_drive_smart, 200, 173, 76, MM, 1)

# Create two motor group objects for left and right motors
left_motor_a = Motor(Ports.PORT1, 1.0, False)
left_motor_b = Motor(Ports.PORT2, 1.0, False)
left_drive_smart = MotorGroup(left_motor_a, left_motor_b)

right_motor_a = Motor(Ports.PORT3, 1.0, True)
right_motor_b = Motor(Ports.PORT4, 1.0, True)
right_drive_smart = MotorGroup(right_motor_a, right_motor_b)

'''
Create a Drivetrain with the following values:
wheelTravel: 200
trackWidth: 173
wheelBase: 76
units: MM
externalGearRatio: 1
'''
drivetrain = DriveTrain(left_drive_smart, right_drive_smart, 200, 173, 76, MM, 1)

SmartDrive#

SmartDrive creates a drivetrain configured with an Inertial Sensor or Gyro Sensor.

Usage:
SmartDrive(lm, rm, g, wheelTravel, trackWidth, wheelBase, units, externalGearRatio)

Παράμετρος

Περιγραφή

lm

Ο αριστερός κινητήρας ή ομάδα κινητήρων.

rm

Ο δεξιός κινητήρας ή ομάδα κινητήρων.

g

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

wheelTravel

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

trackWidth

Προαιρετικό. Το πλάτος μεταξύ του αριστερού και του δεξιού τροχού. Η προεπιλογή είναι 320 χιλιοστά.

wheelBase

Προαιρετικά. Η απόσταση μεταξύ των μπροστινών και των πίσω τροχών. Η προεπιλογή είναι 320 χιλιοστά.

units

Optional. The unit for wheelTravel, trackWidth, and wheelBase: MM (millimeters, default) or INCHES.

externalGearRatio

Optional. The gear ratio used to adjust drive distances if gears are used. This can be an integer or decimal (float). The default is 1.0.

# Create the Inertial Sensor
brain_inertial = Inertial()

# Make left and right drive motors
left_drive_smart = Motor(Ports.PORT1, 1.0, False)
right_drive_smart = Motor(Ports.PORT6, 1.0, True)

# Create a SmartDrive object with wheelTravel 200
drivetrain = SmartDrive(left_drive_smart, right_drive_smart, brain_inertial, 200)

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

# Create the Inertial Sensor
brain_inertial = Inertial()

# Create two motor groups for left and right motors
left_motor_a = Motor(Ports.PORT1, 1.0, False)
left_motor_b = Motor(Ports.PORT2, 1.0, False)
left_drive_smart = MotorGroup(left_motor_a, left_motor_b)

right_motor_a = Motor(Ports.PORT5, 1.0, True)
right_motor_b = Motor(Ports.PORT6, 1.0, True)
right_drive_smart = MotorGroup(right_motor_a, right_motor_b)

# Create a SmartDrive object with wheelTravel 200 mm
drivetrain = SmartDrive(left_drive_smart, right_drive_smart, brain_inertial, 200)