Python ειδικά για ρομπότ#

Εισαγωγή#

Το Hero Bot, Flex, περιλαμβάνει έναν κινητήρα με νύχια, έναν κινητήρα με βραχίονα, έναν αισθητήρα όρασης AI, έναν αισθητήρα απόστασης και έναν αισθητήρα συστήματος εντοπισμού θέσης παιχνιδιού (GPS).

Όλες οι τυπικές μέθοδοι VR VEXcode είναι διαθέσιμες για χρήση στην παιδική χαρά V5 26-27 Override.

Παρακάτω είναι μια λίστα με όλες τις διαθέσιμες μεθόδους ειδικά για ρομπότ:

Σύστημα μετάδοσης κίνησης – Μετακινήστε και περιστρέψτε το ρομπότ.

  • Ενέργειες

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

    • turn_to_rotation — Turns the robot to a specific rotation.

    • stop — Stops the robot’s movement.

  • Μεταλλαγμένοι

  • Αποκτητές

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

    • rotation — Returns the robot’s current rotation.

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

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

    • velocity — Returns how fast the robot is driving.

Κίνηση – Μετακίνηση και παρακολούθηση των κινητήρων του ρομπότ.

  • Ενέργειες

    • spin — Spins a motor forward or reverse forever.

    • spin_for — Spins a motor for a specific distance.

    • spin_to_position — Spins a motor to a specific position.

    • stop — Stops a motor from spinning.

  • Μεταλλαγμένοι

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

    • set_velocity — Tells a motor how fast to spin.

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

  • Αποκτητές

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

    • is_spinning — Returns whether the motor is spinning, as a Boolean value.

    • position — Returns the motor’s current position.

    • velocity — Returns how fast the motor is spinning.

AI Vision – Καταγραφή και ανάλυση αντικειμένων χρησιμοποιώντας τον αισθητήρα AI Vision.

  • Αποκτητές

    • take_snapshot – Returns a tuple of detected objects for a specific signature.

  • Σκηνικά θέατρου

    • .width – Width of the detected object in pixels.

    • .height – Height of the detected object in pixels.

    • .centerX – X position of the object’s center in pixels.

    • .centerY – Y position of the object’s center in pixels.

    • .originX – X position of the object’s top-left corner in pixels.

    • .originY – Y position of the object’s top-left corner in pixels.

    • .id – Classification ID of the detected object.

Κονσόλα – Εκτύπωση στην Κονσόλα και παρακολούθηση τιμών.

Αισθητήρες – Χρησιμοποιήστε τους διάφορους αισθητήρες του ρομπότ.

  • Απόσταση

    • found_object – Returns whether the Distance Sensor detects an object within range.

    • object_distance – Returns the distance between the Distance Sensor and the nearest detected object.

  • GPS

    • x_position – Returns the current x-coordinate of the GPS Sensor on the field.

    • y_position – Returns the current y-coordinate of the GPS Sensor on the field.

    • heading – Returns the heading the robot is currently facing based on the GPS Sensor.

Τα παραδείγματα σε αυτήν τη σελίδα χρησιμοποιούν την Τοποθεσία Εκκίνησης C από τη Λίστα Ελέγχου Πριν τον Αγώνα του Playground.

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

Το σύστημα μετάδοσης κίνησης ελέγχει τον τρόπο με τον οποίο το ρομπότ εικονικής πραγματικότητας (VR) κινείται και στρίβει. Το σύστημα μετάδοσης κίνησης μπορεί να κινείται προς τα εμπρός ή προς τα πίσω, να στρίβει αριστερά ή δεξιά, να στρίβει προς τις κατευθύνσεις και να παρακολουθεί την περιστροφή του.

Ενέργειες#

οδηγώ#

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.

def main():
    # Raise the Arm, drive to the Goal, release the Pin
    arm_motor.spin_for(FORWARD, 300, DEGREES)
    drivetrain.drive(FORWARD)
    wait(0.5, SECONDS)
    drivetrain.stop()
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

μονάδα_δίσκου#

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, 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) or MM (millimeters).

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.

def main():
    # Raise the Arm, drive to the Goal, release the Pin
    arm_motor.spin_for(FORWARD, 300, DEGREES)
    drivetrain.drive_for(FORWARD, 10, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

σειρά#

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)

Παράμετροι

Περιγραφή

direction

The direction the robot turns: LEFT or RIGHT.

