Struct rust_rpi_4wd_car::Motors [−][src]
pub struct Motors { /* fields omitted */ }
Proves a simpler interface for the robot’s motors.
Implementations
impl Motors
[src]
pub fn new() -> Rr4cResult<Self>
[src]
Constructor
pub fn brake(&mut self) -> Result
[src]
Stop the robot motors.
pub fn enable(&mut self, v: bool)
[src]
Used to enable/disable robot moving.
Arguments
v
- Usetrue
to enable robot moving elsefalse
to disable.
pub fn movement<L, R>(&mut self, left: L, right: R) -> Result where
L: Into<Option<i8>>,
R: Into<Option<i8>>,
[src]
L: Into<Option<i8>>,
R: Into<Option<i8>>,
Sets direction and speed of motors.
NOTE: Motors must be enabled by calling
enable(true)
before this command cause robot to start moving.
Arguments
Both motors use a -100(%) to +100(%) integer speed range.
NOTE: Speeds below 20% in either direction may be glitchy and ones below 10% are likely to cause little or no movement of the robot.
left
- Speed and direction for left motors.right
- Speed and direction for right motors.
Examples
use rust_rpi_4wd_car::{Motors, Result}; fn main() -> Result { let mut motors = Motors::new()?; motors.enable(true); motors.movement(-50, 50) }
This will cause the robot to start spinning in place to the left. The left motors going backwards and the right motors forward. Both motors will be at ~50% speed.
pub fn speeds(&self) -> (i8, i8)
[src]
Access the current speeds of the left and right motors.
NOTE: Speeds will be return even when motors are not actively being driven or enabled.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Motors
impl Send for Motors
impl Sync for Motors
impl Unpin for Motors
impl !UnwindSafe for Motors
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
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.
pub 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>,