### Start Robobo Camera Streaming Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Initiates the video streaming from Robobo's camera. Streaming is off by default and this setting is persistent. Requires downloading the 'robobo-python-video-stream' project from GitHub. ```python def startStream(self): """ | Starts the camera streaming. | Camera streaming is stopped by default. | This change is persistent (see: :ref:`persistent`). | In order to use this function, it's neccesary to download the project and follow the instructions from the `stream repository `_. """ self.rem.startStream() ``` -------------------------------- ### Control Robobo Camera Streaming (Python) Source: https://mintforpeople.github.io/robobo.py/robobo Manages the camera streaming functionality. Includes methods to start and stop the stream. Requires downloading and following instructions from the stream repository to use. Changes are persistent. ```python Robobo.startStream() ``` ```python Robobo.stopStream() ``` -------------------------------- ### Control Robobo Camera (Python) Source: https://mintforpeople.github.io/robobo.py/robobo Manages the smartphone camera. Provides methods to start and stop the camera. Warning: Other modules depend on the camera; it must be restarted for them to function. ```python Robobo.startCamera() ``` ```python Robobo.stopCamera() ``` -------------------------------- ### Read Basic Lane Detection - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Retrieves the last detected basic lane using straight line detection. Returns a deep copy of the LaneBasic object. Requires lane detection to be started via startLaneDetection(). ```python def readLaneBasic(self): """ | Reads the last detected basic lane (straight lines). | See also: :class:`~Robobo.startLaneDetection`. :return: The lane read. :rtype: LaneBasic """ return deepcopy(self.rem.state.laneBasic) ``` -------------------------------- ### Read Registered Speech Phrases Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Retrieves a list of all speech phrases that have been registered with Robobo for speech detection. This function is related to starting speech detection. ```python return deepcopy(self.rem.state.registeredSpeechPhrases) ``` -------------------------------- ### Read QR Code - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Retrieves the last detected QR code from the robot's vision system. Returns a deep copy of the QR code object. Requires QR code tracking to be started via startQrTracking(). ```python def readQR(self): """ | Reads the last detected QR code. | See also: :class:`~Robobo.startQrTracking`. :return: The QR code read. :rtype: QRCode """ return deepcopy(self.rem.state.qr) ``` -------------------------------- ### Read Pro Lane Detection - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Retrieves the last detected pro lane using degree 2 polynomial curves for more accurate lane modeling. Returns a deep copy of the LanePro object. Requires lane detection to be started via startLaneDetection(). ```python def readLanePro(self): """ | Reads the last detected pro lane (Degree 2 polynomials). | See also: :class:`~Robobo.startLaneDetection`. :return: The pro lane read. :rtype: LanePro """ return deepcopy(self.rem.state.lanePro) ``` -------------------------------- ### Read Detected Line - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Retrieves the last detected line from the robot's vision system. Returns a deep copy of the Lines object. Requires line detection to be started via startLineDetection(). ```python def readLine(self): """ | Reads the last detected line. | See also: :class:`~Robobo.startLineDetection`. :return: The line read. :rtype: Lines """ return deepcopy(self.rem.state.lines) ``` -------------------------------- ### Read All IR Sensors - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Reads values from all infrared sensors on the robot base and returns a dictionary with IR IDs as keys and sensor values as float values. Example usage shows accessing specific IR readings by value attribute. ```python def readAllIRSensor(self): """ Reads the values of all the IR sensors. Example of use: .. code-block:: python irs = rob.readAllIRSensor() if irs != []: print (irs[IR.FrontR.value]) print (irs[IR.FrontRR.value]) :return: A dictionary returning the values of all the IR sensors of the base. :rtype: dict """ return deepcopy(self.rem.state.irs) ``` -------------------------------- ### Read All IR Sensors in Python Source: https://mintforpeople.github.io/robobo.py/robobo Reads values from all infrared sensors on the Robobo base and accesses specific sensor readings. The method returns a dictionary with IR sensor IDs as keys and their current values as floats, where higher values indicate shorter distances to objects. This example demonstrates accessing front-right and front-right-right IR sensor values. ```python irs = rob.readAllIRSensor() if irs != []: print(irs[IR.FrontR.value]) print(irs[IR.FrontRR.value]) ``` -------------------------------- ### Read Face Sensor Data in Python Source: https://mintforpeople.github.io/robobo.py/robobo Retrieves the last detected face from Robobo's face detection system, including distance and X/Y position coordinates. Returns a Face object with distance and position attributes. Requires face detection to be started first. ```python face = robobo.readFaceSensor() print(face.distance) # the distance to the person print(face.posX) # the position of the face in X axis print(face.posY) # the position of the face in Y axis ``` -------------------------------- ### Initialize Robobo Robot Instance (Python) Source: https://mintforpeople.github.io/robobo.py/_sources/robobo.rst Demonstrates how to create an instance of the Robobo robot by providing its IP address. This is the first step to controlling the robot. ```python from Robobo import Robobo rob = Robobo ('10.113.36.150') ``` -------------------------------- ### Initialize Robobo Connection Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Establishes a new instance of the Robobo library, setting up the connection parameters for the robot. Requires the robot's IP address and optionally a robot ID and secure connection flag. This is the first step before interacting with the robot. ```python from robobopy.remotelib import Remote class Robobo: def __init__(self, ip, robot_id=0, secure=False): """ Creates a new Robobo library instance. :param ip: The IP address of the Robobo robot. :type ip: string :param robot_id: Sequential ID of robots. Only used in multi-robot scenarios in simulation. :type robot_id: int :param secure: Use a secure websocket connection instead of the default one. Only works in local networks (192.68.xxx.xxx) :type secure: bool """ self.rem = Remote(ip, robot_id, secure) ``` -------------------------------- ### Read Lost ARuco Tag ID Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Returns the ID of the ARuco tag that has most recently disappeared from view. This function is related to starting ARuco tag detection. ```python return deepcopy(self.rem.state.lastLostTagId) ``` -------------------------------- ### Read Detected Object Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Reads the last object recognized by Robobo's object recognition system. This function is related to starting object recognition and returns a 'DetectedObject'. ```python return deepcopy(self.rem.state.detectedObject) ``` -------------------------------- ### Read Newest ARuco Tag Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Retrieves the most recently detected ARuco tag. This function is related to starting ARuco tag detection and returns a single 'Tag' object. ```python return deepcopy(self.rem.state.newestTag) ``` -------------------------------- ### Configure Lane Detection Callbacks - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Sets up callback functions to be executed when a pro lane or a basic lane is detected by Robobo. These functions are invoked by the Robobo's remote module. The detection is typically initiated using `Robobo.startLaneDetection`. ```python def whenALaneProDetected(self, callback): """ | Configures the callback that is called when a pro lane is detected. | See also: :class:`~Robobo.startLaneDetection`. :param callback: The callback function to be called. :type callback: fun """ self.rem.setLaneProCallback(callback) def whenALaneBasicDetected(self, callback): """ | Configures the callback that is called when a basic lane is detected. | See also: :class:`~Robobo.startLaneDetection`. :param callback: The callback function to be called. :type callback: fun """ self.rem.setLaneBasicCallback(callback) ``` -------------------------------- ### Read Detected ARuco Tags Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Reads the last set of ARuco tags detected by Robobo. This is associated with starting ARuco tag detection. It returns a list of 'Tag' objects. ```python return deepcopy(self.rem.state.tags) ``` -------------------------------- ### Create Robobo Instance with IP Address in Python Source: https://mintforpeople.github.io/robobo.py/robobo Initialize a Robobo instance by providing the robot's IP address as a string parameter. This creates a local reference to the remote Robobo robot that can be used to call control and sensing methods. ```python from Robobo import Robobo rob = Robobo('10.113.36.150') ``` -------------------------------- ### Configure QR Code Detection Callback - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Sets a callback function that is invoked whenever a QR code is detected. This method is associated with `Robobo.startQrTracking`. The callback is registered using `self.rem.setQRCallback`. ```python def whenAQRCodeIsDetected(self, callback): """ | Configures the callback that is called when a QR is detected. | See also: :class:`~Robobo.startQrTracking`. :param callback: The callback function to be called. :type callback: fun """ self.rem.setQRCallback(callback) ``` -------------------------------- ### Read Detected Face Information Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Reads the data of the last detected face. This function is related to starting face detection. The returned 'Face' object contains properties like distance, posX, and posY. ```python return deepcopy(self.rem.state.face) ``` -------------------------------- ### Start/Stop Lane Detection - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Controls the lane detection module. `startLaneDetection` initiates the process, while `stopLaneDetection` halts it. Lane detection is off by default. These settings are persistent. Dependencies include the `rem` object. ```python def startLaneDetection(self): """ | Starts the lane detection. | See also: :class:`~Robobo.stopLaneDetection`, :class:`~Robobo.setLaneColorInversion`, :class:`~Robobo.readLaneBasic`, :class:`~Robobo.readLanePro`, :class:`~Robobo.whenALaneBasicDetected`, :class:`~Robobo.whenALaneProDetected`. | For more information, check the `Lane Detection Wiki `_. """ self.rem.startLane() def stopLaneDetection(self): """ | Stops the lane detection. | Lane detection is stopped by default. | This change is persistent (see: :ref:`persistent`). | See also: :class:`~Robobo.startLaneDetection`. """ self.rem.stopLane() ``` -------------------------------- ### Start/Stop Line Detection - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Manages the line detection module. `startLineDetection` activates line detection, and `stopLineDetection` deactivates it. Line detection is off by default and changes are persistent. Related functions include `utils.Lines.Lines` and methods for reading lines and detecting them. ```python def startLineDetection(self): """ | Starts the line detection. | Line detection is stopped by default. | This change is persistent (see: :ref:`persistent`). | See also: :class:`~utils.Lines.Lines`, :class:`~Robobo.stopLineDetection`, :class:`~Robobo.readLine`, :class:`~Robobo.whenALineIsDetected`. """ self.rem.startLine() def stopLineDetection(self): """ | Stops the line detection. | Line detection is stopped by default. | This change is persistent (see: :ref:`persistent`). | See also: :class:`~Robobo.startLineDetection`. """ self.rem.stopLine() ``` -------------------------------- ### Set LED Color Source: https://mintforpeople.github.io/robobo.py/robobo Sets the color of a specified LED on the robot's base. ```APIDOC ## Robobo.setLedColorTo ### Description Set the color of a LED of the base. ### Method POST ### Endpoint /robobo/setLedColorTo ### Parameters #### Request Body - **led** (LED) - Required - LED to set the color of. - **color** (Color) - Required - New color of the LED. ### Request Example { "led": "front_left", "color": "red" } ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example { "status": "success" } ``` -------------------------------- ### Read Detected Speech Message Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Reads the last speech message detected by Robobo. This includes the message content, matched registered phrases, and an indicator of whether the detection is final or ongoing. Related to starting speech detection. ```python return deepcopy(self.rem.state.lastSpeech) ``` -------------------------------- ### Start/Stop Camera - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Controls the camera module. `startCamera` activates the camera, and `stopCamera` deactivates it. Stopping the camera requires restarting it to use other modules that depend on it. Uses the `rem` object. ```python def startCamera(self): """ Starts the camera. """ self.rem.startCamera() def stopCamera(self): """ | Stops the camera. | **Warning**: Other modules depend on the camera, so it's necessary to start it again to make use of them. """ self.rem.stopCamera() ``` -------------------------------- ### Configure New QR Code Detection Callback - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Sets a callback function that is invoked when a new, distinct QR code is detected. This method is related to `Robobo.startQrTracking`. It uses `self.rem.setNewQRCallback` to register the callback. ```python def whenANewQRCodeIsDetected(self, callback): """ | Configures the callback that is called when a new QR is detected. A QR is considered to be new if it's different to the last one detected. | See also: :class:`~Robobo.startQrTracking`. :param callback: The callback function to be called. :type callback: fun """ self.rem.setNewQRCallback(callback) ``` -------------------------------- ### Callback for Basic Lane Detection Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Sets up a callback function to be triggered when a basic lane is detected. This is associated with the Robobo's lane detection capabilities. ```APIDOC ## POST /robobo/lane/basic/callback ### Description Configures the callback that is called when a basic lane is detected. This functionality is part of the lane detection system. ### Method POST ### Endpoint /robobo/lane/basic/callback ### Parameters #### Request Body - **callback** (function) - Required - The callback function to be invoked upon basic lane detection. ### Request Example ```json { "callback": "myBasicLaneCallbackFunction" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation, e.g., "callback_set". #### Response Example ```json { "status": "callback_set" } ``` ``` -------------------------------- ### Read TILT Position - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Retrieves the current position of the TILT (vertical pan/tilt mechanism). Returns position in degrees within the range [5..105]. Also includes readTiltLastTime() to get the timestamp of the last received tilt status. ```python def readTiltPosition(self): """ Reads the current position of the TILT. :return: The position in degrees, taking values in range [5..105]. See: :ref:`tilt`. :rtype: int """ return self.rem.state.tiltPos def readTiltLastTime(self): """ Returns the timestamp of the last received tilt status :return: Time in milliseconds :rtype: int """ return self.rem.state.lastTiltTimestamp ``` -------------------------------- ### Read PAN Position - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Retrieves the current position of the PAN (horizontal pan/tilt mechanism). Returns position in degrees within the range [-160..160]. Also includes readPanLastTime() to get the timestamp of the last received pan status. ```python def readPanPosition(self): """ Reads the current position of the PAN. :return: The position in degrees, taking values in range [-160..160]. See: :ref:`pan`. :rtype: int """ return self.rem.state.panPos def readPanLastTime(self): """ Returns the timestamp of the last received pan status :return: Time in milliseconds :rtype: int """ return self.rem.state.lastPanTimestamp ``` -------------------------------- ### Configure Face Detection Callback - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Sets a callback function to be executed when a new face is detected by the RoboBo. This method is related to `Robobo.startFaceDetection`. The callback is registered using `self.rem.setFaceCallback`. ```python def whenANewFaceIsDetected(self, callback): """ | Configures the callback that is called when a new face is detected. | See also: :class:`~Robobo.startFaceDetection`. :param callback: The callback function to be called. :type callback: fun """ self.rem.setFaceCallback(callback) ``` -------------------------------- ### Connect to Robobo Robot in Python Source: https://mintforpeople.github.io/robobo.py/robobo Establishes a remote connection with the Robobo robot using the IP address associated with the Robobo instance. Must be called before any control or sensing operations. ```python rob.connect() ``` -------------------------------- ### Configure Object Detection Callback - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Configures the callback function that is invoked when an object is detected. This functionality is linked to `Robobo.startObjectRecognition`. The callback is registered using `self.rem.setDetectedObjectCallback`. ```python def whenAnObjectIsDetected(self, callback): """ | Configures the callback that is called when an object is detected. | See also: :class:`~Robobo.startObjectRecognition`. :param callback: The callback function to be called. :type callback: fun """ self.rem.setDetectedObjectCallback(callback) ``` -------------------------------- ### Connect and Disconnect Robobo Robot Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Manages the connection to the RoboBo robot. The `connect` method initiates the remote connection, while `disconnect` terminates it. These are crucial for managing robot communication and resources. ```python def connect(self): """ Establishes a remote connection with the Robobo indicated by the IP address associated to this instance. """ self.rem.wsStartup() def disconnect(self): """ Disconnects the library from the Robobo robot. """ self.rem.disconnect() ``` -------------------------------- ### Callback for Pro Lane Detection Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Configures the callback function that is executed when a pro lane is detected by the Robobo. This is related to lane detection functionality. ```APIDOC ## POST /robobo/lane/pro/callback ### Description Configures the callback that is called when a pro lane is detected. This functionality is part of the lane detection system. ### Method POST ### Endpoint /robobo/lane/pro/callback ### Parameters #### Request Body - **callback** (function) - Required - The callback function to be invoked upon pro lane detection. ### Request Example ```json { "callback": "myProLaneCallbackFunction" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation, e.g., "callback_set". #### Response Example ```json { "status": "callback_set" } ``` ``` -------------------------------- ### Start/Stop Speech Detection - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Manages speech detection. `startSpeechDetection` enables listening for speech, and `stopSpeechDetection` disables it. Speech detection is off by default. Changes are persistent. Related functions include `setSpeechDetectionPhraseOnly`, `registerSpeechDetectionPhrase`, and `removeSpeechDetectionPhrase`. ```python def startSpeechDetection(self): """ | Starts the speech detection. | Speech detection is stopped by default. | This change is persistent (see: :ref:`persistent`). """ self.rem.startSpeechDetection() def stopSpeechDetection(self): """ | Stops the speech detection. | Speech detection is stopped by default. | This change is persistent (see: :ref:`persistent`). | See also: :class:`~Robobo.stopSpeechDetection`. """ self.rem.stopSpeechDetection() ``` -------------------------------- ### Callback for Speech Detection Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Registers a callback function that will be executed whenever speech is detected by the Robobo. This is part of the speech detection feature. ```APIDOC ## POST /robobo/speech/callback ### Description Configures the callback that is called when speech is detected. This functionality is part of the speech detection system. ### Method POST ### Endpoint /robobo/speech/callback ### Parameters #### Request Body - **callback** (function) - Required - The callback function to be invoked upon speech detection. ### Request Example ```json { "callback": "mySpeechCallbackFunction" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation, e.g., "callback_set". #### Response Example ```json { "status": "callback_set" } ``` ``` -------------------------------- ### Configure Speech Detection Callback - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Establishes a callback function that is triggered when speech is detected by Robobo. This functionality is managed through the Robobo's remote module and is typically enabled by calling `Robobo.startSpeechDetection`. ```python def whenSpeechDetected(self, callback): """ | Configures the callback that is called when speech is detected. | See also: :class:`~Robobo.startSpeechDetection`. :param callback: The callback function to be called. :type callback: fun """ self.rem.setSpeechDetectionCallback(callback) ``` -------------------------------- ### Switch Robobo Camera (Python) Source: https://mintforpeople.github.io/robobo.py/robobo Controls which camera Robobo uses. Options include setting the front camera or the back camera. These changes are persistent. ```python Robobo.setFrontCamera() ``` ```python Robobo.setBackCamera() ``` -------------------------------- ### Configure Line Detection Callback - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Sets a callback function that is executed when a line is detected by the RoboBo. This method is related to `Robobo.startLineDetection`. The callback is configured using `self.rem.setLineCallback`. ```python def whenALineIsDetected(self, callback): """ | Configures the callback that is called when a line is detected. | See also: :class:`~Robobo.startLineDetection`. :param callback: The callback function to be called. :type callback: fun """ self.rem.setLineCallback(callback) ``` -------------------------------- ### Python Blob Class Definition and Initialization Source: https://mintforpeople.github.io/robobo.py/_modules/utils/Blob Defines the Blob class for representing detected blobs. It includes attributes for color, position (posx, posy), size, and timestamps (frame_timestamp, status_timestamp). The constructor initializes these attributes, and the __str__ method provides a human-readable string representation of the blob object. ```python class Blob: """ Represents a blob detected by Robobo. Attributes: - color (string): The color of the blob. - posx (int): The x coordinate of the tap [0..100]. See: :ref:`screen`. - posy (int): The y coordinate of the tap [0..100]. See: :ref:`screen`. - size (int): The area of the blob measured in pixels. - frame_timestamp (long): The time when the frame started processing. - status_timestamp (long): The time when the status was sent. """ def __init__(self, color, posx, posy, size, frame_timestamp, status_timestamp): self.color = color self.posx = posx self.posy = posy self.size = size self.frame_timestamp = frame_timestamp self.status_timestamp = status_timestamp def __str__(self): return self.color+" blob, x:"+str(self.posx)+" y:"+str(self.posy)+" size:"+str(self.size) + " frame timestamp:"+str(self.frame_timestamp) ``` -------------------------------- ### Configure Lost QR Code Callback - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Configures a callback function to be executed when a previously detected QR code is no longer visible. This is related to `Robobo.startQrTracking` and uses `self.rem.setLostQRCallback`. ```python def whenAQRCodeIsLost(self, callback): """ | Configures the callback that is called when a QR is lost. | See also: :class:`~Robobo.startQrTracking`. :param callback: The callback function to be called. :type callback: fun """ self.rem.setLostQRCallback(callback) ``` -------------------------------- ### Python Enum for Robobo Base LEDs Source: https://mintforpeople.github.io/robobo.py/_modules/utils/LED Defines an enumeration `LED` for the different LEDs available on the Robobo base. This enumeration is used to reference and control specific LEDs. It includes LEDs for the back, front, and an 'all' option for controlling all LEDs simultaneously. ```python from enum import Enum [docs] class LED(Enum): """ This enumeration represents the list of Robobo base's LEDs .. image:: _static/leds.jpg :scale: 60 % :alt: Top view of Robobo. There are five IR sensors forming a pentagon on the frontal part: Front-C on the upper and central part, Front-RR to the left and Front-LL to the right (from the viewer's point of view) of the first one, and finally Front-R on the left and Front-L on the right of the lower part of the pentagon. There are two IR sensors on the rear part: Back-R on the right and Back-L on the left. """ BackR = "Back-R" FrontR = "Front-R" FrontRR = "Front-RR" FrontC = "Front-C" FrontL = "Front-L" FrontLL = "Front-LL" BackL = "Back-L" All = "all" ``` -------------------------------- ### Move Wheels by Time Source: https://mintforpeople.github.io/robobo.py/robobo Moves the robot's wheels for a specified duration at given speeds. ```APIDOC ## Robobo.moveWheelsByTime ### Description Moves Robobo wheels during the specified time, each one at the specified speed. ### Method POST ### Endpoint /robobo/moveWheelsByTime ### Parameters #### Request Body - **rSpeed** (int) - Required - Speed factor for the right wheel [-100..100]. - **lSpeed** (int) - Required - Speed factor for the left wheel [-100..100]. - **duration** (float) - Required - Duration of the movement in seconds (>0). - **wait** (bool) - Optional - If true, the instruction is executed in blocking mode. Defaults to true. ### Request Example { "rSpeed": 50, "lSpeed": 50, "duration": 2.5, "wait": true } ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example { "status": "success" } ``` -------------------------------- ### Configure Tap Detection Callback - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Configures the callback function that will be executed when a tap is detected. The callback is registered via the `self.rem.setTapCallback` method. ```python def whenATapIsDetected(self, callback): """ Configures the callback that is called when a new tap is detected. :param callback: The callback function to be called. :type callback: fun """ self.rem.setTapCallback(callback) ``` -------------------------------- ### Configure Note Detection Callback - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Configures the callback that is invoked when a new musical note is detected. The provided callback function will be executed upon detection. This method uses the `rem.setNoteCallback` method internally. ```python def whenANoteIsDetected(self, callback): """ Configures the callback that is called when a new note is detected. :param callback: The callback function to be called. :type callback: fun """ self.rem.setNoteCallback(callback) ``` -------------------------------- ### Set Robobo LED Color Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Sets the color of a specific LED on the Robobo base. Requires specifying the LED component and the desired color. The 'LED' and 'Color' types are abstract and would be defined elsewhere in the Robobo library. ```python def setLedColorTo(self, led, color): """ Set the color of a LED of the base. :param led: LED to set the color of. :param color: New color of the LED. :type led: LED :type color: Color """ self.rem.setLedColor(led, color) ``` -------------------------------- ### Configure New Aruco Tag Detection Callback - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Configures a callback function to be executed when a new Aruco tag is detected. This is related to `Robobo.startArUcoTagDetection` and uses `self.rem.setNewTagCallback`. ```python def whenArucoTagAppears(self, callback): """ | Configures the callback that is called when a new Tag is detected. | See also: :class:`~Robobo.startArUcoTagDetection`. :param callback: The callback function to be called. :type callback: fun """ self.rem.setNewTagCallback(callback) ``` -------------------------------- ### Send Synchronization IDs - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Sends synchronization identifiers for camera and audio streams. This allows for labeling specific frames or audio packets, ensuring proper synchronization between different data streams. ```python def sendSync(self, syncId): """Send a sync identifier to label the next frame sent through the camera stream :param syncId: Label to be applied to the frame :type syncId: int """ self.rem.sendSync(syncId) def sendSyncAudio(self, syncId): """Send a sync identifier to label the next audio packet sent through the audio stream :param syncId: Label to be applied to the audio packet :type syncId: int """ self.rem.sendSyncAudio(syncId) ``` -------------------------------- ### Configure Clap Detection Callback - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Sets a callback function to be executed whenever a clap is detected. This function takes a single argument, which is the callback function itself. It relies on the `rem.setClapCallback` method for its implementation. ```python def whenClapIsDetected(self, callback): """ Configures the callback that is called when a new clap is detected. :param callback: The callback function to be called. :type callback: fun """ self.rem.setClapCallback(callback) ``` -------------------------------- ### Set Lane Color Inversion - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Configures color inversion for the advanced lane detection module. `setLaneColorInversion(set_on)` enables or disables detection of dark lanes on light backgrounds. This setting is persistent. Requires the `rem` object and is related to `startLaneDetection`. ```python def setLaneColorInversion(self, set_on): """ | Toggles the color inversion for the advanced lane module. Usually, light lanes are detected against a dark background, but it is also possible to detect dark lanes against light backgrounds. | This change is persistent (see: :ref:`persistent`). | See also: :class:`~Robobo.startLaneDetection`. :param set_on: Boolean to choose if turn it on or off. :type set_on: bool """ if set_on: self.rem.setLaneColorInversionOn() else: self.rem.setLaneColorInversionOff() ``` -------------------------------- ### Move Tilt Source: https://mintforpeople.github.io/robobo.py/robobo Moves the robot's head (tilt axis) to a specified degree position at a given speed. ```APIDOC ## Robobo.moveTiltTo ### Description Moves the TILT of the base to the specified position at the specified speed. ### Method POST ### Endpoint /robobo/moveTiltTo ### Parameters #### Request Body - **degrees** (int) - Required - Position in degrees of the TILT [5..105]. - **speed** (int) - Required - Speed factor for the movement [0..100]. - **wait** (bool) - Optional - If true, the instruction is executed in blocking mode. Defaults to true. ### Request Example { "degrees": 30, "speed": 50, "wait": true } ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example { "status": "success" } ``` -------------------------------- ### Set Robobo Camera FPS Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Configures the frames per second (FPS) captured by the smartphone's camera. This setting is persistent. The input 'fps' must be a positive integer. ```python def setCameraFps(self, fps): """ | Sets the camera fps. These are the number of frames per second read by the smartphone camera. Default value is 60, buf effective value is usually lower (around 20), depending on the smartphone. | This change is persistent (see: :ref:`persistent`). :param fps: New upper limit of the camera fps. Takes positive values. :type fps: int """ self.rem.setCameraFps(fps) ``` -------------------------------- ### Define DetectedObject Class for Robobo Source: https://mintforpeople.github.io/robobo.py/_modules/utils/DetectedObject This Python class represents an object detected by the Robobo system. It stores bounding box coordinates (x, y, width, height), the object's label, and detection confidence. It also includes a timestamp for the detection. The `__init__` method initializes these attributes, and `__str__` provides a formatted string representation of the detected object. ```python class DetectedObject: """ Represents an object detected by Robobo. Attributes: - x (int): The x coordinate of the center of the bounding box, measured in pixels from the left side of the screen. Takes positive values. - y (int): The y coordinate of the center of the bounding box, measured in pixels from the upper side of the screen. Takes positive values. - width (int): The width of the bounding box, measured in pixels. Takes positive values. - height (int): The height of the bounding box, measured in pixels. Takes positive values. - label (string): The class of the identified object. - confidence (float): The confidence for the class of the object. Takes values between 0.5 and 1. """ def __init__(self, x, y, width, height, confidence, label, statusTimestamp): self.x = x self.y = y self.width = width self.height = height self.label = label self.confidence = confidence self.timeStamp = statusTimestamp def __str__(self): return "DETECTED_OBJECT, Label:" + self.label + \ " x:" + str(self.x) + \ " y:" + str(self.y) + \ " height:" + str(self.height) + \ " width:" + str(self.width) + \ " confidence:" + str(self.confidence) + \ " timestamp:" + str(self.timeStamp) ``` -------------------------------- ### Set Robobo Front Camera Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Configures Robobo to use its front-facing camera. This setting is persistent across sessions. ```python def setFrontCamera(self): """ | Makes Robobo use the frontal camera. | This change is persistent (see: :ref:`persistent`). """ self.rem.setCamera("front") ``` -------------------------------- ### Set Advanced Blob Tracker Parameters - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Configures advanced parameters for the blob tracker including frame count for lost blob detection, minimum blob area, and termcriteria parameters. Use only if familiar with blob tracking algorithms as incorrect configuration may cause unexpected behavior. ```python def setAdvancedLostBlobParameters(self, frames=5, minarea=1000, max_count=1, epsilon=0): """ Sets advanced parameters for the blob tracker. :param frames: Number of frames passed to consider a blob lost. :param minarea: Minimum area to consider a Blob as a Blob. :param max_count: max_count parameter of the termcriteria. :param epsilon: epsilon parameter of the termcriteria. :type frames: int :type minarea: int :type max_count: int :type epsilon: int """ self.rem.advancedLostBlobConfiguration(frames, minarea, max_count, epsilon) ``` -------------------------------- ### Python: Define Orientation Class Source: https://mintforpeople.github.io/robobo.py/_modules/utils/Orientation Defines the Orientation class to represent the yaw, pitch, and roll of a device. It includes initialization and a string representation for easy display of orientation data. The class takes yaw, pitch, and roll as float attributes. ```python class Orientation: """ Represents the orientation of the Smartphone. Attributes: - yaw (float): Rotation in degrees around the Z axis. Takes values between -180 and 180. The yaw angle turn is achieved by turning the base with the wheel motors and the PAN motor. - pitch (float): Rotation in degrees around the Y axis. Takes values between -180 and 180. The pitch angle turn is achieved by using the TILT motor or moving the robot through a frontally inclined plane. - roll (float): Rotation in degrees around the X axis. Takes values between -180 and 180. The turn in the roll angle cannot be achieved by Robobo, but if the surface on which it moves has a lateral inclination, it will change. .. image:: _static/orientation.jpg :alt: Image showing Robobo three main axes. Yaw is the vertical axis, positive upwards. Roll is the longitudinal axis, positive forward. Pitch is the transversal axis, positive to Robobo's right. """ def __init__(self, yaw, pitch, roll): self.yaw = yaw self.pitch = pitch self.roll = roll def __str__(self): return "Orientation, yaw: " + str(self.yaw)+", pitch: " + str(self.pitch) + ", roll: " + str(self.roll) ``` -------------------------------- ### Lines Class Definition Source: https://mintforpeople.github.io/robobo.py/_modules/utils/Lines Defines the Lines class to store detected lines and frame IDs. It includes initialization with line data and frame ID, and a string representation for the object. ```python class Lines: """ Represents a set of straight lines detected by Robobo in a frame. Attributes: - lines (array): Array with n rows and 4 columns, being n the number of lines detected. Each row has the values 'x1', 'y1', 'x2', 'y2', representing the x and y coordinates of the points 1 and 2 that form the detected line. These coordinates takes positive values. - id (int): Sequence frame number. Since the camera starts, each frame has a number to be identified. Takes positive values. """ def __init__(self,lines,id): self.lines = lines self.id=id def __str__(self): return "Lane, Id:" + str(self.id) + " lines:" + str(self.lines) ``` -------------------------------- ### Configure Color Blob Detection Callback - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Configures the callback that is triggered when a new color blob is detected. This functionality is linked to `Robobo.setActiveBlobs`. The callback is set using `self.rem.setBlobCallback`. ```python def whenANewColorBlobIsDetected(self, callback): """ | Configures the callback that is called when a new color blob is detected. | See also: :class:`~Robobo.setActiveBlobs`. :param callback: The callback function to be called. :type callback: fun """ self.rem.setBlobCallback(callback) ``` -------------------------------- ### Send Sync Identifier for Camera Stream Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Sends a synchronization identifier to label the next frame transmitted through the camera stream. Useful for aligning streams. ```APIDOC ## POST /robobo/sync/camera ### Description Sends a synchronization identifier to label the next frame sent through the camera stream. ### Method POST ### Endpoint /robobo/sync/camera ### Parameters #### Request Body - **syncId** (int) - Required - The label to be applied to the camera frame. ### Request Example ```json { "syncId": 12345 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation, e.g., "sync_id_sent". #### Response Example ```json { "status": "sync_id_sent" } ``` ``` -------------------------------- ### Make Robobo Say Text Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Enables Robobo to speak the provided text. Supports both blocking and non-blocking modes for speech output. The 'speech' parameter is a string, and 'wait' is a boolean. ```python def sayText(self, speech, wait=True): """ Makes Robobo say the specified text. :param speech: The text to say. :param wait: If true, the instruction is executed in blocking mode. If false, it's executed in non-blocking mode. For more information, see: :ref:`blocking`. :type speech: string :type wait: bool """ self.rem.talk(speech, wait) ``` -------------------------------- ### Define Color Enum for Robobo LED Support Source: https://mintforpeople.github.io/robobo.py/_modules/utils/Color Creates an Enum class that represents the complete list of colors supported by Robobo's LEDs. Each color is mapped to a string identifier that can be used to control the robot's lighting. This enumeration provides type-safe color references throughout the Robobo control library. ```python from enum import Enum class Color(Enum): """ This enumeration represents the list of colors Robobo's LEDs can show. """ OFF = 'off' WHITE = 'white' RED = 'red' BLUE = 'blue' CYAN = 'cyan' MAGENTA = 'magenta' YELLOW = 'yellow' GREEN = 'green' ORANGE = 'orange' ``` -------------------------------- ### Move Wheels Source: https://mintforpeople.github.io/robobo.py/robobo Controls the speed of the left and right wheels independently to move the robot. ```APIDOC ## Robobo.moveWheels ### Description Moves Robobo wheels, each one at the specified speed. ### Method POST ### Endpoint /robobo/moveWheels ### Parameters #### Request Body - **rSpeed** (int) - Required - Speed factor for the right wheel [-100..100]. Positive values mean the wheel moves forwards and negative values mean it moves backwards. - **lSpeed** (int) - Required - Speed factor for the left wheel [-100..100]. Positive values mean the wheel moves forwards and negative values mean it moves backwards. ### Request Example { "rSpeed": 50, "lSpeed": 50 } ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. #### Response Example { "status": "success" } ``` -------------------------------- ### Configure Aruco Tag Detection Callback - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Sets a callback function that is executed when an Aruco tag is detected. This method is linked to `Robobo.startArUcoTagDetection`. The callback is registered using `self.rem.setTagCallback`. ```python def whenArucoTagIsDetected(self, callback): """ | Configures the callback that is called when a Tag is detected. | See also: :class:`~Robobo.startArUcoTagDetection`. :param callback: The callback function to be called. :type callback: fun """ self.rem.setTagCallback(callback) ``` -------------------------------- ### Send Sync Identifier for Audio Stream Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Transmits a synchronization identifier to label the next audio packet sent over the audio stream. Aids in stream synchronization. ```APIDOC ## POST /robobo/sync/audio ### Description Sends a synchronization identifier to label the next audio packet sent through the audio stream. ### Method POST ### Endpoint /robobo/sync/audio ### Parameters #### Request Body - **syncId** (int) - Required - The label to be applied to the audio packet. ### Request Example ```json { "syncId": 67890 } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation, e.g., "sync_audio_id_sent". #### Response Example ```json { "status": "sync_audio_id_sent" } ``` ``` -------------------------------- ### Register/Remove Speech Detection Phrase - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Manages registered phrases for speech detection. `registerSpeechDetectionPhrase(phrase)` adds a phrase, and `removeSpeechDetectionPhrase(phrase)` removes it. These changes are persistent. Registered phrases can be retrieved using `readRegisteredSpeechPhrases`. Related to `startSpeechDetection`. ```python def registerSpeechDetectionPhrase(self, phrase): """ | Registers a new phrase to be detected by the speech detection module | Registered phrases can be retrieved with :class:`~Robobo.readRegisteredSpeechPhrases`. | This change is persistent (see: :ref:`persistent`). | See also: :class:`~Robobo.startSpeechDetection`. :param phrase: Phrase string to be registered. :type phrase: string """ self.rem.registerSpeechPhrase(phrase) def removeSpeechDetectionPhrase(self, phrase): """ | Removes a a phrase from the registered on the speech detection module. Has no effect if the phrase wasn't registered previously | Registered phrases can be retrieved with :class:`~Robobo.readRegisteredSpeechPhrases`. | This change is persistent (see: :ref:`persistent`). | See also: :class:`~Robobo.startSpeechDetection`. :param phrase: Phrase string to be removed. :type phrase: string """ self.rem.removeSpeechPhrase(phrase) ``` -------------------------------- ### Set Speech Detection Mode - Python Source: https://mintforpeople.github.io/robobo.py/_modules/Robobo Configures the speech detection mode. `setSpeechDetectionPhraseOnly(set_on)` sets the mode to detect only registered phrases if `set_on` is true, or any speech if false. This change is persistent. Related to `startSpeechDetection`. ```python def setSpeechDetectionPhraseOnly(self, set_on): """ | Toggles the Speech Detection mode to only detect the registered phrases if true or anything if false | Registered phrases won't get cleared if this is toggled off | This change is persistent (see: :ref:`persistent`). | See also: :class:`~Robobo.startSpeechDetection`. :param set_on: Boolean to choose if turn it on or off. :type set_on: bool """ if set_on: self.rem.detectSpeechPhrasesOnly() else: self.rem.detectAnySpeech() ``` -------------------------------- ### Set Advanced Lost Blob Parameters (Python) Source: https://mintforpeople.github.io/robobo.py/robobo Sets advanced parameters for the blob tracker, such as frames to consider a blob lost, minimum area, maximum count, and epsilon. Use with caution, as incorrect configuration can lead to unexpected results. ```python Robobo.setAdvancedLostBlobParameters(_frames =5_, _minarea =1000_, _max_count =1_, _epsilon =0_) ```