def main():
    # Score a Pin in a Neutral Goal
    drivetrain.turn(LEFT)
    wait(0.78, SECONDS)
    drivetrain.stop()
    arm_motor.spin_for(FORWARD, 800, DEGREES)
    drivetrain.drive_for(FORWARD, 25, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

στροφή_για#

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. The project will wait until the robot is done turning before the next line of code runs.

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

Παράμετροι

Περιγραφή

direction

The direction the robot turns: LEFT or RIGHT.

angle

The number of degrees the robot turns. This can be an integer or decimal (float).

units

Optional. The angle unit: DEGREES (default).

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.

def main():
    # Score a Pin in a Neutral Goal
    drivetrain.turn_for(LEFT, 110, DEGREES)
    arm_motor.spin_for(FORWARD, 800, DEGREES)
    drivetrain.drive_for(FORWARD, 25, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

στροφή_προς_την_κατεύθυνση#

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(heading, units, wait)

Παράμετροι

Περιγραφή

heading

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

units

Optional. The angle unit: DEGREES (default).

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.

def main():
    # Score a Pin in a Neutral Goal
    drivetrain.turn_to_heading(-110, DEGREES)
    arm_motor.spin_for(FORWARD, 800, DEGREES)
    drivetrain.drive_for(FORWARD, 25, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

στροφή_σε_περιστροφή#

turn_to_rotation turns the robot to a specific rotation.

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

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

Usage:
drivetrain.turn_to_rotation(rotation, units, wait)

Παράμετροι

Περιγραφή

rotation

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

units

Optional. The angle unit: DEGREES (default).

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.

def main():
    # Score a Pin in a Neutral Goal
    drivetrain.turn_to_rotation(-110, DEGREES)
    arm_motor.spin_for(FORWARD, 800, DEGREES)
    drivetrain.drive_for(FORWARD, 25, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

στάση#

stop stops the robot’s movement.

Usage:
drivetrain.stop()

Παράμετροι

Περιγραφή

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

def main():
    # Score a Pin in a Neutral Goal
    drivetrain.turn(LEFT)
    wait(0.78, SECONDS)
    drivetrain.stop()
    arm_motor.spin_for(FORWARD, 800, DEGREES)
    drivetrain.drive_for(FORWARD, 25, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

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

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

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

units

Optional. The angle unit: DEGREES (default).

def main():
    # Make facing the Neutral Goal the new heading
    drivetrain.set_heading(110, DEGREES)
    drivetrain.turn_to_heading(0, DEGREES)

# VR threads — Do not delete
vr_thread(main)

set_rotation#

Rotation is how much the robot has turned, measured in degrees. set_rotation changes the robot’s current rotation to a new value.

Usage:
drivetrain.set_rotation(rotation, units)

Παράμετροι

Περιγραφή

rotation

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

units

Optional. The angle unit: DEGREES (default).

def main():
    # Make facing the Neutral Goal the new rotation
    drivetrain.set_rotation(110, DEGREES)
    drivetrain.turn_to_rotation(0, DEGREES)

# VR threads — Do not delete
vr_thread(main)

set_timeout#

set_timeout sets how many seconds 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(time, units)

Παράμετροι

Περιγραφή

time

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

units

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

def main():
    # Turn to face the Neutral Goal
    drivetrain.set_timeout(0.8, SECONDS)
    drivetrain.turn_for(LEFT, 180, DEGREES)

# VR threads — Do not delete
vr_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, units)

Παράμετροι

Περιγραφή

velocity

The velocity to drive with from 0% to 100%. This can be an integer or decimal (float).

units

Optional. The velocity unit: PERCENT (default).

def main():
    # Score a Pin in a Neutral Goal
    drivetrain.turn_for(LEFT, 110, DEGREES)
    arm_motor.spin_for(FORWARD, 800, DEGREES)
    drivetrain.set_drive_velocity(100, PERCENT)
    drivetrain.drive_for(FORWARD, 25, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

ορισμός_ταχύτητας_στροφής#

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%. This can be an integer or decimal (float).

units

Optional. The velocity unit: PERCENT (default).

def main():
    # Turn to face the Neutral Goal faster
    drivetrain.set_turn_velocity(100, PERCENT)
    drivetrain.turn_for(LEFT, 110, DEGREES)

# VR threads — Do not delete
vr_thread(main)

Αποκτητές#

επικεφαλίδα#

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

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

Usage:
drivetrain.heading(units)

Παράμετροι

Περιγραφή

units

Optional. The heading unit: DEGREES (default).

def main():
    # Turn to the Goal, then show heading
    drivetrain.turn_for(LEFT, 110, DEGREES)
    brain.screen.print("Heading: ")
    brain.screen.print(drivetrain.heading(DEGREES))

# VR threads — Do not delete
vr_thread(main)

περιστροφή#

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 returns the robot’s current rotation.

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

Usage:
drivetrain.rotation(units)

Παράμετροι

Περιγραφή

units

Optional. The rotation unit: DEGREES (default).

def main():
    # Spin to find a Pin, then show rotation
    drivetrain.turn_for(RIGHT, 450, DEGREES)
    brain.screen.print("Rotation: ")
    brain.screen.print(drivetrain.rotation(DEGREES))

# VR threads — Do not delete
vr_thread(main)

είναι_ολοκληρωμένο#

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()

Παράμετροι

Περιγραφή

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

def main():
    # Score a Pin in a Neutral Goal
    drivetrain.turn_for(LEFT, 110, DEGREES)
    arm_motor.spin_for(FORWARD, 800, DEGREES)
    drivetrain.drive_for(FORWARD, 25, INCHES, wait=False)
    wait(0.5, SECONDS)
    while not drivetrain.is_done():
        wait(5, MSEC)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

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.

Usage:
drivetrain.is_moving()

Παράμετροι

Περιγραφή

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

def main():
    # Raise the Arm once stopped near the Goal
    drivetrain.turn_for(LEFT, 110, DEGREES)
    drivetrain.drive_for(FORWARD, 25, INCHES, wait=False)
    wait (0.5, SEC)
    while drivetrain.is_moving():
        wait(5, MSEC)
    arm_motor.spin_for(FORWARD, 800, DEGREES)

# VR threads — Do not delete
vr_thread(main)

ταχύτητα#

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

Usage:
drivetrain.velocity(units)

Παράμετροι

Περιγραφή

units

Optional. The velocity unit: PERCENT (default).

def main():
    # Show speed while driving to the Goal
    drivetrain.drive_for(FORWARD, 150, MM)
    brain.screen.print("Velocity: ")
    brain.screen.print(drivetrain.velocity(PERCENT))

# VR threads — Do not delete
vr_thread(main)

Κίνηση#

Το Flex χρησιμοποιεί τον κινητήρα του βραχίονα για να ανυψώσει και να κατεβάσει τον βραχίονα και τον κινητήρα της δαγκάνας για να ανοίξει και να κλείσει τη δαγκάνα.

Κάθε κινητήρας έχει τη δική του συμπεριφορά κατεύθυνσης. Οι περιγραφές κατεύθυνσης εξηγούν πώς κάθε κατεύθυνση κινεί τον κινητήρα στο Flex.

Ενέργειες#

γνέθω#

spin spins a motor in one of two directions forever. The motor will continue to spin until it is given another action, like spinning in a different direction or stopping.

Χρήση:
Ένα από τα δύο διαθέσιμα αντικείμενα κινητήρα μπορεί να χρησιμοποιηθεί με αυτήν τη μέθοδο, όπως φαίνεται παρακάτω:

μοτέρ

Εντολή

arm_motor

arm_motor.spin(direction) — Arm Motor

claw_motor

claw_motor.spin(direction) — Claw Motor

Παράμετροι

Περιγραφή

direction

The direction the motor spins:

  • FORWARD — Moves the Arm Motor up or closes the Claw Motor.
  • REVERSE — Moves the Arm Motor down or opens the Claw Motor.

def main():
    # Raise the Arm before driving toward a Pin
    arm_motor.spin(FORWARD)
    wait(1, SECONDS)
    arm_motor.stop()

# VR threads — Do not delete
vr_thread(main)

περιστροφή_για#

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

Χρήση:
Ένα από τα δύο διαθέσιμα αντικείμενα κινητήρα μπορεί να χρησιμοποιηθεί με αυτήν τη μέθοδο, όπως φαίνεται παρακάτω:

μοτέρ

Εντολή

arm_motor

arm_motor.spin_for(direction, distance, units, wait) — Arm Motor

claw_motor

claw_motor.spin_for(direction, distance, units, wait) — Claw Motor

Παράμετροι

Περιγραφή

direction

The direction the motor spins:

  • FORWARD — Moves the Arm Motor up or closes the Claw Motor.
  • REVERSE — Moves the Arm Motor down or opens the Claw Motor.

distance

The distance the motor spins. DEGREES use integers. TURNS can use integers or decimals.

units

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

wait

Optional.

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

def main():
    # Raise the Arm to carry the Pin to the Goal
    arm_motor.spin_for(FORWARD, 800, DEGREES)

# VR threads — Do not delete
vr_thread(main)

περιστροφή_σε_θέση#

spin_to_position spins a motor to a specific position.

A motor’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 Arm Motor’s position is set to 0 degrees. The Claw Motor is the exception — it starts at 467 degrees (fully closed). The motor position can also be set using the set_position method.

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

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

Χρήση:
Ένα από τα δύο διαθέσιμα αντικείμενα κινητήρα μπορεί να χρησιμοποιηθεί με αυτήν τη μέθοδο, όπως φαίνεται παρακάτω:

μοτέρ

Εντολή

arm_motor

arm_motor.spin_to_position(angle, units, wait=True) — Arm Motor

claw_motor

claw_motor.spin_to_position(angle, units, wait=True) — Claw Motor

Παράμετροι

Περιγραφή

angle

The position value the motor will spin to. DEGREES use integers. TURNS can use integers or decimals.

units

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

wait

Optional.

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

def main():
    # Raise the Arm, then release the Pin
    arm_motor.spin_to_position(800, DEGREES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

στάση#

stop stops a motor from spinning.

Χρήση:
Ένα από τα δύο διαθέσιμα αντικείμενα κινητήρα μπορεί να χρησιμοποιηθεί με αυτήν τη μέθοδο, όπως φαίνεται παρακάτω:

μοτέρ

Εντολή

arm_motor

arm_motor.stop() — Arm Motor

claw_motor

claw_motor.stop() — Claw Motor

Παράμετροι

Περιγραφή

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

def main():
    # Raise the Arm partway to hold the Pin
    arm_motor.spin(FORWARD)
    wait(1, SECONDS)
    arm_motor.stop()

# VR threads — Do not delete
vr_thread(main)

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

ορισμός_θέσης#

A motor’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’s current position to a new value.

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

Χρήση:
Ένα από τα δύο διαθέσιμα αντικείμενα κινητήρα μπορεί να χρησιμοποιηθεί με αυτήν τη μέθοδο, όπως φαίνεται παρακάτω:

μοτέρ

Εντολή

arm_motor

arm_motor.set_position(position, units) — Arm Motor

claw_motor

claw_motor.set_position(position, units) — Claw Motor

Παράμετροι

Περιγραφή

position

The position value to set for the motor. DEGREES use integers. TURNS can use integers or decimals.

units

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

def main():
    # Reset encoder, raise Arm, place Pin
    arm_motor.set_position(0, DEGREES)
    arm_motor.spin_to_position(800, DEGREES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

set_velocity#

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

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

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

Χρήση:
Ένα από τα δύο διαθέσιμα αντικείμενα κινητήρα μπορεί να χρησιμοποιηθεί με αυτήν τη μέθοδο, όπως φαίνεται παρακάτω:

μοτέρ

Εντολή

arm_motor

arm_motor.set_velocity(velocity, units) — Arm Motor

claw_motor

claw_motor.set_velocity(velocity, units) — Claw Motor

Παράμετροι

Περιγραφή

velocity

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

units

The velocity unit: PERCENT.

def main():
    # Raise the Arm fast to release the Pin
    arm_motor.set_velocity(100, PERCENT)
    arm_motor.spin_for(FORWARD, 800, DEGREES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

set_timeout#

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

Χρήση:
Ένα από τα δύο διαθέσιμα αντικείμενα κινητήρα μπορεί να χρησιμοποιηθεί με αυτήν τη μέθοδο, όπως φαίνεται παρακάτω:

μοτέρ

Εντολή

arm_motor

arm_motor.set_timeout(value, units) — Arm Motor

claw_motor

claw_motor.set_timeout(value, units) — Claw Motor

Παράμετροι

Περιγραφή

value

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

units

The time unit: SECONDS or MSEC (milliseconds).

def main():
    # Score a Pin in a Neutral Goal
    drivetrain.turn_for(LEFT, 110, DEGREES)
    arm_motor.set_timeout(1, SECONDS)
    arm_motor.spin_for(FORWARD, 1800, DEGREES)
    drivetrain.drive_for(FORWARD, 25, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

Αποκτητές#

είναι_ολοκληρωμένο#

is_done returns whether the motor 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 is finished moving.

  • False — The motor is still moving.

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

Χρήση:
Ένα από τα δύο διαθέσιμα αντικείμενα κινητήρα μπορεί να χρησιμοποιηθεί με αυτήν τη μέθοδο, όπως φαίνεται παρακάτω:

μοτέρ

Εντολή

arm_motor

arm_motor.is_done() — Arm Motor

claw_motor

claw_motor.is_done() — Claw Motor

Παράμετροι

Περιγραφή

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

def main():
    # Raise the Arm while driving to the Goal
    arm_motor.spin_to_position(800, DEGREES, wait=False)
    wait(0.1, SECONDS)
    while not arm_motor.is_done():
        drivetrain.drive(FORWARD)
        wait(5, MSEC)
    drivetrain.stop()

# VR threads — Do not delete
vr_thread(main)

περιστρέφεται#

is_spinning returns whether the motor 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 is spinning.

  • False — The motor is not spinning.

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

Χρήση:
Ένα από τα δύο διαθέσιμα αντικείμενα κινητήρα μπορεί να χρησιμοποιηθεί με αυτήν τη μέθοδο, όπως φαίνεται παρακάτω:

μοτέρ

Εντολή

arm_motor

arm_motor.is_spinning() — Arm Motor

claw_motor

claw_motor.is_spinning() — Claw Motor

Παράμετροι

Περιγραφή

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

def main():
    # Raise the Arm while driving to the Goal, then release the Pin
    arm_motor.spin_to_position(800, DEGREES, wait=False)
    wait(0.1, SECONDS)
    while arm_motor.is_spinning():
        drivetrain.drive_for(FORWARD, 25, MM)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

θέση#

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

Στην αρχή ενός έργου, η θέση του μοτέρ βραχίονα ορίζεται στις 0 μοίρες. Ο μοτέρ με δαγκάνα αποτελεί εξαίρεση — ξεκινά στις 467 μοίρες (πλήρως κλειστός). Εάν ο μοτέρ περιστραφεί μία πλήρη στροφή προς τα εμπρός, η θέση αυξάνεται. Εάν ο μοτέρ περιστραφεί προς την αντίθετη κατεύθυνση, η θέση μειώνεται.

Χρήση:
Ένα από τα δύο διαθέσιμα αντικείμενα κινητήρα μπορεί να χρησιμοποιηθεί με αυτήν τη μέθοδο, όπως φαίνεται παρακάτω:

μοτέρ

Εντολή

arm_motor

arm_motor.position(units) — Arm Motor

claw_motor

claw_motor.position(units) — Claw Motor

Παράμετροι

Περιγραφή

units

The unit to return the motor position in: DEGREES or TURNS.

def main():
    # Raise the Arm, then release the Pin
    while arm_motor.position(DEGREES) < 800:
        arm_motor.spin(FORWARD)
        wait(2, MSEC)
    arm_motor.stop()
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

ταχύτητα#

velocity returns how fast the motor is spinning.

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

Χρήση:
Ένα από τα δύο διαθέσιμα αντικείμενα κινητήρα μπορεί να χρησιμοποιηθεί με αυτήν τη μέθοδο, όπως φαίνεται παρακάτω:

μοτέρ

Εντολή

arm_motor

arm_motor.velocity(units) — Arm Motor

claw_motor

claw_motor.velocity(units) — Claw Motor

Παράμετροι

Περιγραφή

units

The velocity unit to return: PERCENT.

def main():
    # Show Arm Motor velocity while raising
    arm_motor.set_velocity(100, PERCENT)
    arm_motor.spin_to_position(800, DEGREES, wait=False)
    wait(0.2, SECONDS)
    brain.screen.print(arm_motor.velocity(PERCENT))

# VR threads — Do not delete
vr_thread(main)

Όραμα Τεχνητής Νοημοσύνης#

Αποκτητές#

λήψη_στιγμιότυπου#

take_snapshot filters data from the AI Vision Sensor frame to a single signature — a saved description of something the sensor can recognize, such as a game element on the field — and returns a tuple.

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

Usage:
ai_vision.take_snapshot(signature)

Παράμετροι

Περιγραφή

signature

Filters the dataset to only include data of the given signature. Available signatures are:

  • AiVision.ALL_AIOBJS - Detects all game elements.
  • GameElements.RED_BLUE_PIN - Detects RedBluePin game elements.
  • GameElements.BLUE_YELLOW_PIN - Detects BlueYellowPin game elements.
  • GameElements.RED_YELLOW_PIN - Detects RedYellowPin game elements.
  • GameElements.YELLOW_PIN - Detects YellowPin game elements.
  • GameElements.CUP - Detects Cup game elements.

def main():
    # Raise the Arm, drive to the Goal, release the Pin
    arm_motor.spin_for(FORWARD, 300, DEGREES)
    drivetrain.drive_for(FORWARD, 10, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

    drivetrain.turn_for(LEFT, 70, DEGREES)

    # Turn to face the Pin
    drivetrain.set_turn_velocity(30, PERCENT)
    while True:
        ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
        if ai_objects:
            if ai_objects[0].centerX < 140:
                drivetrain.turn(LEFT)
            elif ai_objects[0].centerX > 180:
                drivetrain.turn(RIGHT)
            else:
                drivetrain.stop()
                break

# VR threads — Do not delete
vr_thread(main)

Σκηνικά θέατρου#

There are seven properties that are included with each object stored in a tuple after take_snapshot is used.

All property values except .id describe the detected object’s position and size in the AI Vision Sensor’s view at the moment take_snapshot was used. These values are measured in pixels, based on the sensor’s 320 by 240 pixel resolution.

.πλάτος#

.width returns the width of the detected object in pixels, which is an integer between 1 and 320.

def main():
    # Raise the Arm, drive to the Goal, release the Pin
    arm_motor.spin_for(FORWARD, 300, DEGREES)
    drivetrain.drive_for(FORWARD, 10, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

    drivetrain.turn_for(LEFT, 70, DEGREES)

    # Approach the next Cup and Pin
    drivetrain.set_drive_velocity(30, PERCENT)
    while True:
        ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
        if ai_objects:
            if ai_objects[0].width > 140:
                drivetrain.stop()
                break
            else:
                drivetrain.drive(FORWARD)

# VR threads — Do not delete
vr_thread(main)

.ύψος#

.height returns the height of the detected object in pixels, which is an integer between 1 and 240.

def main():
    # Raise the Arm, drive to the Goal, release the Pin
    arm_motor.spin_for(FORWARD, 300, DEGREES)
    drivetrain.drive_for(FORWARD, 10, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

    drivetrain.turn_for(LEFT, 70, DEGREES)

    # Approach the next Cup and Pin
    drivetrain.set_drive_velocity(30, PERCENT)
    while True:
        ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
        if ai_objects:
            if ai_objects[0].height > 200:
                drivetrain.stop()
                break
            else:
                drivetrain.drive(FORWARD)

# VR threads — Do not delete
vr_thread(main)

.centerX#

.centerX returns the x-coordinate of the detected object’s center in pixels, which is an integer between 0 and 320.

def main():
    # Raise the Arm, drive to the Goal, release the Pin
    arm_motor.spin_for(FORWARD, 300, DEGREES)
    drivetrain.drive_for(FORWARD, 10, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

    drivetrain.turn_for(LEFT, 70, DEGREES)

    # Turn and approach the next Cup and Pin
    drivetrain.set_turn_velocity(30, PERCENT)
    while True:
        ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
        if ai_objects:
            if ai_objects[0].centerX < 140:
                drivetrain.turn_for(LEFT, 5, DEGREES)
            else: 
                drivetrain.drive_for(FORWARD, 25, INCHES)
                break

# VR threads — Do not delete
vr_thread(main)

.centerY#

.centerY returns the y-coordinate of the detected object’s center in pixels, which is an integer between 0 and 240.

def main():
    # Raise the Arm, drive to the Goal, release the Pin
    arm_motor.spin_for(FORWARD, 300, DEGREES)
    drivetrain.drive_for(FORWARD, 10, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

    drivetrain.turn_for(LEFT, 70, DEGREES)

    # Approach the next Cup and Pin
    drivetrain.set_drive_velocity(30, PERCENT)
    while True:
        ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
        if ai_objects:
            if ai_objects[0].centerY > 230:
                drivetrain.stop()
                break
            else:
                drivetrain.drive(FORWARD)

# VR threads — Do not delete
vr_thread(main)

.originX#

.originX returns the x-coordinate of the top-left corner of the detected object’s bounding box in pixels, which is an integer between 0 and 320.

def main():
    # Raise the Arm, drive to the Goal, release the Pin
    arm_motor.spin_for(FORWARD, 300, DEGREES)
    drivetrain.drive_for(FORWARD, 10, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

    drivetrain.turn_for(LEFT, 70, DEGREES)

    # Turn and approach the next Cup and Pin
    drivetrain.set_turn_velocity(30, PERCENT)
    while True:
        ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
        if ai_objects:
            if ai_objects[0].originX < 100:
                drivetrain.turn_for(LEFT, 5, DEGREES)
            else:
                drivetrain.drive_for(FORWARD, 25, INCHES)
                break

# VR threads — Do not delete
vr_thread(main)

.originY#

.originY returns the y-coordinate of the top-left corner of the detected object’s bounding box in pixels, which is an integer between 0 and 240.

def main():
    # Raise the Arm, drive to the Goal, release the Pin
    arm_motor.spin_for(FORWARD, 300, DEGREES)
    drivetrain.drive_for(FORWARD, 10, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

    drivetrain.turn_for(LEFT, 70, DEGREES)

    # Approach the next Cup and Pin
    drivetrain.set_drive_velocity(30, PERCENT)
    while True:
        ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
        if ai_objects:
            if ai_objects[0].originY > 140:
                drivetrain.stop()
                break
            else:
                drivetrain.drive(FORWARD)

# VR threads — Do not delete
vr_thread(main)

.ταυτότητα#

.id returns the ID of the detected AI Classification as an integer.

Ταξινόμηση Τεχνητής Νοημοσύνης

ταυτότητα

Υπογραφή

ΚόκκινοΜπλεΚαρφίτσα

0

GameElements.RED_BLUE_PIN

ΜπλεΚίτρινηΚαρφίτσα

1

GameElements.BLUE_YELLOW_PIN

ΚόκκινοΚίτρινοΚαρφίτσα

2

GameElements.RED_YELLOW_PIN

Κίτρινη καρφίτσα

3

GameElements.YELLOW_PIN

Φλιτζάνι

4

GameElements.CUP

def main():
    # Raise the Arm, drive to the Goal, release the Pin
    arm_motor.spin_for(FORWARD, 300, DEGREES)
    drivetrain.drive_for(FORWARD, 10, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

    drivetrain.turn_for(LEFT, 70, DEGREES)

    # Display the ID of the next closest object
    while True:
        ai_objects = ai_vision.take_snapshot(AiVision.ALL_AIOBJS)
        if ai_objects:
            brain.screen.print(ai_objects[0].id)
            break

# VR threads — Do not delete
vr_thread(main)

Κονσόλα#

Η Κονσόλα εμφανίζει κείμενο, αριθμούς και τιμές μεταβλητών ενώ εκτελείται ένα έργο. Οι μέθοδοι κονσόλας μπορούν επίσης να μετακινήσουν τον κέρσορα σε μια νέα γραμμή, να διαγράψουν την Κονσόλα και να προσθέσουν μεταβλητές ή τιμές αισθητήρων στην καρτέλα Παρακολούθηση.

Αποτύπωμα#

εγκέφαλος.οθόνη.εκτύπωση#

brain.screen.print displays text, numbers, or variable values in the Console using the current cursor position.

Use brain.screen.next_row when you want the next printed value to start on a new row.

Usage:
brain.screen.print(value)

Παράμετροι

Περιγραφή

value

Το κείμενο, ο αριθμός ή η τιμή μεταβλητής που θα εμφανίζεται στην Κονσόλα.

def main():
    # Display a message in the Console
    brain.screen.print("Hello, robot!")

# VR threads — Do not delete
vr_thread(main)

brain.screen.next_row#

brain.screen.next_row moves the cursor to column 1 on the next row in the Console. The next value printed will appear on that row.

Usage:
brain.screen.next_row()

Παράμετροι

Περιγραφή

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

def main():
    # Print on two rows
    brain.screen.print("Row 1")
    brain.screen.next_row()
    brain.screen.print("Row 2")

# VR threads — Do not delete
vr_thread(main)

brain.screen.clear_screen#

brain.screen.clear_screen clears all rows from the Console and moves the cursor back to Row 1.

Usage:
brain.screen.clear_screen()

Παράμετροι

Περιγραφή

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

def main():
    # Display text, then clear it after two seconds
    brain.screen.print("This will disappear...")
    wait(2, SECONDS)
    brain.screen.clear_screen()

# VR threads — Do not delete
vr_thread(main)

Ελεγκτής εκπομπών#

μεταβλητή_παρακολούθησης#

monitor_variable adds one or more predefined variables to the Monitor tab in VEXcode. This lets you watch a variable’s value change while a project is running.

Variables must be global for monitor_variable to monitor them successfully. Provide each variable name as a string.

Usage:
monitor_variable(“variable”)
monitor_variable(“variable1”, “variable2”)

Παράμετροι

Περιγραφή

variable

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

def main():
    # Monitor the number of loops
    global loops
    monitor_variable("loops")

    # Turn in a full circle 3 times
    for loops in range(12):
        drivetrain.turn_for(RIGHT, 90, DEGREES)

# VR threads — Do not delete
vr_thread(main)

αισθητήρας_παρακολούθησης#

monitor_sensor adds one or more sensor values to the Monitor tab in VEXcode. This lets you watch sensor values change while a project is running.

Παρέχετε κάθε τιμή αισθητήρα ως συμβολοσειρά.

Usage:
monitor_sensor(“sensor”)
monitor_sensor(“sensor1”, “sensor2”)

Παράμετροι

Περιγραφή

sensor

The sensor value to monitor, given as a string. To monitor more than one sensor value, separate each sensor value with a comma. Supported sensor identifiers include:

  • Brain
    • brain.timer.time
  • Drivetrain
    • drivetrain.is_done
    • drivetrain.is_moving
    • drivetrain.heading
    • drivetrain.rotation
    • drivetrain.velocity
  • Arm Motor
    • arm_motor.is_done
    • arm_motor.is_spinning
    • arm_motor.position
    • arm_motor.velocity
  • Claw Motor
    • claw_motor.is_done
    • claw_motor.is_spinning
    • claw_motor.position
    • claw_motor.velocity
  • Distance Sensor
    • distance.is_object_detected
    • distance.object_distance_mm
    • distance.object_distance_inches
  • GPS Sensor
    • gps.position_mm
    • gps.position_inches
    • gps.heading
  • AI Vision Sensor
    • ai_vision.object_count
    • ai_vision.height
    • ai_vision.width
    • ai_vision.centerX
    • ai_vision.centerY
    • ai_vision.originX
    • ai_vision.originY
    • ai_vision.id

def main():
    # Monitor the robot's heading
    monitor_sensor("drivetrain.heading")
    drivetrain.turn_for(RIGHT, 450, DEGREES)

# VR threads — Do not delete
vr_thread(main)

Εξεύρεση της φόρας#

Απόσταση#

βρέθηκε_αντικείμενο#

found_object returns whether the Distance Sensor currently detects an object within 2000mm.

  • True — The Distance Sensor detects an object.

  • False — The Distance Sensor does not detect an object.

Usage:
distance.found_object()

Παράμετροι

Περιγραφή

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

def main():
    # Turn until something is detected, then release the Pin
    drivetrain.turn(RIGHT)
    while True:
        wait(5, MSEC)
        if distance.found_object():
            drivetrain.stop()
            break
    arm_motor.spin_for(FORWARD, 300, DEGREES)
    drivetrain.drive_for(FORWARD, 10, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

απόσταση_αντικειμένου#

object_distance returns the distance between the Distance Sensor and the nearest detected object.

Usage:
distance.object_distance(units)

Παράμετροι

Περιγραφή

units

The distance unit: MM or INCHES.

def main():
    # Drive until 200 mm from the Goal, then release the Pin
    while distance.object_distance(MM) > 200:
        wait(5, MSEC)
        drivetrain.drive(FORWARD)
    drivetrain.stop()
    arm_motor.spin_for(FORWARD, 300, DEGREES)
    drivetrain.drive_for(FORWARD, 10, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

GPS#

x_θέση#

x_position returns the current x-coordinate of a GPS (Game Positioning System™) Sensor on the field.

Usage:
gps.x_position(units)

Παράμετροι

Περιγραφή

μονάδες

The unit of the offset value: INCHES or MM

def main():
    # Raise the Arm, drive to the Goal, release the Pin
    arm_motor.spin_for(FORWARD, 300, DEGREES)
    drivetrain.drive(FORWARD)
    while not gps.x_position(MM) > -1370:
        wait(2, MSEC)
    drivetrain.stop()
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

y_θέση#

y_position returns the current y-coordinate of a GPS (Game Positioning System™) Sensor on the field.

Usage:
gps.y_position(units)

Παράμετροι

Περιγραφή

μονάδες

The unit of the offset value: INCHES or MM

def main():
    # Raise the Arm, drive to the Goal, release the Pin
    arm_motor.spin_for(FORWARD, 300, DEGREES)
    drivetrain.drive(FORWARD)
    while not gps.y_position(MM) < -450:
        wait(2, MSEC)
    drivetrain.stop()
    claw_motor.spin_for(REVERSE, 180, DEGREES)

# VR threads — Do not delete
vr_thread(main)

επικεφαλίδα#

heading returns the heading that the robot is currently facing based on the GPS (Game Positioning System™) Sensor’s readings from 0 to 359 degrees.

Usage:
gps.heading()

Παράμετροι

Περιγραφή

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

def main():
    # Raise the Arm, drive to the Goal, release the Pin
    monitor_sensor("gps.heading")
    arm_motor.spin_for(FORWARD, 300, DEGREES)
    drivetrain.drive_for(FORWARD, 10, INCHES)
    claw_motor.spin_for(REVERSE, 180, DEGREES)

    # Turn left to face the Neutral Goal
    drivetrain.set_turn_velocity(30, PERCENT)
    drivetrain.turn(LEFT)
    while not gps.heading() < 18:
        wait(2, MSEC)
    drivetrain.stop()


# VR threads — Do not delete
vr_thread(main)