LatControl

Struct LatControl 

Source
pub struct LatControl {
    pub ui_steer: f64,
    pub sat_count: f64,
    pub y_des: f64,
    pub lateral_control_sat: bool,
}
Expand description

Represents lateral control logic.

Fields§

§ui_steer: f64

Integral term of lateral control.

§sat_count: f64

Saturation count for lateral control.

§y_des: f64

Desired lateral offset.

§lateral_control_sat: bool

Indicates if lateral control is saturated.

Implementations§

Source§

impl LatControl

Source

pub fn new() -> Self

Creates a new LatControl instance.

§Examples
use openpilot::selfdrive::controls::lat_control::LatControl;
let mut lat_control = LatControl::new();
Source

pub fn reset(&mut self)

Resets the integral term of the lateral control.

§Examples
use openpilot::selfdrive::controls::lat_control::LatControl;

let mut lat_control = LatControl::new();
lat_control.ui_steer = 0.5;
lat_control.reset();
assert_eq!(lat_control.ui_steer, 0.0);
Source

pub fn update( &mut self, enabled: bool, cs: &CS, d_poly: &Array1<f64>, angle_offset: f64, ) -> (f64, bool)

Updates lateral control based on the control state, polynomial, and angle offset.

§Arguments
  • enabled - Indicates if lateral control is enabled.
  • CS - Control state.
  • d_poly - Polynomial coefficients for lateral control.
  • angle_offset - Angle offset.
§Returns

A tuple containing the final steering output and a flag indicating continuous lateral control saturation.

§Examples
use openpilot::selfdrive::controls::lat_control::{LatControl, CS, VP};
use ndarray::prelude::*;

let mut lat_control = LatControl::new();
lat_control.ui_steer = 0.2;

let cs = CS {
    v_ego: 20.0,
    angle_steers: 5.0,
    torque_mod: false,
    steer_override: false,
    vp: VP {
        steer_ratio: 12.0,
        wheelbase: 2.7,
        slip_factor: 0.01,
    },
};

let d_poly = Array1::from(vec![0.1, 0.05, -0.02]);
let angle_offset = 1.0;

let (final_steer, sat_flag) = lat_control.update(true, &cs, &d_poly, angle_offset);

assert!(final_steer <= 1.0 && final_steer >= -1.0); // Asserting final steering within limits
assert!(sat_flag == false); // Asserting no continuous lateral control saturation

Trait Implementations§

Source§

impl Default for LatControl

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
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.