[][src]Struct odrive_rs::commands::ODrive

pub struct ODrive<T> where
    T: Read
{ /* fields omitted */ }

The ODrive struct manages a connection with an ODrive motor over the ASCII protocol. It acts as a newtype around a connection stream. This has been tested using serial types from serialport-rs.

Methods

impl<T> ODrive<T> where
    T: Read
[src]

pub fn new(io_stream: T) -> Self[src]

Although any type can be passed in here, it is suggested that the supplied type T be Read + Write. Doing so will unlock the full API.

impl<T> ODrive<T> where
    T: Read
[src]

pub fn read_string(&mut self) -> Result<Option<String>>[src]

Reads the next message sent by the ODrive as a string. If their is no message, this function should return None

It is suggested that you only use this if you are directly using the Write implementation and are expecting a response, as normally the supplied for the ODrive can directly support reading any response.

pub fn read_odrive_response(&mut self) -> ODriveResult<String>[src]

pub fn read_float(&mut self) -> Result<Option<f32>>[src]

Reads the next message as a float. This will return zero if the message is not a valid float.

It is suggested that you only use this if you are directly using the Write implementation and are expecting a response, as normally the supplied for the ODrive can directly support reading any response.

pub fn read_int(&mut self) -> Result<Option<i32>>[src]

Reads the next message as an int. This will return zero if the message is not a valid int.

It is suggested that you only use this if you are directly using the Write implementation and are expecting a response, as normally the supplied for the ODrive can directly support reading any response.

impl<T> ODrive<T> where
    T: Write + Read
[src]

pub fn set_position_p(
    &mut self,
    axis: AxisID,
    position: f32,
    velocity_feed_forward: Option<f32>,
    current_feed_forward: Option<f32>
) -> Result<()>
[src]

Move the motor to a position. Use this command if you have a real-time controller which is streaming setpoints and tracking a trajectory. axis The motor to be used for the operation. position is the desired position, in encoder counts. velocity_feed_forward is the velocity feed forward term, in encoder counts per second. current_feed_forward is the current feed forward term, in amps. If None is supplied for a feed forward input, zero will be provided as a default.

pub fn set_position_q(
    &mut self,
    axis: AxisID,
    position: f32,
    velocity_limit: Option<f32>,
    current_limit: Option<f32>
) -> Result<()>
[src]

Move the motor to a position. Use this command if you are sending one setpoint at a time. axis The motor to be used for the operation. position is the desired position, in encoder counts. velocity_limit is the velocity limit, in encoder counts per second. current_limit is the current limit, in amps. If None is supplied for a limit, zero will be provided as a default.

pub fn set_velocity(
    &mut self,
    axis: AxisID,
    velocity: f32,
    current_feed_forward: Option<f32>
) -> Result<()>
[src]

Specifies a velocity setpoint for the motor. axis The motor to be used for the operation. velocity is the velocity setpoint, in encoder counts per second. current_feed_forward is the current feed forward term, in amps. If None is supplied for a feed forward input, zero will be provided as a default.

pub fn set_current(&mut self, axis: AxisID, current: f32) -> Result<()>[src]

Specifies a velocity setpoint for the motor. axis The motor to be used for the operation. current is the current to be supplied, in amps.

pub fn set_trajectory(&mut self, axis: AxisID, position: f32) -> Result<()>[src]

Moves a motor to a given position For general movement, this is the best command. axis The motor to be used for the operation. position is the desired position, in encoder counts.

impl<T> ODrive<T> where
    T: Read + Write
[src]

pub fn get_velocity(&mut self, axis: AxisID) -> Result<Option<f32>>[src]

Retrieves the velocity of a motor, in counts per second.

pub fn run_state(
    &mut self,
    axis: AxisID,
    requested_state: AxisState,
    wait: bool
) -> Result<bool>
[src]

Changes the state of an axis. The wait flag indicates whether this command should block until the state is updated. Returns true unless we are in blocking mode and the operation times out. The current timeout is 10 seconds.

This command will likely be deprecated and reworked in a future release.

impl<T> ODrive<T> where
    T: Read + Write
[src]

Startup Configuration

The ODrive motor controllers have several optional startup procedures which can be enabled. Each of them has an associated getter and setter which can be invoked to read to and write from their value.

From the official documentation:

By default the ODrive takes no action at startup and goes to idle immediately. In order to change what startup procedures are used, set the startup procedures you want to true. The ODrive will sequence all enabled startup actions selected in the order shown below.

  1. <axis>.config.startup_motor_calibration
  2. <axis>.config.startup_encoder_index_search
  3. <axis>.config.startup_encoder_offset_calibration
  4. <axis>.config.startup_closed_loop_control
  5. <axis>.config.startup_sensorless_control

