| Crates.io | pros-simulator |
| lib.rs | pros-simulator |
| version | 0.5.0 |
| created_at | 2023-10-17 03:53:18.384092+00 |
| updated_at | 2024-01-05 05:42:11.250615+00 |
| description | Run PROS robot code without the need for real VEX V5 hardware. |
| homepage | |
| repository | https://github.com/pros-rs/pros-simulator |
| max_upload_size | |
| id | 1005488 |
| size | 86,650 |
Run PROS robot code without the need for real VEX V5 hardware.
cargo add pros-simulator
Or, as an executable JSON-based server:
cargo install pros-simulator-server
This Rust crate is a WebAssembly-based runtime for simulating VEX V5 robot code, without the need for any special hardware. It's the best way to program from home, debug misbehaving programs, and quickly iterate code design.
This runtime implements a portion of the PROS C interface, allowing pre-existing PROS-based programs to function in the simulator without the need for invasive modification. Support for pros-simulator is built directly into the pros crate, so programs using it will be compatible with this simulator without extra work.
PROS Simulator is available in library form, and also as a JSON-based server that's inspired by the LSP protocol and ideal for integrating into other programs (see releases page for ready made binaries). This project contains the core of the simulator, which handles loading and running user-generated robot code, and requires a custom interface (like a GUI or TUI) to be useful. There are a few example interfaces provided, like the TUI-based one below.

To build the example simulator program, you'll need a nightly Rust toolchain and the was32-unknown-unknown target installed. In the example directory, run the following command to build:
cargo pros build -s
Then, in the project root, run the following command to start the TUI:
cargo run --example tui ./example/target/wasm32-unknown-unknown/debug/example.wasm
The simulator (and its TUI interface) support the use of breakpoints in robot code! Try opening this project in VS Code and pressing F5 to start debugging the example program.
See PROS docs for signatures and documentation. API is 1:1 except where mentioned otherwise.
LLEMU (Legacy LCD Emulator) C API
lcd_clearlcd_clear_linelcd_initializelcd_is_initializedlcd_printlcd_read_buttonslcd_register_btn0_cblcd_register_btn1_cblcd_register_btn2_cblcd_set_textlcd_shutdownlcd_set_background_colorlcd_set_text_colorMiscellaneous C API
battery_get_capacitybattery_get_currentbattery_get_temperaturebattery_get_voltagecompetition_get_statuscompetition_is_autonomouscompetition_is_connectedcompetition_is_disabledcontroller_clearcontroller_clear_linecontroller_get_analogcontroller_get_battery_capacitycontroller_get_battery_level (Return value always equal to capacity)controller_get_digitalcontroller_get_digital_new_presscontroller_is_connectedcontroller_printcontroller_rumblecontroller_set_textusd_is_installedRTOS Facilities C API
delaymillismicrosmutex_createmutex_deletemutex_givemutex_taketask_createtask_delaytask_delay_untiltask_deletetask_get_by_nametask_get_counttask_get_currenttask_get_nametask_get_prioritytask_get_statetask_notifytask_notify_cleartask_notify_exttask_notify_taketask_jointask_resumetask_set_prioritytask_suspendrtos_suspend_allrtos_resume_allpvTaskGetThreadLocalStoragePointervTaskSetThreadLocalStoragePointerxTaskAbortDelayGeneric I/O API
Undocumented/internal PROS functions that are required to support
miscellaneous IO like errno, the debug terminal, and panicking.
_errno: Returns a mutable pointer to the errno value of the current task.sim_abort(*const char) -> !: Simulator-only API for aborting with an error message.sim_log_backtrace() -> (): Simulator-specific function that will print a backtrace to the debug terminal.puts: Write to the debug terminal (pros terminal command from official PROS CLI)exit: Cleanly shutdown