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: f64Integral term of lateral control.
sat_count: f64Saturation count for lateral control.
y_des: f64Desired lateral offset.
lateral_control_sat: boolIndicates if lateral control is saturated.
Implementations§
Source§impl LatControl
impl LatControl
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new LatControl instance.
§Examples
use openpilot::selfdrive::controls::lat_control::LatControl;
let mut lat_control = LatControl::new();Sourcepub fn reset(&mut self)
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);Sourcepub fn update(
&mut self,
enabled: bool,
cs: &CS,
d_poly: &Array1<f64>,
angle_offset: f64,
) -> (f64, bool)
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 saturationTrait Implementations§
Auto Trait Implementations§
impl Freeze for LatControl
impl RefUnwindSafe for LatControl
impl Send for LatControl
impl Sync for LatControl
impl Unpin for LatControl
impl UnwindSafe for LatControl
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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