[−][src]Struct odrive_rs::commands::ODrive
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]
T: Read,
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]
T: Read,
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]
T: Write + Read,
pub fn set_position_p(
&mut self,
axis: AxisID,
position: f32,
velocity_feed_forward: Option<f32>,
current_feed_forward: Option<f32>
) -> Result<()>
[src]
&mut self,
axis: AxisID,
position: f32,
velocity_feed_forward: Option<f32>,
current_feed_forward: Option<f32>
) -> Result<()>
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]
&mut self,
axis: AxisID,
position: f32,
velocity_limit: Option<f32>,
current_limit: Option<f32>
) -> Result<()>
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]
&mut self,
axis: AxisID,
velocity: f32,
current_feed_forward: Option<f32>
) -> Result<()>
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]
T: Read + Write,
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]
&mut self,
axis: AxisID,
requested_state: AxisState,
wait: bool
) -> Result<bool>
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]
T: Read + Write,
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.
<axis>.config.startup_motor_calibration
<axis>.config.startup_encoder_index_search
<axis>.config.startup_encoder_offset_calibration
<axis>.config.startup_closed_loop_control
<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]
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<()>
pub fn set_startup_encoder_index_search(
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<()>
[src]
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<()>
pub fn set_startup_encoder_offset_calibration(
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<()>
[src]
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<()>
pub fn set_startup_closed_loop_control(
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<()>
[src]
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<()>
pub fn set_startup_sensorless_control(
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<()>
[src]
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<()>
pub fn read_startup_motor_calibration(
&mut self,
axis: AxisID
) -> ODriveResult<bool>
[src]
&mut self,
axis: AxisID
) -> ODriveResult<bool>
pub fn read_startup_encoder_index_search(
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<bool>
[src]
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<bool>
pub fn read_startup_encoder_offset_calibration(
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<bool>
[src]
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<bool>
pub fn read_startup_closed_loop_control(
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<bool>
[src]
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<bool>
pub fn read_startup_sensorless_control(
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<bool>
[src]
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<bool>
impl<T> ODrive<T> where
T: Read + Write,
[src]
T: Read + Write,
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]
T: Read + Write,
Motor configuration
pub fn set_motor_pole_pairs(
&mut self,
axis: AxisID,
value: u16
) -> ODriveResult<()>
[src]
&mut self,
axis: AxisID,
value: u16
) -> ODriveResult<()>
pub fn set_motor_resistance_calib_max_voltage(
&mut self,
axis: AxisID,
value: f32
) -> ODriveResult<()>
[src]
&mut self,
axis: AxisID,
value: f32
) -> ODriveResult<()>
pub fn set_motor_requested_current_range(
&mut self,
axis: AxisID,
value: f32
) -> ODriveResult<()>
[src]
&mut self,
axis: AxisID,
value: f32
) -> ODriveResult<()>
pub fn set_motor_current_control_bandwidth(
&mut self,
axis: AxisID,
value: f32
) -> ODriveResult<()>
[src]
&mut self,
axis: AxisID,
value: f32
) -> ODriveResult<()>
pub fn set_motor_pre_calibrated(
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<()>
[src]
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<()>
impl<T> ODrive<T> where
T: Read + Write,
[src]
T: Read + Write,
Encoder configuration
pub fn set_encoder_mode(
&mut self,
axis: AxisID,
value: EncoderMode
) -> ODriveResult<()>
[src]
&mut self,
axis: AxisID,
value: EncoderMode
) -> ODriveResult<()>
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]
&mut self,
axis: AxisID,
value: f32
) -> ODriveResult<()>
pub fn set_encoder_pre_calibrated(
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<()>
[src]
&mut self,
axis: AxisID,
value: bool
) -> ODriveResult<()>
impl<T> ODrive<T> where
T: Read + Write,
[src]
T: Read + Write,
Controller configuration
pub fn set_position_gain(
&mut self,
axis: AxisID,
value: f32
) -> ODriveResult<()>
[src]
&mut self,
axis: AxisID,
value: f32
) -> ODriveResult<()>
pub fn set_velocity_gain(
&mut self,
axis: AxisID,
value: f32
) -> ODriveResult<()>
[src]
&mut self,
axis: AxisID,
value: f32
) -> ODriveResult<()>
pub fn set_velocity_integrator_gain(
&mut self,
axis: AxisID,
value: f32
) -> ODriveResult<()>
[src]
&mut self,
axis: AxisID,
value: f32
) -> ODriveResult<()>
pub fn set_velocity_limit(
&mut self,
axis: AxisID,
value: f32
) -> ODriveResult<()>
[src]
&mut self,
axis: AxisID,
value: f32
) -> ODriveResult<()>
pub fn set_control_mode(
&mut self,
axis: AxisID,
mode: ControlMode
) -> ODriveResult<()>
[src]
&mut self,
axis: AxisID,
mode: ControlMode
) -> ODriveResult<()>
Trait Implementations
impl<T: Debug> Debug for ODrive<T> where
T: Read,
[src]
T: Read,
impl<T> Read for ODrive<T> where
T: Read,
[src]
T: Read,
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.
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
[src]
fn read_vectored(&mut self, bufs: &mut [IoSliceMut]) -> Result<usize, Error>
1.36.0[src]
unsafe fn initializer(&self) -> Initializer
[src]
fn read_to_end(&mut self, buf: &mut Vec<u8>) -> Result<usize, Error>
1.0.0[src]
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
1.0.0[src]
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
1.6.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
fn bytes(self) -> Bytes<Self>
1.0.0[src]
fn chain<R>(self, next: R) -> Chain<Self, R> where
R: Read,
1.0.0[src]
R: Read,
fn take(self, limit: u64) -> Take<Self>
1.0.0[src]
impl<T> Write for ODrive<T> where
T: Write + Read,
[src]
T: Write + Read,
An implementation of Write
has been provided as an escape hatch to enable the usage of
operations not yet supported by this library.
fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
[src]
fn flush(&mut self) -> Result<(), Error>
[src]
fn write_vectored(&mut self, bufs: &[IoSlice]) -> Result<usize, Error>
1.36.0[src]
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
1.0.0[src]
fn write_fmt(&mut self, fmt: Arguments) -> Result<(), Error>
1.0.0[src]
fn by_ref(&mut self) -> &mut Self
1.0.0[src]
Auto Trait Implementations
impl<T> Send for ODrive<T> where
T: Send,
T: Send,
impl<T> Sync for ODrive<T> where
T: Sync,
T: Sync,
impl<T> Unpin for ODrive<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for ODrive<T> where
T: UnwindSafe,
T: UnwindSafe,
impl<T> RefUnwindSafe for ODrive<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
Blanket Implementations
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,