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

Εισαγωγή#

Το σύστημα μετάδοσης κίνησης περιλαμβάνει τροχούς και κινητήρες που ελέγχουν τον τρόπο με τον οποίο το ρομπότ κινείται και περιστρέφεται. Τα συστήματα μετάδοσης κίνησης μπορούν να βρεθούν σε εκδόσεις όπως το Code Base 2.0, το Super Car ή σε ένα προσαρμοσμένο ρομπότ.

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

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

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

  • drive — Moves the robot forward or reverse forever.

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

  • drive_until — Moves the robot forward until the Eye Sensor detects an object or the robot detects a crash.

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

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

  • 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 long 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.

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

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

  • get_rotation — Returns the robot’s current rotation.

  • get_velocity — Returns how fast the robot is driving, as a percentage from -100% to 100%.

  • get_yaw — Returns the robot’s current yaw.

  • get_roll — Returns the robot’s current roll.

  • get_pitch — Returns the robot’s current pitch.

  • get_crashed — Returns whether the robot has detected a crash, as a Boolean value.

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

Ενέργειες#

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)

Παράμετροι

Περιγραφή

direction

The direction the robot moves: FORWARD or REVERSE.

# Build Used: Code Base 2.0
def main():
    # Drive forward then stop
    drivetrain.drive(FORWARD)
    wait(2, SECONDS)
    drivetrain.stop()

# Start threads — Do not delete
start_thread(main)

drive_for#

drive_for moves the robot forward or reverse for a specific distance.

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

Παράμετροι

Περιγραφή

direction

The direction the robot moves: FORWARD or REVERSE.

distance

Η απόσταση που διανύει το ρομπότ. Αυτή μπορεί να είναι ακέραια ή δεκαδική.

units

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

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.

# Build Used: Code Base 2.0
def main():
    # Drive back and forth
    drivetrain.drive_for(FORWARD, 100, MM)
    drivetrain.drive_for(REVERSE, 4, INCHES)
    

# Start threads — Do not delete
start_thread(main)

drive_until#

drive_until moves the robot forward until the Eye Sensor detects an object or the robot detects a crash.

Usage:
drivetrain.drive_until(condition, wait)

Παράμετροι

Περιγραφή

condition

The condition that stops the robot: OBJECT or CRASH.

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.

# Build Used: Code Base 2.0
def main():
    # Turn right after a crash
    drivetrain.drive_until(CRASH)
    drivetrain.turn_for(RIGHT, 90)

# Start threads — Do not delete
start_thread(main)

turn#

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

Usage:
drivetrain.turn(direction)

Παράμετροι

Περιγραφή

direction

The direction the robot turns: LEFT or RIGHT.

# Build Used: Code Base 2.0
def main():
    # Turn right and left, then stop
    drivetrain.turn(RIGHT)
    wait(2, SECONDS)
    drivetrain.turn(LEFT)
    wait(2, SECONDS)
    drivetrain.stop()

# Start threads — Do not delete
start_thread(main)

turn_for#

turn_for turns the robot left or right for a specific number of degrees. The turn is relative to the current position of the robot.

Usage:
drivetrain.turn_for(direction, angle, wait)

Παράμετροι

Περιγραφή

direction

The direction the robot turns: LEFT or RIGHT.

angle

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

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.

# Build Used: Code Base 2.0
def main():
    # Turn right then left
    drivetrain.turn_for(RIGHT, 90)
    drivetrain.turn_for(LEFT, 90)

# Start threads — Do not delete
start_thread(main)

turn_to_heading#

A heading is the direction the robot’s brain 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 μοίρες.

Ένας κώδικας VEX GO Base 2.0 που δείχνει τις κατευθύνσεις κατεύθυνσης: 0 μοίρες προς τα εμπρός, 90 μοίρες δεξιά, 180 μοίρες προς τα πίσω και 270 μοίρες αριστερά.

Usage:
drivetrain.turn_to_heading(angle, wait)

Παράμετροι

Περιγραφή

angle

Η κατεύθυνση προς την οποία πρέπει να στραφεί το ρομπότ ως ακέραιος αριθμός, από -359 έως 359 μοίρες.

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.

# Build Used: Code Base 2.0
def main():
    # Turn to face the cardinal directions
    drivetrain.turn_to_heading(90)
    wait(1, SECONDS)
    drivetrain.turn_to_heading(180)
    wait(1, SECONDS)
    drivetrain.turn_to_heading(270)
    wait(1, SECONDS)
    drivetrain.turn_to_heading(0)

# Start threads — Do not delete
start_thread(main)

turn_to_rotation#

turn_to_rotation turns the robot to a specific rotation.

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

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

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

Ένας κώδικας VEX GO Base 2.0 που δείχνει βέλη που περιστρέφονται δεξιά και αριστερά. Το αριστερό βέλος δείχνει "μείον" και το δεξί βέλος δείχνει "συν".

