Skip to main content

Mode

Enum Mode 

Source
#[non_exhaustive]
#[repr(u8)]
pub enum Mode {
Show 16 variants Stopped = 0, Fault = 1, Enabling = 2, Calibrating = 3, CalibrationComplete = 4, Pwm = 5, Voltage = 6, VoltageFoc = 7, VoltageDq = 8, Current = 9, Position = 10, Timeout = 11, ZeroVelocity = 12, StayWithin = 13, MeasureInd = 14, Brake = 15,
}
Expand description

The operating mode of a moteus controller.

This corresponds to the value in the Register::Mode register.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

Stopped = 0

Motor is stopped and unpowered

§

Fault = 1

Controller is in a fault state

§

Enabling = 2

Controller is enabling (transitioning to active)

§

Calibrating = 3

Controller is calibrating

§

CalibrationComplete = 4

Calibration is complete

§

Pwm = 5

Raw PWM mode

§

Voltage = 6

Voltage mode

§

VoltageFoc = 7

Voltage FOC mode

§

VoltageDq = 8

Voltage DQ mode

§

Current = 9

Current (torque) mode

§

Position = 10

Position mode (primary operating mode)

§

Timeout = 11

Position timeout (watchdog expired)

§

ZeroVelocity = 12

Zero velocity mode (hold position with damping)

§

StayWithin = 13

Stay within bounds mode

§

MeasureInd = 14

Measure inductance mode (calibration)

§

Brake = 15

Brake mode (short motor windings)

Implementations§

Source§

impl Mode

Source

pub fn is_error(&self) -> bool

Returns true if the controller is in an error state.

§Examples
use moteus_protocol::Mode;

let mode = Mode::Position;
assert!(mode.is_active());
assert!(!mode.is_error());

let fault = Mode::Fault;
assert!(fault.is_error());
assert!(!fault.is_active());
Source

pub fn is_active(&self) -> bool

Returns true if the controller is actively controlling the motor.

Trait Implementations§

Source§

impl Clone for Mode

Source§

fn clone(&self) -> Mode

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 Mode

Source§

impl Debug for Mode

Source§

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

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

impl Default for Mode

Source§

fn default() -> Mode

Returns the “default value” for a type. Read more
Source§

impl Display for Mode

Source§

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

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

impl Eq for Mode

Source§

impl From<Mode> for u8

Source§

fn from(enum_value: Mode) -> Self

Converts to this type from the input type.
Source§

impl From<Mode> for i8

Source§

fn from(mode: Mode) -> i8

Converts to this type from the input type.
Source§

impl PartialEq for Mode

Source§

fn eq(&self, other: &Mode) -> 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 StructuralPartialEq for Mode

Source§

impl TryFrom<u8> for Mode

Source§

type Error = TryFromPrimitiveError<Mode>

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

fn try_from(number: u8) -> Result<Self, TryFromPrimitiveError<Self>>

Performs the conversion.
Source§

impl TryFromPrimitive for Mode

Auto Trait Implementations§

§

impl Freeze for Mode

§

impl RefUnwindSafe for Mode

§

impl Send for Mode

§

impl Sync for Mode

§

impl Unpin for Mode

§

impl UnsafeUnpin for Mode

§

impl UnwindSafe for Mode

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.