### Handle GET Command in JINX (C) Source: https://github.com/purduesigbots/pros-docs/blob/master/cortex/tutorials/jinx.rst An example C helper function for handling the 'get' command within the JINX protocol. It extracts a token from the incoming message and constructs a response string. This function demonstrates dynamic memory allocation and string formatting. ```c //Example of user defined JINX helper function. //Since it is at the top of this file, it can be called from anywhere else in this file. //Good practice is to put its prototype in JINX.h, though. void handleGet(JINX * inStr) { //Get the first token from the sent command getToken(inStr, 1); //Host outgoing messages char * message = (char *)malloc(sizeof(char) * (strlen(inStr->token) + 30)); if (strcmp(inStr->token, "DEBUG_JINX") == 0) { writeJINXMessage("Asked for Debug"); sprintf(message, "%s, %d", inStr->token, DEBUG_JINX); } else { sprintf(message, "%s %s", inStr->token, " was unable to be gotten."); } //Free malloc'd string writeJINXMessage(message); free(message); message = NULL; } ``` -------------------------------- ### Installing PROS Documentation Dependencies Source: https://context7.com/purduesigbots/pros-docs/llms.txt Instructions for setting up the Python environment required for building PROS documentation. Includes creating a virtual environment, installing dependencies from `requirements.txt`, and initializing Git submodules. ```bash # Create virtual environment (recommended) python3 -m venv ./docs-venv source ./docs-venv/bin/activate # On Windows: .\docs-venv\Scripts\activate # Install all required dependencies pip install -r requirements.txt # Initialize and update git submodules (required for custom theme) git submodule init git submodule update --recursive ``` ```text # requirements.txt contents docutils<0.18 Sphinx==1.8.5 alabaster==0.7.13 sphinx_tabs==1.1.10 ablog==0.9.4 sphinx-click==2.0.1 click jinja2<3.1.0 ``` -------------------------------- ### Install PROS Editor on macOS Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/getting-started/macos.rst Installs the PROS Editor application on macOS. This involves building and installing cquery and then downloading and placing the PROS Editor application in the Applications folder. ```bash unzip pros-editor-mac.zip cp -R PROS\ Editor.app /Applications ``` -------------------------------- ### Manual Installation of ARM GCC Toolchain on macOS Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/getting-started/macos.rst Provides steps for manually installing the GNU Arm Embedded Toolchain. This involves downloading the toolchain, extracting it, copying it to a desired location, and linking its binaries to the system's PATH. ```bash mkdir -p /usr/local/bin/pros-toolchain && ln -s /usr/local/lib/pros-toolchain/bin/* /usr/local/bin/pros-toolchain # Then add /usr/local/bin/pros-toolchain to your /etc/paths file. ``` ```bash ln -s /usr/local/lib/pros-toolchain/bin/* /usr/local/bin ``` -------------------------------- ### Install PROS Toolchain and CLI using Homebrew on macOS Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/getting-started/macos.rst Installs the ARM GCC toolchain and the PROS CLI using Homebrew. This is the recommended method for most users. Ensure Homebrew is installed before running these commands. ```bash brew tap osx-cross/arm && brew install arm-gcc-bin brew tap purduesigbots/pros brew install pros-cli ``` -------------------------------- ### Initialize, Set Text, and Shutdown LCD - C Example Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/llemu.rst Initializes the LCD, displays 'Hello World!' on line 1, and then shuts down the LCD. This example shows a complete lifecycle for LCD interaction. ```c void initialize() { lcd_initialize(); lcd_set_text(1, "Hello World!"); lcd_shutdown(); // All done with the LCD } ``` -------------------------------- ### Example Makefile Configuration for Hot/Cold Linking and Library Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/tutorials/topical/wireless-upload.rst This example illustrates a combined Makefile configuration enabling hot/cold linking and setting up the project as a library. It includes specific files and directories to be excluded from the library, such as common control files and a scripts directory. ```Makefile # Set to 1 to enable hot/cold linking USE_PACKAGE=1 # Set this to 1 to add additional rules to compile your project as a PROS library template IS_LIBRARY:=1 LIBNAME:=libtheseus VERSION:=1.0.0 # this line excludes opcontrol.c and similar files EXCLUDE_SRC_FROM_LIB+=$(foreach file, $(SRCDIR)/opcontrol $(SRCDIR)/initialize $(SRCDIR)/autonomous,$(foreach cext,$(CEXTS),$(file).$(cext)) $(foreach cxxext,$(CXXEXTS),$(file).$(cxxext))) EXCLUDE_SRC_FROM_LIB+=$(SRCDIR)/scripts # exclude any files in the src/scripts directory EXCLUDE_SRC_FROM_LIB+=$(SRCDIR)/lcdselector.cpp # exclude src/lcdselector.cpp ``` -------------------------------- ### Install VEX Vision Utility using Homebrew on macOS Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/getting-started/macos.rst Installs the VEX Vision Utility, which is required for setting up signatures for the Vision Sensor. This command should be run after installing the PROS toolchain and CLI via Homebrew. ```bash brew install vcs-vision ``` -------------------------------- ### Start JINX Server Source: https://github.com/purduesigbots/pros-docs/blob/master/cortex/tutorials/jinx.rst This command starts the JINX server. It must be run from the JINX directory for the server to function correctly. The server enables the JINX dashboard accessible via a web browser. ```bash python3 JINX.py ``` -------------------------------- ### Initialize ADIPotentiometer in C++ Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/adi.rst Demonstrates how to initialize an ADIPotentiometer object using its port and type. The constructor takes an ADI port and an optional potentiometer type. The example shows a typical setup within the opcontrol loop to read the potentiometer's angle. ```cpp #define ADI_POTENTIOMETER_PORT 'a' #define SMART_PORT 1 void opcontrol() { pros::ADIPotentiometer potentiometer ({{ SMART_PORT , ADI_POTENTIOMETER_PORT }}); while (true) { // Get the potentiometer angle std::cout << "Angle: " << potentiometer.get_angle(); pros::delay(10); } } ``` -------------------------------- ### Install PROS Atom Plugins using APM Source: https://github.com/purduesigbots/pros-docs/blob/master/cortex/getting-started/debian-linux.rst Installs the necessary PROS Atom editor plugins using the Atom Package Manager (apm). This command ensures that Atom is configured to work with PROS, including features like file icons, linting, toolbars, and build tools. Ensure Atom and its dependencies are installed prior to running this command. ```bash apm install file-icons linter tool-bar tool-bar-main busy build pros ``` -------------------------------- ### Start JINX Reader Task (C) Source: https://github.com/purduesigbots/pros-docs/blob/master/cortex/tutorials/jinx.rst Initializes and starts the JINX reader task by calling `taskCreate`. This function should be called within the `initialize()` function of your PROS project. ```c taskCreate(JINXRun, TASK_DEFAULT_STACK_SIZE, NULL, (TASK_PRIORITY_DEFAULT)); ``` -------------------------------- ### Install pySerial using pip Source: https://github.com/purduesigbots/pros-docs/blob/master/cortex/tutorials/jinx.rst This command installs or upgrades the pySerial library, which is a requirement for JINX. It uses pip3, the package installer for Python 3. ```bash pip3 install pyserial ``` ```bash pip3 install --upgrade pyserial ``` -------------------------------- ### Initialize and Set LCD Text - C Example Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/llemu.rst Initializes the LCD and then sets the text on the first line to 'Hello World!'. This demonstrates a basic usage pattern for the lcd_initialize and lcd_set_text functions. ```c void initialize() { lcd_initialize(); lcd_set_text(1, "Hello World!"); } ``` -------------------------------- ### Get Vision Sensor Signature (C) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/vision.rst Retrieves the signature details for a specific signature ID on a Vision Sensor connected to a V5 port. The example shows how to get a signature and print its information. This function requires a valid port and signature ID. ```c #define VISION_PORT 1 #define EXAMPLE_SIG 1 void opcontrol() { vision_signature_s_t sig = vision_get_signature(VISION_PORT, EXAMPLE_SIG); vision_print_signature(sig); } ``` -------------------------------- ### Get Vision Sensor Object Count (C) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/vision.rst Gets the total number of objects currently detected by the Vision Sensor on a given V5 port. The example continuously prints the object count to the console every 2 milliseconds. Ensure the port number is valid (1-21). ```c #define VISION_PORT 1 void opcontrol() { while (true) { printf("Number of Objects Detected: %d\n", vision_get_object_count(VISION_PORT)); delay(2); } } ``` -------------------------------- ### Get ADI Encoder Value Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/adi_ext.rst Retrieves the current value of an ADI encoder. The value represents the signed and cumulative number of counts since the last start or reset. ```APIDOC ## ext_adi_encoder_get ### Description Retrieves the current value of an ADI encoder. Analogous to `pros::ADIEncoder::get_value <../cpp/adi.html#id11>`_. ### Method `ext_adi_encoder_get` ### Endpoint ```c int32_t ext_adi_encoder_get ( ext_adi_encoder_t enc ) ``` ### Parameters #### Path Parameters - **enc** (ext_adi_encoder_t) - Required - the `ext_adi_encoder_t`_ object from `ext_adi_encoder_init`_ to read, or simply the ADI port number. ### Request Example ```c #define ADI_EXPANDER_PORT 20 #define PORT_TOP 1 #define PORT_BOTTOM 2 void opcontrol() { ext_adi_encoder_t enc = ext_adi_encoder_init(ADI_EXPANDER_PORT, PORT_TOP, PORT_BOTTOM, false); while (true) { printf("Encoder Value: %d\n", ext_adi_encoder_get(enc)); delay(5); } } ``` ### Response #### Success Response (int32_t) - **value** (int32_t) - The signed and cumulative number of counts since the last start or reset. #### Response Example ```json { "value": 1234 } ``` ``` -------------------------------- ### Initialize, Set Text Color, and Text - C Example Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/llemu.rst Initializes the LCD, sets the text color to GOLD, and then displays 'Hello World!' on line 1. This shows combined color and text manipulation. ```c void initialize() { lcd_initialize(); lcd_set_text_color(COLOR_GOLD); lcd_set_text(1, "Hello World!"); } ``` -------------------------------- ### Get Current Task Handle Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/rtos.rst Obtains a handle to the currently executing task. This is useful within a task to reference itself, for example, to check its own state or priority. It takes no arguments and returns a task_t handle. ```c task_t task_get_current ( void ) ``` ```c void my_task_fn(void* param) { task_t this_task = task_get_current(); if (task_get_state(this_take) == E_TASK_STATE_RUNNING) { printf("This task is currently running\n"); } // ... } ``` -------------------------------- ### JINX Reader Initialization Source: https://github.com/purduesigbots/pros-docs/blob/master/cortex/tutorials/jinx.rst Explains how to start the JINX reader task by calling `taskCreate` with `JINXRun`. ```APIDOC ## JINX Reader Initialization ### Description The read task is started by calling `taskCreate` in `initialize()`. ### Method (Not applicable - Initialization code) ### Endpoint (Not applicable - Initialization code) ### Parameters #### Path Parameters (None) #### Query Parameters (None) #### Request Body (Not applicable - Initialization code) ### Request Example ```c taskCreate(JINXRun, TASK_DEFAULT_STACK_SIZE, NULL, (TASK_PRIORITY_DEFAULT)); ``` ### Response (Not applicable - Initialization code) #### Success Response (200) (Not applicable - Initialization code) #### Response Example (Not applicable - Initialization code) ``` -------------------------------- ### Get VEX Inertial Sensor Rotation (C++) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/imu.rst Provides an example of retrieving the total rotation in degrees from the VEX Inertial Sensor. The sensor's rotation is theoretically unbounded, with clockwise being positive. ```cpp #define IMU_PORT 1 void opcontrol() { pros::Imu imu_sensor(IMU_PORT); while (true) { printf("IMU get rotation: %f degrees\n", imu_sensor.get_rotation()); pros::delay(20); } } ``` -------------------------------- ### Get GPS Y Position (C++) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/gps.rst Retrieves the Y position in meters of the GPS sensor relative to its starting point. Similar to get_x_position, it handles errors such as ENXIO, ENODEV, and EAGAIN. The function returns a double representing the Y position or PROS_ERR_F on failure. ```cpp #define GPS_PORT 1 void opcontrol() { pros::Gps gps1(GPS_PORT); double y_pos; while (true) { y_pos = gps1.get_y_position(); pros::delay(20); } } ``` -------------------------------- ### Building PROS Documentation with Sphinx Source: https://context7.com/purduesigbots/pros-docs/llms.txt Direct Sphinx commands for building specific documentation sections. Includes instructions for running with auto-rebuild and a live reload server using `sphinx-autobuild`. ```bash # Build V5 documentation sphinx-build ./v5/ ./build/v5/ # Build Cortex documentation sphinx-build ./cortex/ ./build/cortex # Build home page sphinx-build ./home/ ./build/ # Run with auto-rebuild and live reload server pip install sphinx-autobuild sphinx-autobuild v5 build --port 8000 ``` -------------------------------- ### Building PROS Documentation with Make Source: https://context7.com/purduesigbots/pros-docs/llms.txt Commands to build the PROS documentation site using the Makefile. Supports building all sections, specific sections, quick builds, cleaning, and link checking. ```bash # Build all documentation sections (home, v5, cortex) make all # Build only specific sections make v5 # Build V5 documentation only make cortex # Build Cortex documentation only make home # Build home page only # Quick build without cleaning make quick # Clean all built files make clean # Check all links in documentation make linkcheck ``` -------------------------------- ### Get and Set Vision Sensor Exposure (C) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/vision.rst Retrieves the current exposure setting of a Vision Sensor on a specified V5 port. The example demonstrates checking if the exposure is below a threshold and setting it to 50 if it is. Valid ports are 1-21. ```c #define VISION_PORT 1 void initialize() { if (vision_get_exposure(VISION_PORT) < 50) vision_set_exposure(VISION_PORT, 50); } ``` -------------------------------- ### Get Ultrasonic Sensor Value in C Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/adi.rst Retrieves the current distance reading from an initialized ultrasonic sensor in centimeters. Returns 0 if no object is detected or PROS_ERR if the sensor was not properly started or if the port is misconfigured. Sensitive to object shape and texture. ```c int32_t adi_ultrasonic_get ( adi_ultrasonic_t ult ) ``` -------------------------------- ### Get GPS Roll (C++) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/gps.rst Retrieves the roll angle in degrees of the GPS sensor relative to its starting orientation. Error conditions include ENXIO, ENODEV, and EAGAIN. The function returns a double representing the roll or PROS_ERR_F upon failure. ```cpp #define GPS_PORT 1 void opcontrol() { pros::Gps gps1(GPS_PORT); double roll; while (true) { roll = gps1.get_roll(); pros::screen::print(TEXT_MEDIUM, 1, "Roll: %3f", roll); pros::delay(20); } } ``` -------------------------------- ### PROS Documentation Development Server with Grunt Source: https://context7.com/purduesigbots/pros-docs/llms.txt Configuration and commands for setting up a local development server with live reloading for PROS documentation. Uses Grunt to manage Sphinx builds and a connect server. ```javascript // Gruntfile.js configuration module.exports = function (grunt) { grunt.initConfig({ shell: { sphinx: { command: "rm -rf ./build && sphinx-build ./home/ ./build/", options: { stdout: true } } }, watch: { home: { files: "home/**/*", tasks: ["shell:sphinx"], options: { spawn: false, debounceDelay: 500 } }, livereload: { options: { livereload: true }, files: ["build/**/*"] } }, connect: { server: { options: { port: 9000, base: "./build", hostname: "0.0.0.0", protocol: "http", livereload: true, open: true } } } }); grunt.registerTask("default", ["shell:sphinx"]); grunt.registerTask("serve", ["connect", "watch"]); }; ``` ```bash # Install dependencies npm install # Run default build task grunt # Start development server with live reload grunt serve ``` -------------------------------- ### Get Accelerometer Values Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/gps.rst Retrieves the GPS's raw accelerometer values from a specified V5 GPS port. This function can return ENXIO, ENODEV, or EAGAIN on error. The example continuously reads and displays the X, Y, and Z acceleration. ```c #define GPS_PORT 1 void opcontrol() { struct gps_accel_s_t accel; while (true) { accel = gps_get_accel(GPS_PORT); screen_print(TEXT_MEDIUM, 1, "accleration- x: %3f, y: %3f, z: %3f", accel.x, accel.y, accel.z); } } ``` -------------------------------- ### Create New PROS Project using Terminal Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/cli/conductor.rst This command initializes a new PROS project in the specified directory, downloading and applying specified kernel and library templates. It outputs the project details including the name, version, and origin of applied templates. Dependencies include the PROS CLI and network access to template repositories. ```console > pros conduct new-project ./Top-5-At-Worlds Updating pros-mainline... Done Downloading kernel@3.0.7 (https://www.cs.purdue.edu/~brookea/kernel@3.0.7.zip) [####################################] 100% Extracting kernel@3.0.7 [####################################] 100% Fetched kernel@3.0.7 from pros-mainline depot Adding kernel@3.0.7 to registry...Done Applying kernel@3.0.7 [####################################] 100% Finished applying kernel@3.0.7 to ./Top-5-At-Worlds Downloading okapilib@3.0.1 (https://www.cs.purdue.edu/~berman5/okapilib@3.0.1.zip) [####################################] 100% Extracting okapilib@3.0.1 [####################################] 100% Fetched okapilib@3.0.1 from pros-mainline depot Adding okapilib@3.0.1 to registry...Done Applying okapilib@3.0.1 [####################################] 100% Finished applying okapilib@3.0.1 to ./Top-5-At-Worlds New PROS Project was created: PROS Project for v5 at: /home/me/Top-5-At-Worlds (Top-5-At-Worlds) Name Version Origin -------- --------- ------------- kernel 3.0.7 pros-mainline okapilib 3.0.1 pros-mainline ``` -------------------------------- ### Get GPS Yaw (C++) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/gps.rst Retrieves the yaw angle in degrees of the GPS sensor relative to its starting orientation. Error codes ENXIO, ENODEV, and EAGAIN may be returned. The function returns a double representing the yaw or PROS_ERR_F if the operation fails. ```cpp #define GPS_PORT 1 void opcontrol() { pros::Gps gps1(GPS_PORT); double yaw; while (true) { yaw = gps1.get_yaw(); pros::screen::print(TEXT_MEDIUM, 1, "Yaw: %3f", yaw); pros::delay(20); } } ``` -------------------------------- ### PROS Template Building and Application Source: https://context7.com/purduesigbots/pros-docs/llms.txt Bash commands for building a PROS library template into a distributable zip file and then fetching and applying it to another project. ```bash # Build and create template archive pros make template # Output: libbest@1.0.0.zip in project directory # Install template locally pros conduct fetch libbest@1.0.0.zip # Apply to another project cd ../other-project pros conduct apply libbest ``` -------------------------------- ### Get GPS Pitch (C++) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/gps.rst Retrieves the pitch angle in degrees of the GPS sensor relative to its starting orientation. This function also handles potential errors like ENXIO, ENODEV, and EAGAIN. It returns a double representing the pitch or PROS_ERR_F if an error occurs. ```cpp #define GPS_PORT 1 void opcontrol() { pros::Gps gps1(GPS_PORT); double pitch; while (true) { pitch = gps1.get_pitch(); pros::screen::print(TEXT_MEDIUM, 1, "Pitch: %3f", pitch); pros::delay(20); } } ``` -------------------------------- ### Initialize Potentiometer (C) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/adi.rst Initializes a potentiometer on a specified ADI port and continuously prints its angle. This example uses `adi_potentiometer_init` and `adi_potentiometer_get_angle`, requiring the PROS C API and `printf`/`delay`. ```c #define POTENTIOMETER_PORT 1 void opcontrol() { adi_potentiometer_t potentiometer = adi_potentiometer_init(POTENTIOMETER_PORT); while (true) { // Print the potentiometer's angle printf("Angle: %lf\n", adi_potentiometer_get_angle(potentiometer)); delay(5); } } ``` -------------------------------- ### PROS Motor Initialization and Basic Movement (C++) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/motors.rst Demonstrates how to initialize a PROS Motor object and control its speed using controller input. The motor's movement is directly mapped to the Y-axis analog stick of the controller. This example assumes a standard V5 controller setup. ```cpp void opcontrol() { pros::Motor motor (1); pros::Controller master (E_CONTROLLER_MASTER); while (true) { motor.move(master.get_analog(E_CONTROLLER_ANALOG_LEFT_Y)); pros::delay(2); } } ``` -------------------------------- ### Get GPS Y Position (C) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/gps.rst Retrieves the Y position in meters relative to the starting point from the GPS sensor. Requires a valid V5 GPS port. Returns PROS_ERR_F on failure, with errno set to indicate the specific error (e.g., ENXIO, ENODEV, EAGAIN). ```c double gps_get_y_position(uint8_t port) ``` ```c #define GPS_PORT 1 void opcontrol() { double y_pos; while (true) { y_pos = gps_get_y_position(GPS_PORT); delay(20); } } ``` -------------------------------- ### Initialize LLEMU Display Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/tutorials/topical/llemu.rst Initializes the Legacy LCD Emulator (LLEMU) for displaying information. This function should be called once at the beginning of the program, typically within the initialize() function. It is available in both C++ and C. ```cpp void initialize() { pros::lcd::initialize(); } ``` ```c void initialize() { lcd_initialize(); } ``` -------------------------------- ### Install PROS CLI using Python Pip on macOS Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/getting-started/macos.rst Installs the PROS Command Line Interface (CLI) using Python's package installer (pip). This method requires Python 3.6 or higher to be installed on your system. ```bash python3 -m pip install pros-cli ``` -------------------------------- ### Get Ultrasonic Sensor Value (C) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/adi_ext.rst Retrieves the current distance reading from an ultrasonic sensor in centimeters. This function requires the ultrasonic sensor to be properly configured and initialized. It returns 0 if no object is detected, PROS_ERR if the sensor was not started, or the distance reading. ```c #define PORT_PING 1 #define PORT_ECHO 2 // Example usage would require further context for 'ult' parameter // For instance: ext_adi_ultrasonic_t ult = ext_adi_ultrasonic_init(PORT_PING, PORT_ECHO); // int distance = ext_adi_ultrasonic_get(ult); ``` -------------------------------- ### PROS Conductor CLI - Creating New Projects Source: https://context7.com/purduesigbots/pros-docs/llms.txt Commands for using the PROS Conductor CLI to create new robotics projects. Supports V5 and Cortex targets and demonstrates querying available templates. ```bash # Create new V5 project with default templates (kernel + okapilib) pros conduct new-project ./Top-5-At-Worlds # Output example: # Updating pros-mainline... Done # Downloading kernel@3.0.7... Done # Extracting kernel@3.0.7... Done # Applying kernel@3.0.7... Done # Downloading okapilib@3.0.1... Done # Applying okapilib@3.0.1... Done # New PROS Project was created: # PROS Project for v5 at: /home/me/Top-5-At-Worlds # Name Version Origin # -------- --------- ------------- # kernel 3.0.7 pros-mainline # okapilib 3.0.1 pros-mainline # Create project targeting Cortex instead of V5 pros conduct new-project ./my-cortex-project --target cortex # Query available templates pros conduct query --force-refresh # List locally cached templates pros conduct info-project ``` -------------------------------- ### Get GPS X Position (C++) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/gps.rst Retrieves the X position in meters of the GPS sensor relative to its starting point. It can return errors like ENXIO, ENODEV, or EAGAIN if the sensor is not properly configured or is calibrating. The function returns a double representing the X position or PROS_ERR_F on failure. ```cpp #define GPS_PORT 1 void opcontrol() { pros::Gps gps1(GPS_PORT); double x_pos; while (true) { x_pos = gps1.get_x_position(); pros::delay(20); } } ``` -------------------------------- ### Get GPS X Position (C) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/gps.rst Retrieves the X position in meters relative to the starting point from the GPS sensor. Requires a valid V5 GPS port. Returns PROS_ERR_F on failure, with errno set to indicate the specific error (e.g., ENXIO, ENODEV, EAGAIN). ```c double gps_get_x_position(uint8_t port) ``` ```c #define GPS_PORT 1 void opcontrol() { double x_pos; while (true) { x_pos = gps_get_x_position(GPS_PORT); delay(20); } } ``` -------------------------------- ### ext_adi_led_init Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/adi_ext.rst Initializes an ADI Expander port as an LED strip. This function sets up the specified smart port and ADI port for LED control. ```APIDOC ## ext_adi_led_init ### Description Initializes an ADI Expander port as an LED strip. ### Method `ext_adi_led_init` ### Endpoint N/A (This is a library function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Parameters - **smart_port** (uint8_t) - Required - The smart port number the ADI Expander is in. - **adi_port** (uint8_t) - Required - The ADI port number (from 1-8, 'a'-'h', 'A'-'H') to initialize as an led. ### Request Example ```c #define LED_PORT 1 #define ADI_EXPANDER_PORT 20 void initialize() { ext_adi_led_t led = ext_adi_led_init(ADI_EXPANDER_PORT, LED_PORT); } ``` ### Response #### Success Response - **ext_adi_led_t** - An `ext_adi_led_t` object containing the given port. #### Response Example `ext_adi_led_t led` ### Error Handling - **PROS_ERR**: Initialization failed. ``` -------------------------------- ### Initialize and Set LCD Background Color - C Example Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/llemu.rst Initializes the LCD and sets its background color to GOLD. This demonstrates how to customize the LCD's appearance. ```c void initialize() { lcd_initialize(); lcd_set_background_color(COLOR_GOLD); } ``` -------------------------------- ### PROS Mutex Constructor and Basic Usage Example (C) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/rtos.rst Shows how to create and use a PROS Mutex. The Mutex constructor initializes a new mutex object. The `take` method acquires the mutex (blocking if necessary), and `give` releases it. This is analogous to C RTOS `mutex_create`, `mutex_take`, and `mutex_give` functions. ```c Mutex mutex; // Acquire the mutex; other tasks using this command will wait until the mutex is released // timeout can specify the maximum time to wait, or MAX_DELAY to wait forever // If the timeout expires, "false" will be returned, otherwise "true" mutex.take(MAX_DELAY); // do some work // Release the mutex for other tasks mutex.give(); // Destructor called here ``` -------------------------------- ### Check SD Card Installation Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/misc.rst Checks if an SD card is installed in the PROS system. Returns 1 if installed, 0 otherwise. ```c std::int32_t pros::usd::is_installed ( ) ``` ```c void opcontrol() { std::cout << pros::usd::is_installed() << std::endl; } ``` -------------------------------- ### Add External Library Depot (Atom IDE) Source: https://github.com/purduesigbots/pros-docs/blob/master/cortex/tutorials/libraries.rst Steps to configure a new library depot within the PROS Atom IDE's Conductor. This involves specifying the depot name and its location, typically a GitHub repository. ```none Name the depot: libblrs Depot location: purduesigbots/libblrs ``` -------------------------------- ### Python Sphinx Configuration for PROS V5 Source: https://context7.com/purduesigbots/pros-docs/llms.txt This Python script configures the Sphinx documentation generator for the PROS V5 project. It sets up project information, integrates necessary extensions for features like blogging and command-line interface documentation, and specifies the HTML theme and path. It also defines project versioning, copyright information, and GitHub repository details for integrated display. ```python import os import sys import ablog sys.path.append(os.path.abspath('../sphinx-tabs/sphinx_tabs/')) # Extensions extensions = ['tabs', 'ablog', 'sphinx_click.ext'] # Project information project = u'PROS for V5' copyright = u'2023, Purdue ACM SIGBots. Released under the MPL 2.0 license' version = u'V5 (3.8.0)' release = u'3.8.0' # Theme configuration html_theme = 'sphinx_rtd_theme' html_theme_path = ["../sphinx_rtd_theme"] html_context = { 'display_github': True, 'github_user': 'purduesigbots', 'github_repo': 'pros-docs', 'github_version': 'master/v5/' } html_theme_options = { 'analytics_id': 'UA-84548828-3', 'versions': { 'V5': 'index', 'Cortex': '../cortex/index', }, 'navigation_depth': 8 } # Static files and templates templates_path = [ablog.get_html_templates_path(), '_templates'] html_static_path = ['_static'] html_logo = "../common/images/logo.svg" html_favicon = "../common/_static/favicon.ico" # Build settings source_suffix = '.rst' master_doc = 'index' pygments_style = 'monokai' highlight_language = "c" exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store'] ``` -------------------------------- ### Get Roll Angle from PROS Inertial Sensor (C++) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/imu.rst Retrieves the roll angle of the Inertial Sensor, bounded between -180 and 180 degrees. This function helps determine the device's tilt side-to-side. Failures, indicated by PROS_ERR_F and set errno, can occur due to invalid port configuration, sensor setup problems, or ongoing calibration. ```cpp #define IMU_PORT 1 void opcontrol() { pros::Imu imu_sensor(IMU_PORT); while (true) { printf("IMU roll: %f\n", imu_sensor.get_roll()); pros::delay(20); } } ``` -------------------------------- ### Configure Project as a PROS Library in Makefile Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/tutorials/topical/wireless-upload.rst This snippet shows how to configure your PROS project to be compiled as a library, which can then be included in the 'cold image' for optimized uploads. This involves setting IS_LIBRARY to 1 and defining a LIBNAME and VERSION. Specific source files can be excluded from the library. ```Makefile # Set this to 1 to add additional rules to compile your project as a PROS library template IS_LIBRARY:=1 # TODO: CHANGE THIS! LIBNAME:=libbest VERSION:=1.0.0 # EXCLUDE_SRC_FROM_LIB= $(SRCDIR)/unpublishedfile.c ``` -------------------------------- ### PROS Conductor: Template Management Commands Source: https://context7.com/purduesigbots/pros-docs/llms.txt Commands for managing PROS library templates, including installing specific versions, fetching from remote or local sources, upgrading, and uninstalling. ```bash pros conduct apply okapilib@3.2.0 pros conduct fetch kernel@3.1.0 pros conduct fetch mylibrary@1.0.0.zip pros conduct upgrade pros conduct upgrade kernel pros conduct uninstall okapilib ``` -------------------------------- ### Motor Get Efficiency Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/motors.rst Gets the efficiency of the motor in percent. This function is analogous to motor_get_efficiency. ```APIDOC ## GET /api/motors/efficiency ### Description Gets the efficiency of the motor in percent. ### Method GET ### Endpoint `/api/motors/efficiency` ### Parameters None ### Request Example ```cpp // No request body for this GET request ``` ### Response #### Success Response (200) - **efficiency_percent** (int32_t) - The motor's efficiency in percent (0-100). #### Error Response (e.g., 500) - **error_code** (string) - 'ENODEV' if the port cannot be configured as a motor. #### Response Example ```json { "efficiency_percent": 95 } ``` #### Error Response Example ```json { "error_code": "ENODEV" } ``` ``` -------------------------------- ### Initialize LED Strip (C) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/adi.rst Initializes an LED strip connected to a specified ADI port. This function is the first step before manipulating the LEDs and requires the ADI port number. It's analogous to `pros::ADILed::ADILed`. ```c #define LED_PORT 1 adi_led_t adi_led_init ( uint8_t port ) ``` -------------------------------- ### Motor Get Direction Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/motors.rst Gets the direction of movement for the motor. This function is analogous to motor_get_direction. ```APIDOC ## GET /api/motors/direction ### Description Gets the direction of movement for the motor. ### Method GET ### Endpoint `/api/motors/direction` ### Parameters None ### Request Example ```cpp // No request body for this GET request ``` ### Response #### Success Response (200) - **direction** (int32_t) - 1 for positive direction, -1 for negative direction. #### Error Response (e.g., 500) - **error_code** (string) - 'ENODEV' if the port cannot be configured as a motor. #### Response Example ```json { "direction": 1 } ``` #### Error Response Example ```json { "error_code": "ENODEV" } ``` ``` -------------------------------- ### Motor Get Current Draw Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/motors.rst Gets the current drawn by the motor in mA. This function is analogous to motor_get_current_draw. ```APIDOC ## GET /api/motors/current_draw ### Description Gets the current drawn by the motor in mA. ### Method GET ### Endpoint `/api/motors/current_draw` ### Parameters None ### Request Example ```cpp // No request body for this GET request ``` ### Response #### Success Response (200) - **current_mA** (int32_t) - The motor's current in mA. #### Error Response (e.g., 500) - **error_code** (string) - 'ENODEV' if the port cannot be configured as a motor. #### Response Example ```json { "current_mA": 500 } ``` #### Error Response Example ```json { "error_code": "ENODEV" } ``` ``` -------------------------------- ### Initialize VEX Optical Sensor with Integration Time (C++) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/optical.rst Constructs a VEX Optical Sensor object with a specified V5 port and integration time. The integration time is clamped between 3ms and 712ms. The port must be between 1-21 and configurable as an Optical Sensor. ```cpp #define OPTICAL_PORT 1 void initialize() { pros::Optical optical_sensor(OPTICAL_PORT, 50); } ``` -------------------------------- ### pros::Optical Constructor (Port and Time) Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/optical.rst Initializes the VEX Optical Sensor with a specified V5 port and integration time. ```APIDOC ## pros::Optical(const std::uint8_t port, double time) ### Description Initializes the VEX Optical Sensor with a specific V5 port and sets the integration time for sensor updates. ### Method Constructor ### Endpoint N/A (Class Constructor) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * **port** (uint8_t) - Required - The V5 port number from 1-21. * **time** (double) - Required - The integration time (update rate) in milliseconds, clamped to the range 3ms - 712ms. The default is 100 ms. ### Request Example ```cpp #define OPTICAL_PORT 1 void initialize() { pros::Optical optical_sensor(OPTICAL_PORT, 50); } ``` ### Response #### Success Response (200) N/A (Constructor) #### Response Example N/A (Constructor) ``` -------------------------------- ### Motor Get Actual Velocity Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/motors.rst Gets the actual velocity of the motor. This function is analogous to motor_get_actual_velocity. ```APIDOC ## GET /api/motors/actual_velocity ### Description Gets the actual velocity of the motor. ### Method GET ### Endpoint `/api/motors/actual_velocity` ### Parameters None ### Request Example ```cpp // No request body for this GET request ``` ### Response #### Success Response (200) - **velocity** (double) - The motor's actual velocity in RPM. #### Error Response (e.g., 500) - **error_code** (string) - 'ENODEV' if the port cannot be configured as a motor. #### Response Example ```json { "velocity": 150.5 } ``` #### Error Response Example ```json { "error_code": "ENODEV" } ``` ``` -------------------------------- ### speakerInit Source: https://github.com/purduesigbots/pros-docs/blob/master/cortex/api/index.rst Initializes the VEX speaker. Note that the speaker is not thread-safe and may impact robot performance. ```APIDOC ## speakerInit ### Description Initializes VEX speaker support. ### Method ``` void speakerInit ( ) ``` ### Notes - The VEX speaker is not thread safe; it can only be used from one task at a time. - Using the VEX speaker may impact robot performance. - Consider enabling sound only if `isOnline` returns false to optimize performance. ``` -------------------------------- ### get() - Get Distance Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/distance.rst Retrieves the currently measured distance from the sensor in millimeters. ```APIDOC ## get() - Get Distance ### Description Retrieves the currently measured distance from the sensor in millimeters. Returns PROS_ERR if the operation fails. ### Method GET ### Endpoint N/A (C++ API) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```cpp #define DISTANCE_PORT 1 void opcontrol() { pros::Distance distance_sensor(DISTANCE_PORT); while (true) { printf("Distance: %d mm\n", distance_sensor.get()); pros::delay(20); } } ``` ### Response #### Success Response (200) - **distance** (int32_t) - The measured distance in millimeters. #### Response Example ```json { "distance": 1500 } ``` ``` -------------------------------- ### Motor Get Target Velocity Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/motors.rst Gets the velocity commanded to the motor by the user. This function is analogous to motor_get_target_velocity. ```APIDOC ## GET /api/motors/target_velocity ### Description Gets the velocity commanded to the motor by the user. ### Method GET ### Endpoint `/api/motors/target_velocity` ### Parameters None ### Request Example ```cpp // No request body for this GET request ``` ### Response #### Success Response (200) - **velocity** (int32_t) - The commanded motor velocity from +-100, +-200, +-600. #### Error Response (e.g., 500) - **error_code** (string) - 'ENODEV' if the port cannot be configured as a motor. #### Response Example ```json { "velocity": 100 } ``` #### Error Response Example ```json { "error_code": "ENODEV" } ``` ``` -------------------------------- ### Initialize JINX Debugging Source: https://github.com/purduesigbots/pros-docs/blob/master/cortex/tutorials/jinx.rst Initializes and enables JINX on the specified serial port. This function should be called within the `initialize()` function of your PROS project. It takes a file pointer for the port as input and prints an error to stdout if initialization fails. ```c void initJINX ( FILE * port ) ``` -------------------------------- ### Motor Get Target Velocity API Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/motors.rst Gets the velocity commanded to the motor by the user. ```APIDOC ## GET /api/motor/get_target_velocity ### Description Gets the velocity commanded to the motor by the user. ### Method GET ### Endpoint /api/motor/get_target_velocity ### Parameters #### Query Parameters - **port** (uint8_t) - Required - The V5 port number from 1-21 ### Request Example ```json { "port": 1 } ``` ### Response #### Success Response (200) - **target_velocity** (int32_t) - The commanded velocity. #### Response Example ```json { "target_velocity": 50 } ``` ### Error Handling - **ENXIO**: The given value is not within the range of V5 ports (1-21). - **ENODEV**: The port cannot be configured as a motor. ``` -------------------------------- ### Build and Upload Code using PROS CLI Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/tutorials/walkthrough/clawbot.rst Commands to build and upload code to the robot using the PROS command-line interface. The 'pros mu' command is a shortcut for 'pros make' and 'pros upload'. ```bash pros make pros upload ``` ```bash pros mu ``` -------------------------------- ### Task Get Current API Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/rtos.rst Gets a handle to the task which called this function. ```APIDOC ## GET /api/rtos/tasks/current ### Description Gets a handle to the task which called this function. ### Method GET ### Endpoint /api/rtos/tasks/current ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) - **handle** (task_t) - A handle to the currently running task. #### Response Example { "handle": 1234567890 } ``` -------------------------------- ### Initialize ADILed with ADI Port in C++ Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/adi.rst Shows how to create an ADILed object using a single ADI port and the number of LEDs. This constructor is suitable when the LEDs are connected directly to an ADI port. The example demonstrates a basic initialization within an initialize function. ```cpp #define LED_PORT 1 #define LED_SIZE 64 void initalize() { pros::ADILed led (LED_PORT, LED_SIZE); // Use the led } ``` -------------------------------- ### Initialize LCD Emulation - pros::lcd::initialize() Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/cpp/llemu.rst Initializes the display to emulate the three-button, UART-based VEX LCD. This function returns true if initialization is successful and false if it has already been initialized. It is a prerequisite for most other LCD functions. ```cpp void initialize() { pros::lcd::initialize(); pros::lcd::set_text(1, "Hello World!"); } ``` -------------------------------- ### Motor Get Target Position API Source: https://github.com/purduesigbots/pros-docs/blob/master/v5/api/c/motors.rst Gets the target position set for the motor by the user. ```APIDOC ## GET /api/motor/get_target_position ### Description Gets the target position set for the motor by the user. ### Method GET ### Endpoint /api/motor/get_target_position ### Parameters #### Query Parameters - **port** (uint8_t) - Required - The V5 port number from 1-21 ### Request Example ```json { "port": 1 } ``` ### Response #### Success Response (200) - **target_position** (double) - The target position in its encoder units. #### Response Example ```json { "target_position": 100.0 } ``` ### Error Handling - **ENXIO**: The given value is not within the range of V5 ports (1-21). - **ENODEV**: The port cannot be configured as a motor. ``` -------------------------------- ### JINX Debugger - initJINX Source: https://github.com/purduesigbots/pros-docs/blob/master/cortex/tutorials/jinx.rst Initializes and enables JINX on the specified port. This function should be called in the initialize() function of your PROS project. ```APIDOC ## void initJINX(FILE *port) ### Description Initializes and enables JINX on the specified port. This function should be called in the `initialize()` function of your PROS project. It prints an error message to stdout if initialization or port setting fails. ### Method `initJINX` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```c void initialize() { // Initialize JINX on UART1 initJINX(uart1); } ``` ### Response #### Success Response (N/A) This function does not return a value, but logs errors to stdout if initialization fails. #### Response Example N/A ```