Crate pros

source ·
Expand description

§Pros

Opinionated bindings for the PROS library and kernel. Not everything in this library is one to one with the PROS API.

Advantages over similar libraries or PROS itself:

  • Pros-rs has an Async executor which allows for easy and performant asynchronous code.
  • Simulation support with pros-simulator and any interface with it (e.g. pros-simulator-gui)
  • Active development. Pros-rs is actively developed and maintained.
  • Pros-rs is a real crate on crates.io instead of a template, or similar. This allows for dependency management with cargo.

§Usage

When using pros, you have a few options for how you want to get started. You have two options: async and sync. When using async, an async executor is started and you can use it to run code asynchronously without any FreeRTOS tasks. When using sync, if you want to run code asynchronously you must create a FreeRTOS task.

Here are some examples of both:

// Async
use pros::prelude::*;

#[derive(Default)]
struct Robot;
impl AsyncRobot for Robot {
   async fn opcontrol(&mut self) -> Result {
      loop {
        // Do something
       sleep(Duration::from_millis(20)).await;
      }
   }
}
async_robot!(Robot);
 // Sync
 use pros::prelude::*;

 #[derive(Default)]
 struct Robot;
 impl SyncRobot for Robot {
   fn opcontrol(&mut self) -> Result {
      loop {
       // Do something
      delay(Duration::from_millis(20));
      }
    }
 }
 sync_robot!(Robot);

You may have noticed the #[derive(Default)] attribute on these Robot structs. If you want to learn why, look at the docs for pros_async::async_robot or [pros_sync::sync_robot].

Re-exports§

Modules§

  • Commonly used features of pros-rs. This module is meant to be glob imported.