Skip to main content

PowertrainParams

Struct PowertrainParams 

Source
pub struct PowertrainParams {
    pub base: MotorQuadParams,
    pub motor_tau: f64,
    pub discharge_rate: f64,
    pub sag_coeff: f64,
    pub min_voltage_scale: f64,
    pub relax_build: f64,
    pub relax_recover: f64,
    pub relax_coeff: f64,
}
Expand description

Powertrain parameters layered on top of the base motor model.

Fields§

§base: MotorQuadParams

Base rigid-body and rotor-mixing parameters.

§motor_tau: f64

First-order motor spin-up time constant [s]; 0 means instant.

§discharge_rate: f64

Battery discharge rate per unit load per second [1/s].

§sag_coeff: f64

Instantaneous voltage droop fraction at full electrical load, in [0, 1).

§min_voltage_scale: f64

Open-circuit voltage scale at an empty pack, in (0, 1].

§relax_build: f64

Rate [1/s] at which the relaxation overpotential builds toward the load.

§relax_recover: f64

Rate [1/s] at which the relaxation overpotential decays (recovers).

§relax_coeff: f64

Voltage-scale depression per unit relaxation overpotential, in [0, 1).

Implementations§

Source§

impl PowertrainParams

Source

pub fn new( base: MotorQuadParams, motor_tau: f64, discharge_rate: f64, sag_coeff: f64, min_voltage_scale: f64, ) -> RoboticsResult<Self>

Build a powertrain with explicit lag/battery coefficients.

Source

pub fn with_recovery(self, build: f64, recover: f64, coeff: f64) -> Self

Add a battery-recovery (relaxation-overpotential) model: the relaxation state builds toward the load at build [1/s] and decays at recover [1/s], depressing the terminal voltage by coeff per unit. Easing off therefore lets the terminal voltage — and thus the thrust ceiling — recover even though the state of charge keeps falling. All arguments are sanitized (build/recover >= 0 and finite, coeff in [0, 1)); the defaults of zero leave the pack with no recovery dynamics.

Source

pub fn ideal(base: MotorQuadParams) -> Self

Idealized powertrain: no lag, no discharge, no sag. Reduces exactly to the base MotorQuadParams dynamics — the benchmark baseline.

Source

pub fn load(self, rotor_thrust: [f64; 4]) -> f64

Electrical load in [0, 1]: total rotor thrust over the absolute max.

Source

pub fn voltage_scale(self, soc: f64, load: f64) -> f64

Terminal-voltage scale in [0, 1] from state of charge and load.

Open-circuit voltage falls linearly with state of charge from 1 (full) to min_voltage_scale (empty); instantaneous sag subtracts sag_coeff * load on top of that.

Source

pub fn terminal_voltage_scale(self, soc: f64, load: f64, relaxation: f64) -> f64

Terminal-voltage scale including the relaxation overpotential: the open-circuit-minus-sag Self::voltage_scale less relax_coeff * relaxation. This is the voltage actually available at the rotors.

Source

pub fn effective_max_rotor(self, state: PowertrainState) -> f64

Battery-limited per-rotor thrust ceiling for the current state, including the relaxation overpotential.

Source

pub fn step( self, state: PowertrainState, command: MotorCommand, dt: f64, ) -> PowertrainState

Advance the powertrain one step under the commanded rotor thrusts.

Trait Implementations§

Source§

impl Clone for PowertrainParams

Source§

fn clone(&self) -> PowertrainParams

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 Debug for PowertrainParams

Source§

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

Formats the value using the given formatter. Read more
Source§

impl PartialEq for PowertrainParams

Source§

fn eq(&self, other: &PowertrainParams) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for PowertrainParams

Source§

impl StructuralPartialEq for PowertrainParams

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> 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> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. 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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,