Skip to content
Merged
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
3 changes: 2 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ icon = "cool-x"
compress = true

[dependencies]
vexide = "0.7.0"
vexide = { version = "0.7.0" }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can version control be less explicit. idk if you can do it in rust where u specify only the big version numbers

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure i fully understand your comment, cargo.toml is read by rust compiler to include proper libraries

libm = { version = "0.2", default-features = false }
uom = { version = "0.36.0", default-features = false, features = ["f64", "si"] }
embassy-sync = "0.7.0"
spin = { version = "0.9", default-features = false, features = ["once", "mutex", "spin_mutex"] }
heapless = "0.8"
9 changes: 9 additions & 0 deletions ascii.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
$$$$$$\ $$\ $$\ $$\
$$ __$$\ $$ | \__|$$ |
$$ / \__| $$$$$$\ $$$$$$\ $$\ $$\ $$ | $$\ $$$$$$$\
$$ |$$$$\ $$ __$$\ \____$$\\$$\ $$ |$$ | $$ |$$ __$$\
$$ |\_$$ |$$ | \__|$$$$$$$ |\$$\$$ / $$ | $$ |$$ | $$ |
$$ | $$ |$$ | $$ __$$ | \$$$ / $$ | $$ |$$ | $$ |
\$$$$$$ |$$ | \$$$$$$$ | \$ / $$$$$$$$\ $$ |$$$$$$$ |
\______/ \__| \_______| \_/ \________|\__|\_______/
###############################################################
3 changes: 3 additions & 0 deletions src/GravLib/actuator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ pub mod motor_group;
// pub mod smartmotor;
// TODO - FIX MOTORGROUP

// pub use smartmotor::SmartMotor;
// pub mod smartmotor;

// pub use smartmotor::SmartMotor;

pub use motor_group::MotorGroup;
135 changes: 4 additions & 131 deletions src/GravLib/actuator/motor_group.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,15 @@ use vexide::task;
use libm::roundf;

pub struct MotorGroup {
inner: &'static Mutex<Inner>,
}

struct Inner {
motors: Vec<Motor>,
}

impl Inner{
fn new(motors: Vec<Motor>) -> Self {
impl MotorGroup {
pub fn new(motors: Vec<Motor>) -> Self {
Self { motors }
}

fn move_voltage(&mut self, voltage: f64) {
pub fn move_voltage(&mut self, voltage: f64) {
for motor in &mut self.motors {
let _ = motor.set_voltage(voltage);
}
Expand Down Expand Up @@ -79,127 +75,4 @@ impl Inner{
let _ = motor.brake(mode);
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.ok?

}
}
}


impl MotorGroup {
pub fn new(motors: Vec<Motor>) -> Self {
let boxed = Box::new(Mutex::new(Inner::new(motors)));
let static_mutex = Box::leak(boxed); // leak the Box to get a static reference

let handle: MotorGroup = MotorGroup {inner: static_mutex};
// task::spawn(Self::tracking_task(handle.inner)).detach(); // TODO - optional, useable in chasiss, spawn background tracking task

handle
}

pub fn move_voltage(&self, voltage: f64) {
let mut guard = self.inner.lock();
guard.move_voltage(voltage);
}

pub fn move_velocity(&self, velocity_percentage: f64) {
let mut guard = self.inner.lock();
guard.move_velocity(velocity_percentage);
}

pub fn voltage(&self) -> f64 {
let guard = self.inner.lock();
guard.voltage()
}

pub fn position(&self) -> f64 {
let guard = self.inner.lock();
guard.position()
}

pub fn brake(&self, mode: BrakeMode) {
let mut guard = self.inner.lock();
guard.brake(mode);
}
}












// _________________________________________ //





// pub struct motorGroup {
// motors: Vec<Motor>
// }


// impl motorGroup {
// pub fn new(motors: Vec<Motor>) -> Self {
// Self { motors }
// }

// pub fn set_voltage(&mut self, voltage: f64) {
// for motor in self.motors.iter_mut() {
// let _ = motor.set_voltage(voltage);
// }
// }

// pub fn voltage(&self) -> f64 {
// let mut total = 0.0;

// for motor in &self.motors {
// if let Ok(voltage) = motor.voltage() {
// total += voltage;
// }
// }
// total / self.motors.len() as f64
// }


// pub fn position(&self) -> f64 {
// let mut total = 0.0;
// for motor in &self.motors {
// if let Ok(angle) = motor.position() {
// total += angle.as_radians();
// }
// }
// total
// }

// // @dev_note: set_velocity method is built in PID by VEXIDE devs.
// pub fn set_velocity(&mut self, velocity_percentage: f64) {
// // Calculate velocity as percentage of max velocity

// for motor in self.motors.iter_mut() {
// let gearset = motor.gearset().unwrap();

// let max_rpm = match gearset {
// Gearset::Red => 100,
// Gearset::Green => 200,
// Gearset::Blue => 600,
// };

// // Convert percentages to rpm
// let velocity_raw =
// (velocity_percentage as f32 / 100.0)
// * (max_rpm as f32);

// let velocity = roundf(velocity_raw) as i32;
// let _ = motor.set_velocity(velocity);
// }
// }

// pub fn brake(&mut self, mode: BrakeMode) {
// for motor in self.motors.iter_mut() {
// let _ = motor.brake(mode);
// }
// }
// }
}
113 changes: 0 additions & 113 deletions src/GravLib/actuator/smartmotor.rs

This file was deleted.

21 changes: 0 additions & 21 deletions src/GravLib/drivebase/chassis.rs

This file was deleted.

5 changes: 0 additions & 5 deletions src/GravLib/drivebase/driver/mod.rs

This file was deleted.

17 changes: 0 additions & 17 deletions src/GravLib/drivebase/driver/single_arcade.rs

This file was deleted.

18 changes: 0 additions & 18 deletions src/GravLib/drivebase/driver/split_arcade.rs

This file was deleted.

12 changes: 0 additions & 12 deletions src/GravLib/drivebase/driver/tank.rs

This file was deleted.

Loading
Loading