Skip to main content

Actuator

Struct Actuator 

Source
pub struct Actuator {
    pub name: String,
    pub joint_name: String,
    pub joint_idx: usize,
    pub gear: f64,
    pub ctrl_range: Option<[f64; 2]>,
    pub gain: f64,
    pub bias_q: f64,
    pub bias_v: f64,
    pub force_range: Option<[f64; 2]>,
}
Expand description

An actuator attached to a joint.

Follows MuJoCo’s affine actuator model: the generalized force applied to the joint’s first DOF is

f = gear * (gain * ctrl + bias_q * q + bias_v * v)

which expresses <motor>, <position>, <velocity> and the affine subset of <general> with one parameter set, so downstream code never branches on actuator type. A plain motor is gain = 1, bias_q = bias_v = 0, for which this reduces to gear * clamp(ctrl).

Fields§

§name: String

Actuator name, as declared in the source model.

§joint_name: String

Name of the joint this actuator drives.

§joint_idx: usize

Index into Model::joints of the driven joint.

§gear: f64

Gear ratio applied to the control signal to produce joint torque.

§ctrl_range: Option<[f64; 2]>

Optional [lo, hi] clamp on the control signal, before gear.

§gain: f64

Coefficient on ctrl. 1 for a motor, kp for a position servo.

§bias_q: f64

Coefficient on joint position. -kp for a position servo, else 0.

§bias_v: f64

Coefficient on joint velocity. -kv for a servo, else 0.

§force_range: Option<[f64; 2]>

Force limits applied after the affine law, or None if unlimited.

Implementations§

Source§

impl Actuator

Source

pub fn clamp_ctrl(&self, ctrl: f64) -> f64

Clamp a raw control value to this actuator’s control range.

Source

pub fn force(&self, ctrl: f64) -> f64

Generalized force produced by this actuator for a raw control value, ignoring any state feedback.

Correct for motors. Position and velocity servos additionally depend on q and v; use Self::force_at for those.

Source

pub fn force_at(&self, ctrl: f64, q: f64, v: f64) -> f64

Evaluate the full affine actuator law at the joint’s current state.

Source

pub fn motor(name: &str, joint_name: &str, joint_idx: usize, gear: f64) -> Self

A direct-torque motor: f = gear * ctrl.

Source

pub fn position( name: &str, joint_name: &str, joint_idx: usize, gear: f64, kp: f64, kv: f64, ) -> Self

A position servo: f = gear * (kp * (ctrl - q) - kv * v).

Source

pub fn velocity( name: &str, joint_name: &str, joint_idx: usize, gear: f64, kv: f64, ) -> Self

A velocity servo: f = gear * kv * (ctrl - v).

Trait Implementations§

Source§

impl Clone for Actuator

Source§

fn clone(&self) -> Actuator

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 Actuator

Source§

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

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

impl Default for Actuator

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> 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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.