Skip to main content

PositionCommand

Struct PositionCommand 

Source
#[non_exhaustive]
pub struct PositionCommand {
Show 14 fields pub position: Option<f32>, pub velocity: Option<f32>, pub feedforward_torque: Option<f32>, pub kp_scale: Option<f32>, pub kd_scale: Option<f32>, pub maximum_torque: Option<f32>, pub stop_position: Option<f32>, pub watchdog_timeout: Option<f32>, pub velocity_limit: Option<f32>, pub accel_limit: Option<f32>, pub fixed_voltage_override: Option<f32>, pub ilimit_scale: Option<f32>, pub fixed_current_override: Option<f32>, pub ignore_position_bounds: Option<f32>,
}
Expand description

Position mode command.

This is the primary control mode for moteus. All fields are optional; fields set to None will not be transmitted (using Ignore resolution).

§Examples

use moteus_protocol::CanFdFrame;
use moteus_protocol::command::{PositionCommand, PositionFormat};

let mut frame = CanFdFrame::new();
frame.arbitration_id = 0x8001;

// Build with the builder pattern -- fields are optional
let cmd = PositionCommand::new()
    .position(0.5)
    .velocity(1.0)
    .maximum_torque(2.0);

cmd.serialize(&mut frame, &PositionFormat::default());
assert!(frame.size > 0);

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§position: Option<f32>

Target position in revolutions

§velocity: Option<f32>

Target velocity in revolutions/second

§feedforward_torque: Option<f32>

Feedforward torque in Nm

§kp_scale: Option<f32>

Kp scale factor (0-1)

§kd_scale: Option<f32>

Kd scale factor (0-1)

§maximum_torque: Option<f32>

Maximum torque in Nm

§stop_position: Option<f32>

Stop position for trajectory mode

§watchdog_timeout: Option<f32>

Watchdog timeout in seconds

§velocity_limit: Option<f32>

Velocity limit in revolutions/second

§accel_limit: Option<f32>

Acceleration limit in revolutions/second^2

§fixed_voltage_override: Option<f32>

Fixed voltage override

§ilimit_scale: Option<f32>

Current limit scale factor

§fixed_current_override: Option<f32>

Fixed current override in A

§ignore_position_bounds: Option<f32>

Ignore position bounds flag

Implementations§

Source§

impl PositionCommand

Source

pub fn position(self, value: f32) -> Self

Source

pub fn velocity(self, value: f32) -> Self

Source

pub fn feedforward_torque(self, value: f32) -> Self

Source

pub fn kp_scale(self, value: f32) -> Self

Source

pub fn kd_scale(self, value: f32) -> Self

Source

pub fn maximum_torque(self, value: f32) -> Self

Source

pub fn stop_position(self, value: f32) -> Self

Source

pub fn watchdog_timeout(self, value: f32) -> Self

Source

pub fn velocity_limit(self, value: f32) -> Self

Source

pub fn accel_limit(self, value: f32) -> Self

Source

pub fn fixed_voltage_override(self, value: f32) -> Self

Source

pub fn ilimit_scale(self, value: f32) -> Self

Source

pub fn fixed_current_override(self, value: f32) -> Self

Source

pub fn ignore_position_bounds(self, value: f32) -> Self

Source§

impl PositionCommand

Source

pub fn new() -> Self

Creates a new position command with all fields set to None.

Source

pub fn serialize(&self, frame: &mut CanFdFrame, format: &PositionFormat)

Serializes this command to a CAN frame.

Trait Implementations§

Source§

impl Clone for PositionCommand

Source§

fn clone(&self) -> PositionCommand

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 PositionCommand

Source§

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

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

impl Default for PositionCommand

Source§

fn default() -> PositionCommand

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, 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.