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

feat(devices): V5 Inertial Sensor support #16

Merged
merged 25 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
d5f54cc
feat: initial IMU support
Tropix126 Dec 31, 2023
9dc143c
chore: update todo
Tropix126 Dec 31, 2023
1994dcd
fmt
Tropix126 Dec 31, 2023
209cb27
use correct bitflag comparison
Tropix126 Dec 31, 2023
c57ad0b
add is_calibrating method
Tropix126 Dec 31, 2023
43df0c1
fix: doc comments
Tropix126 Dec 31, 2023
656ac00
fix(pros_sys): make `imu_status_e_t` field visibility public
Tropix126 Dec 31, 2023
bea9c18
chore: fmt
Tropix126 Dec 31, 2023
aaf4217
remove `InertialStatus::raw`
Tropix126 Dec 31, 2023
2c6b597
use `imu_reset_blocking` for calibration
Tropix126 Dec 31, 2023
02ebb46
make `InertialStatus` API consistent with `CompetitionStatus`
Tropix126 Jan 1, 2024
1963e36
refactor: inline `bail_on!` for structs returning errors
Tropix126 Jan 2, 2024
e4bec23
chore: document all the things
Tropix126 Jan 2, 2024
474f407
include imu in prelude, add example
Tropix126 Jan 4, 2024
fea6c8d
fix: quaternion using incorrect `bail_on!` order
Tropix126 Jan 5, 2024
2ba4141
fix: revert test code in example
Tropix126 Jan 5, 2024
962d9d8
fix: don't return Ok(()) in the example
Tropix126 Jan 5, 2024
02a4bc2
feat: calibration future, data rate setter
Tropix126 Jan 5, 2024
f7f6f4a
feat: proper async calibration
Tropix126 Jan 5, 2024
fb3f57e
refactor: rename `wait_until_calibrated` to `calibrate_async`
Tropix126 Jan 5, 2024
71081a4
fix: calibration future
Tropix126 Jan 5, 2024
d811e41
Merge branch 'main' into main
Tropix126 Jan 8, 2024
b3b990c
docs: document `set_data_rate`
Tropix126 Jan 8, 2024
54f834e
refactor: swap `calibrate` terminology
Tropix126 Jan 8, 2024
e61a5e1
chore: fmt
Tropix126 Jan 8, 2024
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
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ This is the todo list for the eventual 1.0.0 release of pros-rs
* [ ] Sensors
* [X] Distance
* [X] GPS
* [ ] Inertial (IMU)
* [x] Inertial (IMU)
* [ ] Optical
* [X] Rotational
* [X] Vision
Expand Down
8 changes: 4 additions & 4 deletions pros-sys/src/imu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ pub struct quaternion_s_t {

#[repr(C)]
pub struct imu_raw_s {
x: f64,
y: f64,
z: f64,
w: f64,
pub x: f64,
pub y: f64,
pub z: f64,
pub w: f64,
}

pub type imu_gyro_s_t = imu_raw_s;
Expand Down
29 changes: 29 additions & 0 deletions pros/examples/imu.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#![no_std]
#![no_main]

use core::time::Duration;
use pros::prelude::*;

#[derive(Default)]
pub struct Robot;

impl SyncRobot for Robot {
fn opcontrol(&mut self) -> pros::Result {
let imu = InertialSensor::new(1)?;

imu.calibrate()?;

loop {
let euler = imu.euler()?;

println!(
"Pitch: {} Roll: {} Yaw: {}",
euler.pitch, euler.roll, euler.yaw
);

pros::task::delay(Duration::from_secs(1));
}
}
}

sync_robot!(Robot);
1 change: 1 addition & 0 deletions pros/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,7 @@ pub mod prelude {
pub use crate::position::*;
pub use crate::sensors::distance::*;
pub use crate::sensors::gps::*;
pub use crate::sensors::imu::*;
pub use crate::sensors::rotation::*;
pub use crate::sensors::vision::*;
pub use crate::task::{sleep, spawn};
Expand Down
Loading
Loading