Skip to main content

Ackermann

Struct Ackermann 

Source
pub struct Ackermann { /* private fields */ }
Expand description

Car-like (Ackermann) steering: one steered axle and a driven axle a wheelbase apart.

A car cannot turn in place; it follows an arc whose radius is set by the steering angle. The kinematic bicycle model collapses each axle to a single central wheel, so the steering angle delta, the wheelbase L, the forward speed v, and the yaw rate omega are related by tan(delta) = L * omega / v, equivalently a turn radius R = L / tan(delta). This is the standard model behind a rover, a tractor, or any rack-and-pinion vehicle.

§Examples

use pamoja_kit::Ackermann;

// A rover with a 2.5 m wheelbase, steering 30 degrees (about 0.5236 rad).
let car = Ackermann::new(2.5);
let radius = car.turn_radius(0.5236);
assert!((radius - 4.33).abs() < 0.01); // R = 2.5 / tan(30 deg)

// At 5 m/s that steering yields a yaw rate of about 1.155 rad/s.
let omega = car.yaw_rate(5.0, 0.5236);
assert!((omega - 1.1547).abs() < 1e-3);
// And asking for that yaw rate at that speed recovers the steering angle.
assert!((car.steering_angle(5.0, omega) - 0.5236).abs() < 1e-3);

Implementations§

Source§

impl Ackermann

Source

pub fn new(wheelbase: f32) -> Self

Creates a model for a vehicle whose axles are wheelbase apart.

§Arguments
  • wheelbase - the distance from the steered axle to the driven axle; its magnitude is used.
§Returns

The kinematics model.

Source

pub fn steering_angle(&self, linear: f32, angular: f32) -> f32

Returns the steering angle for a desired forward speed and yaw rate.

§Arguments
  • linear - the forward speed.
  • angular - the desired yaw rate, positive turning left.
§Returns

The steering angle in radians, atan(wheelbase * angular / linear). Returns zero when the vehicle is stopped (linear is zero), since a stationary car cannot yaw by steering.

Source

pub fn yaw_rate(&self, linear: f32, steering: f32) -> f32

Returns the yaw rate produced by a forward speed and steering angle.

§Arguments
  • linear - the forward speed.
  • steering - the steering angle in radians.
§Returns

The yaw rate linear * tan(steering) / wheelbase, zero when the wheelbase is zero.

Source

pub fn turn_radius(&self, steering: f32) -> f32

Returns the turn radius for a steering angle.

§Arguments
  • steering - the steering angle in radians.
§Returns

The radius wheelbase / tan(steering) in metres, or f32::INFINITY when the wheels point straight ahead (steering is zero), since the path is then a straight line.

Source

pub fn curvature(&self, steering: f32) -> f32

Returns the path curvature for a steering angle.

§Arguments
  • steering - the steering angle in radians.
§Returns

The curvature tan(steering) / wheelbase, the reciprocal of the turn radius, zero when the wheelbase is zero.

Trait Implementations§

Source§

impl Clone for Ackermann

Source§

fn clone(&self) -> Ackermann

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Ackermann

Source§

impl Debug for Ackermann

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.