Skip to content
This repository has been archived by the owner on Jun 19, 2024. It is now read-only.

refactor(breaking): Vision Sensor #77

Draft
wants to merge 19 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: nightly-2024-02-07
override: true

- name: Check
Expand All @@ -33,7 +33,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
toolchain: nightly-2024-02-07
override: true

- name: Setup | Install Rustfmt
Expand All @@ -57,4 +57,4 @@ jobs:
with:
reporter: 'github-pr-check'
github_token: ${{ secrets.GITHUB_TOKEN }}
clippy_flags: --all-targets --all-features
clippy_flags: --all-targets --all-features
63 changes: 62 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,67 @@ Before releasing:
### Fixed

### Changed
- Refactored the vision sensor API. (**Breaking Change**) (#77)

### Removed

## [0.8.0]

### Added
- Added feedforward motor controllers (#80)
- Lightly document all APIs with missing documentation. (#70)
- Added `Debug`, `Copy`, and `Clone` derives for common structs (#70)
- Screen drawing API. (#81)
- Added screen field to `Peripherals` and `DynamicPeripherals::take_screen` method. (#81)
- Added `AdiSolenoid`, a wrapper over `AdiDigitalOut` for actuating SMC pneumatic solenoids. (#61)
- Added `AdiSwitch`, another `AdiDigitalOut` wrapper that abstracts bumper switches and limit switches. (#61)
- Added `AdiLineTracker` for abstracting the EDR line tracker sensor.

### Fixed

- Fix error handling and error type variats in ADI bindings
- Fix `AsynRobot` only running opcontrol
- Properly handle `EADDRINUSE` return for smart port errors (**Breaking Change**) (#97)

### Changed

- Re-exported printing macros from `pros::io`. (#82)
- Applied several lints to improve code quality. (#70)
- Updated to PROS version 4. (**Breaking Change**) (#81)
- Moved `vision::Rgb` into its own `color.rs` file. (**Breaking Change**) (#81)
- The VEXOS target has been updated to improve file size and floating point operation speed. (#81)
- `Peripherals::new()` is no longer const (**Breaking Change) (#81)
- Updated panic handler to print to the brain display as well as over serial (#81)
- Refactors digital and analog ADI input/output. (**Breaking Change**) (#61)
- Adds LogicLevel rather than bools for controlling digital devices.
- Adds 0-5V voltage getters and setters for analog ADI.
- Changed analog getters and setters to use `u16` data.
- Changed `AdiPotentiometer` to return degrees rather than tenth degrees (**Breaking Change**) (#61).
- Renamed `AdiPotentiometer::value` to `AdiPotentiometer::angle`.
- Refactors `AdiMotor` to match the smart motor APIs, having output/raw output getters/setters.
- Renamed `AdiUltrasonic::value` to `AdiUltrasonic::distance` (**Breaking Change**) (#61).
- Renamed `AdiEncoder::value` to `AdiEncoder::position` (**Breaking Change**) (#61).
- Repurposed `AdiAnalogOut` as `AdiPwmOut` to correct match port output. (**Breaking Change**) (#90).
- Moved most device-related constants into their associated struct `impl` (**Breaking Change**) (#98).
- Renamed IMU_RESET_TIMEOUT to `InertialSensor::CALIBRATION_TIMEOUT` (**Breaking Change**) (#98).
- Repurposed the `pros` crate as a metapackage without any code of its own. (**Breaking Change**) (#86)
- Split the pros-rs into several small subcrates. (**Breaking Change**) (#86)
- `pros-async` with the async executor and robot trait.
- `pros-devices` for device bindings.
- `pros-sync` for the sync robot trait.
- `pros-core` with basic abstractions over `pros-sys` needed to compile a program to the brain.
- `pros-math` with commonly used controllers and other mathematical models.
- `pros-panic` for the panic handler implementation.

### Removed

- LVGL bindings (pros-sys) and colors (pros). (**Breaking Change**) (#81)
- LLEMU/lcd bindings. (**Breaking Change**) (#81)
- Re-exported printing macros from `pros::io`. (#82)
- Applied several lints to improve code quality. (#70)
- Removed the confusingly named `write`, `ewrite`, `writeln`, and `ewriteln` macros. (**Breaking Change**) (#82)
- Removed AdiDigitalIn::new_press, instead swapping it for AdiSwitch::was_pressed. (**Breaking Change**) (#61)

## [0.7.0]

### Added
Expand All @@ -46,6 +104,7 @@ Before releasing:
- All ADI device bindings (#55)
- `LocalKey` now has `Cell`/`RefCell`-specific methods for setting and taking values. (#42)
- `Peripherals` and `DynamicPeripherals` structs to ensure that you have only registered one device on a given smart or ADI port. (#53)
- Support for ADI Expander modules with `AdiExpander`. (#63)

### Fixed

Expand All @@ -54,6 +113,7 @@ Before releasing:
- Fixed errors in doctests and examples throughout the crate. (#37)
- Fixed Missing ERRNO and ADI config variants in pros-sys (#55)
- Fixed incorrect error handling with `InertialSensor::status`. (#65)
- `Controller::status` now handles errors by returning `Result<ControllerStatus, ControllerError>`. (**Breaking Change**) (#74)

### Changed

Expand Down Expand Up @@ -129,8 +189,9 @@ Before releasing:

### Removed

[unreleased]: https://github.com/pros-rs/pros-rs/compare/v0.7.0...HEAD
[unreleased]: https://github.com/pros-rs/pros-rs/compare/v0.8.0...HEAD
[0.4.0]: https://github.com/pros-rs/pros-rs/releases/tag/v0.4.0
[0.5.0]: https://github.com/pros-rs/pros-rs/compare/v0.4.0...v0.5.0
[0.6.0]: https://github.com/pros-rs/pros-rs/compare/v0.5.0...v0.6.0
[0.7.0]: https://github.com/pros-rs/pros-rs/compare/v0.6.0...v0.7.0
[0.8.0]: https://github.com/pros-rs/pros-rs/compare/v0.7.0...v0.8.0
8 changes: 8 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
[workspace]
members = ["packages/*"]
resolver = "2"

[workspace.lints.rust]
rust_2018_idioms = "warn"
missing_docs = "warn"
unsafe_op_in_unsafe_fn = "warn"

[workspace.lints.clippy]
missing_const_for_fn = "warn"
6 changes: 3 additions & 3 deletions TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ This is the todo list for the eventual 1.0.0 release of pros-rs
* [ ] (Custom) Gear Ratios
* [X] Make Robot Functions Take Self
* [X] PID controllers
* [ ] Feedforward loops
* [X] Feedforward loops
* [ ] ADI (3 wire ports)
* [ ] Ext. ADI
* [X] Sensors
Expand All @@ -34,9 +34,9 @@ This is the todo list for the eventual 1.0.0 release of pros-rs
* [X] Async runtime
* [X] Returning top level futures
* [X] Reactor
* [ ] More asynchronous APIs
* [ ] More asynchronous APIs
* [ ] MPSC
* [X] Task Locals
* [X] Task Locals

## API

Expand Down
8 changes: 5 additions & 3 deletions armv7a-vexos-eabi.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"cpu": "cortex-a9",
"arch": "arm",
"data-layout": "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64",
"disable-redzone": true,
"emit-debug-gdb-scripts": false,
"env": "newlib",
"executables": true,
"features": "+v7,+thumb2,+soft-float,-neon,+strict-align",
"features": "+thumb2,+neon,+vfp3",
"linker": "arm-none-eabi-gcc",
"linker-flavor": "gcc",
"llvm-target": "armv7a-none-eabi",
Expand All @@ -16,11 +17,12 @@
"-nostartfiles",
"-nostdlib",
"-Wl,-Tv5.ld,-Tv5-common.ld,--gc-sections",
"-Wl,--start-group,-lpros,-lc,-lm,-lgcc,-lstdc++,--end-group"
"-Wl,--start-group,-lgcc,-lpros,-lc,--end-group"
]
},
"relocation-model": "static",
"target-family": "unix",
"target-pointer-width": "32",
"os": "vexos"
"os": "vexos",
"vendor": "vex"
}
29 changes: 29 additions & 0 deletions packages/pros-async/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[package]
name = "pros-async"
version = "0.1.0"
edition = "2021"
license = "MIT"
description = "A simple async executor for pros-rs"
keywords = ["PROS", "Robotics", "bindings", "async", "vex", "v5"]
categories = [
"no-std",
"science::robotics",
"Asynchronous"
]
repository = "https://github.com/gavin-niederman/pros-rs"
authors = [
"pros-rs",
"Gavin Niederman <[email protected]>",
"doinkythederp <[email protected]>",
]

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
async-task = { version = "4.5.0", default-features = false }
pros-core = { version = "0.1.0", path = "../pros-core" }
waker-fn = "1.1.1"
pros-sys = { version = "0.7.0", path = "../pros-sys" }

[lints]
workspace = true
6 changes: 6 additions & 0 deletions packages/pros-async/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# pros-async

Tiny async runtime and robot traits for `pros-rs`.
The async executor supports spawning tasks and blocking on futures.
It has a reactor to improve the performance of some futures.
FreeRTOS tasks can still be used, but it is recommended to use only async tasks for performance.
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ use core::{
};

use async_task::{Runnable, Task};
use pros_core::{os_task_local, task::delay};
use waker_fn::waker_fn;

use super::reactor::Reactor;
use crate::{os_task_local, task::delay};

os_task_local! {
pub(crate) static EXECUTOR: Executor = Executor::new();
Expand All @@ -27,7 +27,7 @@ impl !Send for Executor {}
impl !Sync for Executor {}

impl Executor {
pub fn new() -> Self {
pub const fn new() -> Self {
Self {
queue: RefCell::new(VecDeque::new()),
reactor: RefCell::new(Reactor::new()),
Expand Down
Loading