#[repr(i8)]pub enum Direction {
Clockwise = 1,
CounterClockwise = -1,
}Expand description
The direction a motor needs to turn to make the robot move forward.
This depends on how the motor is physically mounted on your robot:
- Clockwise: Use this if the motor shaft points toward the front of the robot
- CounterClockwise: Use this if the motor shaft points toward the back of the robot
§Examples
For a typical two-wheeled robot with motors on opposite sides:
use ev3_drivebase::{Motor, Direction};
use ev3_drivebase::ev3dev_lang_rust::motors::MotorPort;
// Left motor (shaft points forward)
let left = Motor::new(MotorPort::OutA, Direction::Clockwise);
// Right motor (shaft points backward due to mirrored mounting)
let right = Motor::new(MotorPort::OutB, Direction::CounterClockwise);Variants§
Clockwise = 1
Motor needs to turn clockwise to move the robot forward.
CounterClockwise = -1
Motor needs to turn counter-clockwise to move the robot forward.
Implementations§
Source§impl Direction
impl Direction
Sourcepub const fn sign(self) -> i32
pub const fn sign(self) -> i32
Returns the sign multiplier for this direction.
Clockwisereturns1CounterClockwisereturns-1
This is used internally for calculating motor encoder counts.
§Examples
use ev3_drivebase::Direction;
assert_eq!(Direction::Clockwise.sign(), 1);
assert_eq!(Direction::CounterClockwise.sign(), -1);Trait Implementations§
Source§impl Ord for Direction
impl Ord for Direction
Source§impl PartialOrd for Direction
impl PartialOrd for Direction
impl Copy for Direction
impl Eq for Direction
impl StructuralPartialEq for Direction
Auto Trait Implementations§
impl Freeze for Direction
impl RefUnwindSafe for Direction
impl Send for Direction
impl Sync for Direction
impl Unpin for Direction
impl UnwindSafe for Direction
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)