Διαφορές AIM WebSocket#

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

Πρόσθετες μέθοδοι#

play_local_file#

The play_local_file method plays a sound file that is stored on the computer and outputs the sound through the robot’s speaker. This allows you to play custom .wav or .mp3 files on the robot without needing to upload them.

Usage:
robot.sound.play_local_file(filepath: str, volume = 100)

Παράμετροι

Περιγραφή

διαδρομή αρχείου

A string specifying the path to a .wav or .mp3 file on the computer.

τόμος

Προαιρετικά. Η ένταση αναπαραγωγής ως ποσοστό από 0 έως 100. Η προεπιλογή είναι 100.

To view an implementation example, open play_sounds.py

get_camera_image#

The get_camera_image method captures the current frame from the robot’s AI Vision Sensor and returns it as a JPEG-compressed bytes object. This is typically used with tools like OpenCV for displaying a live video feed.

Usage:
robot.vision.get_camera_image()

Παράμετροι

Περιγραφή

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

To view an implementation example, see stream_video.py.

Χρησιμοποιήστε Πολλαπλά Ρομπότ Ταυτόχρονα#

You can connect to multiple robots by manually specifying each robot’s IP address when creating Robot objects.

Usage:
Robot(address)

Παράμετροι

Περιγραφή

διεύθυνση

Optional. The IP Address of the robot. If omitted, the address in the host field of settings.json is used by default.

To view an implementation example, open multiple_robots.py.

Αφαιρέθηκαν κλάσεις#

Οι ακόλουθες κλάσεις που είναι διαθέσιμες στο VEXcode Python API δεν είναι διαθέσιμες στην έκδοση WebSocket:

  • Controller

  • Event

Χαρακτηριστικά διαθέσιμα μόνο στο VEXcode#

Οι ακόλουθες λειτουργίες δεν υποστηρίζονται προς το παρόν μέσω του AIM WebSocket API και απαιτούν σύνδεση μέσω του VEXcode AIM:

  • Ενημέρωση του υλικολογισμικού του ρομπότ

  • Μεταφόρτωση προσαρμοσμένων εικόνων

  • Μεταφόρτωση προσαρμοσμένων ήχων

  • Μηνύματα από ρομπότ σε ρομπότ από ρομπότ