For further information, see the documentation for AxisState.

pub fn set_startup_motor_calibration(
    &mut self,
    axis: AxisID,
    value: bool
) -> ODriveResult<()>
[src]

pub fn set_startup_encoder_offset_calibration(
    &mut self,
    axis: AxisID,
    value: bool
) -> ODriveResult<()>
[src]

pub fn set_startup_closed_loop_control(
    &mut self,
    axis: AxisID,
    value: bool
) -> ODriveResult<()>
[src]

pub fn set_startup_sensorless_control(
    &mut self,
    axis: AxisID,
    value: bool
) -> ODriveResult<()>
[src]

pub fn read_startup_motor_calibration(
    &mut self,
    axis: AxisID
) -> ODriveResult<bool>
[src]

pub fn read_startup_encoder_offset_calibration(
    &mut self,
    axis: AxisID,
    value: bool
) -> ODriveResult<bool>
[src]

pub fn read_startup_closed_loop_control(
    &mut self,
    axis: AxisID,
    value: bool
) -> ODriveResult<bool>
[src]

pub fn read_startup_sensorless_control(
    &mut self,
    axis: AxisID,
    value: bool
) -> ODriveResult<bool>
[src]

impl<T> ODrive<T> where
    T: Read + Write
[src]

Configuration management.

pub fn save_configuration(&mut self) -> ODriveResult<()>[src]

Saves the current configuration of properties to the ODrives non-volatile memory, allowing the configuration to persist after reboots.

pub fn erase_configuration(&mut self) -> ODriveResult<()>[src]

Reset the current configuration to the factory default settings.

impl<T> ODrive<T> where
    T: Read + Write
[src]

Motor configuration

pub fn set_motor_pole_pairs(
    &mut self,
    axis: AxisID,
    value: u16
) -> ODriveResult<()>
[src]

pub fn set_motor_resistance_calib_max_voltage(
    &mut self,
    axis: AxisID,
    value: f32
) -> ODriveResult<()>
[src]

pub fn set_motor_requested_current_range(
    &mut self,
    axis: AxisID,
    value: f32
) -> ODriveResult<()>
[src]

pub fn set_motor_current_control_bandwidth(
    &mut self,
    axis: AxisID,
    value: f32
) -> ODriveResult<()>
[src]

pub fn set_motor_pre_calibrated(
    &mut self,
    axis: AxisID,
    value: bool
) -> ODriveResult<()>
[src]

impl<T> ODrive<T> where
    T: Read + Write
[src]

Encoder configuration

pub fn set_encoder_mode(
    &mut self,
    axis: AxisID,
    value: EncoderMode
) -> ODriveResult<()>
[src]

pub fn set_encoder_cpr(&mut self, axis: AxisID, value: u16) -> ODriveResult<()>[src]

pub fn set_encoder_bandwidth(
    &mut self,
    axis: AxisID,
    value: f32
) -> ODriveResult<()>
[src]

pub fn set_encoder_pre_calibrated(
    &mut self,
    axis: AxisID,
    value: bool
) -> ODriveResult<()>
[src]

impl<T> ODrive<T> where
    T: Read + Write
[src]

Controller configuration

pub fn set_position_gain(
    &mut self,
    axis: AxisID,
    value: f32
) -> ODriveResult<()>
[src]

pub fn set_velocity_gain(
    &mut self,
    axis: AxisID,
    value: f32
) -> ODriveResult<()>
[src]

pub fn set_velocity_integrator_gain(
    &mut self,
    axis: AxisID,
    value: f32
) -> ODriveResult<()>
[src]

pub fn set_velocity_limit(
    &mut self,
    axis: AxisID,
    value: f32
) -> ODriveResult<()>
[src]

pub fn set_control_mode(
    &mut self,
    axis: AxisID,
    mode: ControlMode
) -> ODriveResult<()>
[src]

Trait Implementations

impl<T: Debug> Debug for ODrive<T> where
    T: Read
[src]

impl<T> Read for ODrive<T> where
    T: Read
[src]

An implementation of Write has been provided as an escape hatch to enable the usage of operations not yet supported by this library. Be advised that using this implementation may place the connection into an inconsistent state.

impl<T> Write for ODrive<T> where
    T: Write + Read
[src]

An implementation of Write has been provided as an escape hatch to enable the usage of operations not yet supported by this library.

Auto Trait Implementations

impl<T> Send for ODrive<T> where
    T: Send

impl<T> Sync for ODrive<T> where
    T: Sync

impl<T> Unpin for ODrive<T> where
    T: Unpin

impl<T> UnwindSafe for ODrive<T> where
    T: UnwindSafe

impl<T> RefUnwindSafe for ODrive<T> where
    T: RefUnwindSafe

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]