Usage:
drivetrain.turn_to_rotation(angle, wait)

Παράμετροι

Περιγραφή

angle

Η τιμή περιστροφής, σε μοίρες, στην οποία θα στραφεί το ρομπότ. Αυτή μπορεί να είναι ακέραιος αριθμός.

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.

# Build Used: Code Base 2.0
def main():
    # Make one full turn to the right
    drivetrain.turn_to_rotation(360)
    # Make another full turn to the right
    drivetrain.turn_to_rotation(720)
    # Make one full turn to the left, returning to 360 degrees
    drivetrain.turn_to_rotation(360)
# Start threads — Do not delete
start_thread(main)

stop#

stop stops the robot’s movement.

Usage:
drivetrain.stop()

Παράμετροι

Περιγραφή

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

# Build Used: Code Base 2.0
def main():
    # Drive forward then stop
    drivetrain.drive(FORWARD)
    wait(2, SECONDS)
    drivetrain.stop()

# Start threads — Do not delete
start_thread(main)

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

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)

Παράμετροι

Περιγραφή

velocity

Η ταχύτητα οδήγησης κυμαίνεται από 0% έως 100%.

# Build Used: Code Base 2.0
def main():
    # Drive at different velocities
    drivetrain.drive_for(FORWARD, 100, MM)
    wait(1, SECONDS)
    # Drive slow
    drivetrain.set_drive_velocity(20)
    drivetrain.drive_for(FORWARD, 100, MM)
    wait(1, SECONDS)
    # Drive fast
    drivetrain.set_drive_velocity(100)
    drivetrain.drive_for(FORWARD, 100, MM)

# Start threads — Do not delete
start_thread(main)

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)

Παράμετροι

Περιγραφή

velocity

Η ταχύτητα περιστροφής κυμαίνεται από 0% έως 100%.

# Build Used: Code Base 2.0
def main():
    # Turn at different velocities
    drivetrain.turn_for(RIGHT, 180)
    wait(1, SECONDS)
    # Turn fast
    drivetrain.set_turn_velocity(100)
    drivetrain.turn_for(RIGHT, 180)

# Start threads — Do not delete
start_thread(main)

set_stopping#

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

Usage:
drivetrain.set_stopping(brake)

Παράμετροι

Περιγραφή

brake

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.

# Build Used: Code Base 2.0
def main():
    # Drive, then coast to a stop
    drivetrain.set_drive_velocity(100)
    drivetrain.set_stopping(COAST)
    drivetrain.drive(FORWARD)
    wait(2, SECONDS)
    drivetrain.stop()

# Start threads — Do not delete
start_thread(main)

set_timeout#

set_timeout sets how long 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

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

units

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

# Build Used: Code Base 2.0
def main():
    # Drive as far as possible for 1 second before turning right
    drivetrain.set_timeout(1, SECONDS)
    drivetrain.drive_for(FORWARD, 25, INCHES)
    drivetrain.turn_for(RIGHT, 90)

# Start threads — Do not delete
start_thread(main)

set_heading#

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

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

Usage:
drivetrain.set_heading(value)

Παράμετροι

Περιγραφή

value

Η τιμή κατεύθυνσης, σε μοίρες, που θα οριστεί για το ρομπότ. Αυτή μπορεί να είναι ένας ακέραιος αριθμός από 0 έως 359.

# Build Used: Code Base 2.0
def main():
    # Face the new 0 degree heading
    drivetrain.set_heading(90)
    drivetrain.turn_to_heading(0)

# Start threads — Do not delete
start_thread(main)

set_rotation#

Rotation is how much the robot has turned, measured in degrees. 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(value)

Παράμετροι

Περιγραφή

value

Η τιμή περιστροφής, σε μοίρες, που θα οριστεί για το ρομπότ. Αυτή μπορεί να είναι ακέραιος αριθμός.

# Build Used: Code Base 2.0
def main():
    # Spin counterclockwise two times
    drivetrain.set_rotation(720)
    drivetrain.turn_to_rotation(0)

# Start threads — Do not delete
start_thread(main)

Αποκτητές#

get_heading#

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

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

Ένας εγκέφαλος VEX GO που δείχνει κατευθύνσεις κατεύθυνσης: 0 μοίρες μπροστά, 90 μοίρες δεξιά, 180 μοίρες πίσω και 270 μοίρες αριστερά.

Usage:
drivetrain.get_heading()

Παράμετροι

Περιγραφή

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

# Build Used: Code Base 2.0
def main():
    # Display the heading while turning
    monitor_sensor("drivetrain.get_heading")
    drivetrain.turn_for(RIGHT, 450)


# Start threads — Do not delete
start_thread(main)

get_rotation#

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

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

Ένας κώδικας VEX GO Base 2.0 που δείχνει βέλη που περιστρέφονται δεξιά και αριστερά. Το αριστερό βέλος δείχνει "μείον" και το δεξί βέλος δείχνει "συν".

