Skip to main content

MotorController

Trait MotorController 

Source
pub trait MotorController: Controller {
    // Required methods
    fn set_velocity<'life0, 'async_trait>(
        &'life0 mut self,
        left: f32,
        right: f32,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_encoders<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(i32, i32), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn get_status<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<MotorStatus, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn emergency_stop<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided methods
    fn set_twist<'life0, 'async_trait>(
        &'life0 mut self,
        twist: Twist,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: Send + 'async_trait,
             'life0: 'async_trait { ... }
    fn enable<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: Send + 'async_trait,
             'life0: 'async_trait { ... }
    fn disable<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: Send + 'async_trait,
             'life0: 'async_trait { ... }
    fn reset_encoders<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self::Error: From<ControllerError>,
             Self: Send + 'async_trait,
             'life0: 'async_trait { ... }
    fn set_pid_gains<'life0, 'async_trait>(
        &'life0 mut self,
        _gains: PidGains,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self::Error: From<ControllerError>,
             Self: Send + 'async_trait,
             'life0: 'async_trait { ... }
    fn get_pid_gains<'life0, 'async_trait>(
        &'life0 self,
    ) -> Pin<Box<dyn Future<Output = Result<PidGains, Self::Error>> + Send + 'async_trait>>
       where Self::Error: From<ControllerError>,
             Self: Sync + 'async_trait,
             'life0: 'async_trait { ... }
}
Expand description

Motor controller trait

Provides a unified interface for different motor types:

  • Differential drive robots
  • Servo motors (Dynamixel, etc.)
  • Stepper motors
  • Brushless DC motors (ODrive, VESC)

Required Methods§

Source

fn set_velocity<'life0, 'async_trait>( &'life0 mut self, left: f32, right: f32, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set velocity command

For differential drive, this sets linear and angular velocities. For other motor types, the interpretation may vary.

Source

fn get_encoders<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(i32, i32), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get motor encoder readings

Returns (left, right) encoder counts or positions.

Source

fn get_status<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<MotorStatus, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get motor status (velocities, current, temperature, etc.)

Source

fn emergency_stop<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Emergency stop - immediately halt all motors

Provided Methods§

Source

fn set_twist<'life0, 'async_trait>( &'life0 mut self, twist: Twist, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait,

Set twist command (linear and angular velocities)

Higher-level command for differential drive robots.

Source

fn enable<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait,

Enable motors (remove safe stop)

Source

fn disable<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: Send + 'async_trait, 'life0: 'async_trait,

Disable motors (safe stop, motors can freewheel)

Source

fn reset_encoders<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self::Error: From<ControllerError>, Self: Send + 'async_trait, 'life0: 'async_trait,

Reset encoder counts

Source

fn set_pid_gains<'life0, 'async_trait>( &'life0 mut self, _gains: PidGains, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self::Error: From<ControllerError>, Self: Send + 'async_trait, 'life0: 'async_trait,

Set PID gains (if supported)

Source

fn get_pid_gains<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<PidGains, Self::Error>> + Send + 'async_trait>>
where Self::Error: From<ControllerError>, Self: Sync + 'async_trait, 'life0: 'async_trait,

Get current PID gains (if supported)

Implementors§