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§
Sourcefn 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 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.
Sourcefn 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_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.
Sourcefn 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 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.)
Provided Methods§
Sourcefn 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 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.
Sourcefn 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 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)
Sourcefn 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 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)
Sourcefn reset_encoders<'life0, 'async_trait>(
&'life0 mut self,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
fn reset_encoders<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
Reset encoder counts