Usage:
drivetrain.get_rotation()

Παράμετροι

Περιγραφή

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

# Build Used: Code Base 2.0
def main():
    # Display the rotation while turning
    monitor_sensor("drivetrain.get_rotation")
    drivetrain.turn_for(RIGHT, 450)


# Start threads — Do not delete
start_thread(main)

get_velocity#

get_velocity returns how fast the robot is driving, as a percentage from -100% to 100%.

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

Usage:
drivetrain.get_velocity()

Παράμετροι

Περιγραφή

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

# Build Used: Code Base 2.0
def main():
    # Display the velocity of the robot before and while moving
    console.print("Start: ")
    console.print(drivetrain.get_velocity())
    console.new_line()
    drivetrain.drive(FORWARD)
    wait(0.5, SECONDS)
    console.print("Moving: ")
    console.print(drivetrain.get_velocity())
    drivetrain.stop()


# Start threads — Do not delete
start_thread(main)

get_yaw#

Yaw is how much the robot has turned left or right from its starting position, measured in degrees. get_yaw returns the robot’s current yaw value.

Η δεξιά στροφή αυξάνει την τιμή της εκτροπής, ενώ η αριστερά τη μειώνει.

Usage:
drivetrain.get_yaw()

Παράμετροι

Περιγραφή

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

# Build Used: Super Code Base 2.0
def main():
    # Change the LED color based on the yaw while
    # moving the robot by hand
    monitor_sensor("drivetrain.get_yaw")
    while True:
        if drivetrain.get_yaw() > 0:
            bumper.set_color(GREEN)
        elif drivetrain.get_yaw() < 0:
            bumper.set_color(RED)
        else:
            bumper.set_color(NONE)

# Start threads — Do not delete
start_thread(main)

get_roll#

Roll is how much the robot tilts to the left or right, measured in degrees. get_roll returns the robot’s current roll value.

Με τον Εγκέφαλο στραμμένο προς τα εμπρός, η κλίση προς τα αριστερά αυξάνει την αξία της ζαριάς και η κλίση προς τα δεξιά τη μειώνει.

Usage:
drivetrain.get_roll()

Παράμετροι

Περιγραφή

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

# Build Used: Super Code Base 2.0
def main():
    # Change the LED color based on the roll while
    # moving the robot by hand
    monitor_sensor("drivetrain.get_roll")
    while True:
        if drivetrain.get_roll() > 0:
            bumper.set_color(GREEN)
        elif drivetrain.get_roll() < 0:
            bumper.set_color(RED)
        else:
            bumper.set_color(NONE)

# Start threads — Do not delete
start_thread(main)

get_pitch#

Pitch is how much the robot tilts forward or backward, measured in degrees. get_pitch returns the robot’s current pitch value.

Με τον εγκέφαλο στραμμένο προς τα εμπρός, η κλίση προς τα εμπρός αυξάνει την τιμή του τόνου, ενώ η κλίση προς τα πίσω τη μειώνει.

Usage:
drivetrain.get_pitch()

Παράμετροι

Περιγραφή

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

# Build Used: Super Code Base 2.0
def main():
    # Change the LED color based on the pitch while
    # moving the robot by hand
    monitor_sensor("drivetrain.get_pitch")
    while True:
        if drivetrain.get_pitch() > 0:
            bumper.set_color(GREEN)
        elif drivetrain.get_pitch() < 0:
            bumper.set_color(RED)
        else:
            bumper.set_color(NONE)

# Start threads — Do not delete
start_thread(main)

get_crashed#

get_crashed returns whether the robot has detected a crash, as a Boolean value.

  • True — A crash has been detected.

  • False — A crash has not been detected.

Usage:
drivetrain.get_crashed()

Παράμετροι

Περιγραφή

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

# Build Used: Super Code Base 2.0
def main():
    # Drive until a crash
    drivetrain.drive(FORWARD)
    while not drivetrain.get_crashed():
        wait(50, MSEC)
    drivetrain.stop()
    drivetrain.turn_for(RIGHT, 90)

# Start threads — Do not delete
start_thread(main)

is_stopped#

is_stopped 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, drive_until, turn_for, turn_to_heading, and turn_to_rotation.

Usage:
drivetrain.is_stopped()

Παράμετροι

Περιγραφή

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

# Build Used: Code Base 2.0
def main():
    # Turn when the drivetrain is done moving forward
    drivetrain.drive_for(FORWARD, 100, MM, wait=False)
    wait(0.25, SECONDS)
    while True:
        if drivetrain.is_stopped():
            drivetrain.turn_for(RIGHT, 180)
            break
        else:
            console.print("Still moving...")
            wait(0.1, SECONDS)
            console.clear()

# Start threads — Do not delete
start_thread(main)