-
Notifications
You must be signed in to change notification settings - Fork 4
feat: 🛞 tracking wheel robot localisation #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
f946427
0267a53
d0aa966
6347818
be0670f
78b4a6e
29acf6e
3d33ac9
5ecd3f1
c71f773
d05e42b
708767b
c17df85
383e616
8e1d366
17df347
0990398
7bddbdf
53b78e8
3da319d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| $$$$$$\ $$\ $$\ $$\ | ||
| $$ __$$\ $$ | \__|$$ | | ||
| $$ / \__| $$$$$$\ $$$$$$\ $$\ $$\ $$ | $$\ $$$$$$$\ | ||
| $$ |$$$$\ $$ __$$\ \____$$\\$$\ $$ |$$ | $$ |$$ __$$\ | ||
| $$ |\_$$ |$$ | \__|$$$$$$$ |\$$\$$ / $$ | $$ |$$ | $$ | | ||
| $$ | $$ |$$ | $$ __$$ | \$$$ / $$ | $$ |$$ | $$ | | ||
| \$$$$$$ |$$ | \$$$$$$$ | \$ / $$$$$$$$\ $$ |$$$$$$$ | | ||
| \______/ \__| \_______| \_/ \________|\__|\_______/ | ||
| ############################################################### |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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); | ||
| } | ||
|
|
@@ -79,127 +75,4 @@ impl Inner{ | |
| let _ = motor.brake(mode); | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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); | ||
| // } | ||
| // } | ||
| // } | ||
| } | ||
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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