Trait Robot

Source
pub trait Robot {
    // Required methods
    fn forward(&mut self, speed: f32);
    fn turn(&mut self, speed: f32);
    fn stop(&mut self);
}
Expand description

Represents a differential drive robot. All commands are assumed to supercede the previous one, i.e. they are not additive.

All speed fields are in arbitrary units of “power” between 0.0 and 1.0

Required Methods§

Source

fn forward(&mut self, speed: f32)

Drive the robot forward by running both motors. A negative speed will drive the robot backwards.

speed should be in the range [-1.0, 1.0]

Source

fn turn(&mut self, speed: f32)

A positive speed makes the robot turn right (clockwise). A negative speed makes the robot turn left (counter-clockwise).

speed should be in the range [-1.0, 1.0]

Source

fn stop(&mut self)

Stop the robot.

Implementors§