#vex #vex-robotics #api-bindings #vex-v5 #vex-vrc

nightly sys no-std safe-vex

A modular, safe and data-orientated rust wrapper over the Purdue PROS library for Vex Robotics

57 releases (34 stable)

4.4.0 Nov 10, 2024
4.3.1-alpha Oct 18, 2024
3.2.3-experimental May 15, 2024
3.2.1 Sep 9, 2024
0.3.2 Nov 16, 2023

#16 in Robotics

Download history 348/week @ 2024-07-29 63/week @ 2024-08-05 49/week @ 2024-08-12 130/week @ 2024-09-02 234/week @ 2024-09-09 50/week @ 2024-09-16 23/week @ 2024-09-23 39/week @ 2024-09-30 4/week @ 2024-10-07 768/week @ 2024-10-14 64/week @ 2024-10-21 183/week @ 2024-10-28 382/week @ 2024-11-04 92/week @ 2024-11-11

761 downloads per month

MIT/Apache

2.5MB
757 lines

safe-vex

A modular, safe and data-orientated rust wrapper over the Purdue PROS library for Vex Robotics

Disclamer

safe-vex is an open-source project by kalscium. safe-vex is neither endorsed by or affiliated with Innovation First, Inc. VEX and VEX Robotics are trademarks or service marks of Innovation First, Inc. safe-vex is also not developed by nor endorsed by the developers of the Purdue PROS library.

Quickstart (Nix)

you will need:

  1. nix
  2. nix flakes

then:

  1. Clone the safe-vex project template by running the following command:
  git clone https://github.com/kalscium/safe-vex-template.git
  1. Enter the newly cloned directory
  2. Enter the nix dev-environment with
  nix develop
  1. Turn on and connect to the vex v5 brain
  2. Give permission to upload code to the robot with: (doesn't matter if this fails)
  sudo chmod a+rw /dev/ttyACM0 || sudo chmod a+rw /dev/ttyACM1
  1. While connected to the v5 brain run:
  cargo run --release
  1. Your robot should now be up and running :D

Quickstart (Debian)

you will need:

  1. A rust toolchain managed by rustup:
  2. An arm-none-eabi toolchain
  3. gcc and libclang-dev/libclang
  4. (optional) libc6-dev if rustc is throwing the error:
--- stderr
/usr/lib/arm-none-eabi/include/sys/reent.h:14:10: fatal error: 'stddef.h' file not found
thread 'main' panicked at /home/dev/.cargo/registry/src/index.crates.io-6f17d22bba15001f/vex-rt-0.15.1/build/main.rs:266:10:
Could not generate bindings.: ClangDiagnostic("/usr/lib/arm-none-eabi/include/sys/reent.h:14:10: fatal error: 'stddef.h' file not found\n")
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
  1. The pros-cli installed through pip

then:

  1. Clone the safe-vex project template by running the following command:
  git clone https://github.com/kalscium/safe-vex-template.git
  1. Enter the newly cloned directory
  2. Turn on and connect to the vex v5 brain
  3. Give permission to upload code to the robot with: (doesn't matter if this fails)
  sudo chmod a+rw /dev/ttyACM0 || sudo chmod a+rw /dev/ttyACM1
  1. While connected to the v5 brain run:
  cargo run --release
  1. Your robot should now be up and running :D

Updating the PROS Library Version


(For future reference for the maintainence of this library) To update the pros library version used by safe-vex, follow the following steps (with the correct toolchains installed)

  1. Enter the build directory of the library

While inside the build dir

  1. Create an empty pros project
  pros conductor new kernel
  1. Delete the unnecessary bloat libraries and files that are irrelevant to PROS
  rm -rf kernel/bin kernel/firmware/{okapilib.a,squiggles.mk} kernel/okapi
  1. Rename the project.pros file to template.pros and take note of the version
  mv kernel/project.pros kernel/template.pros
  {
    "py/state": {
      "templates": {
        "kernel": {
          "target": "v5",
          "version": "<version>, eg 1.0.0 (TAKE NOTE OF THIS FOR LATER STEPS)",
        }
      }
    }
  }
  1. Zip and package the kernel for compilation use
  (cd kernel && zip ../kernel@VERSION.zip -r *)
  rm -rf kernel
  1. Update references to the kernel package in bindgen build code (still in the build dir main.rs)
  // Path to PROS release zip (relative to project root)
  const PROS_ZIP_STR: &str = "build/kernel@VERSION.zip"; // update the vesrion

In the project root

  1. Clean the project and publish it (given you have changed the project version in Cargo.toml to something appropriate to this update to the kernel)
  cargo clean
  cargo publish

Dependencies