pub struct Mecanum { /* private fields */ }Expand description
Mecanum (four-wheel omnidirectional) drive: forward, sideways, and turning at once.
A mecanum base carries four wheels whose angled rollers let it strafe sideways as well as
drive and turn, so it tracks a full planar Twist (vx, vy, omega). This uses the
standard kinematics for the common “O” roller layout, with k = (half-wheelbase + half-track):
front_left = vx - vy - k*omega rear_left = vx + vy - k*omega
front_right = vx + vy + k*omega rear_right = vx - vy + k*omegaThe forward kinematics invert these by averaging the wheels. Speeds are wheel contact speeds in the body’s units; convert to motor rates by dividing by the wheel radius.
§Examples
use pamoja_kit::{Mecanum, Twist, WheelSpeeds};
// 0.4 m wheelbase, 0.3 m track.
let base = Mecanum::new(0.4, 0.3);
// Pure left strafe: the O-layout spins the diagonals against each other.
let w = base.wheel_speeds(Twist::new(0.0, 1.0, 0.0));
assert_eq!(w, WheelSpeeds { front_left: -1.0, front_right: 1.0, rear_left: 1.0, rear_right: -1.0 });
// Reading the wheels back recovers the body twist.
let t = base.body_motion(w);
assert!(t.vx.abs() < 1e-6 && (t.vy - 1.0).abs() < 1e-6 && t.omega.abs() < 1e-6);Implementations§
Source§impl Mecanum
impl Mecanum
Sourcepub fn wheel_speeds(&self, twist: Twist) -> WheelSpeeds
pub fn wheel_speeds(&self, twist: Twist) -> WheelSpeeds
Returns the four wheel speeds for a desired body twist.
§Arguments
twist- the desired body velocity, using all ofvx,vy, andomega.
§Returns
The WheelSpeeds that produce that twist.
Sourcepub fn body_motion(&self, wheels: WheelSpeeds) -> Twist
pub fn body_motion(&self, wheels: WheelSpeeds) -> Twist
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Mecanum
impl RefUnwindSafe for Mecanum
impl Send for Mecanum
impl Sync for Mecanum
impl Unpin for Mecanum
impl UnsafeUnpin for Mecanum
impl UnwindSafe for Mecanum
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more