pub trait Robot: AngleProvider {
Show 13 methods
// Required methods
fn drive(
&self,
distance: impl Into<Distance>,
speed: impl Into<Speed>,
) -> Result<()>;
fn turn(&self, angle: Heading, speed: impl Into<Speed>) -> Result<()>;
fn turn_named(
&self,
angle: Heading,
speed: impl Into<Speed>,
turn: TurnType,
) -> Result<()>;
fn set_heading(&self, angle: Heading) -> Result<()>;
fn motor(&self, motor: MotorId) -> Option<RefMut<'_, dyn Motor>>;
fn color_sensor(
&self,
port: SensorPort,
) -> Option<RefMut<'_, dyn ColorSensor>>;
fn process_buttons(&self) -> Result<Input>;
fn battery(&self) -> Result<Percent>;
fn await_input(&self, timeout: Option<Duration>) -> Result<Input>;
fn stop(&self) -> Result<()>;
fn reset(&self) -> Result<()>;
fn spec(&self) -> &RobotSpec;
// Provided method
fn handle_interrupt(&self) -> Result<()> { ... }
}Expand description
Represents a simple robot with 2 wheels to move and a method to sense direction
Required Methods§
Sourcefn drive(
&self,
distance: impl Into<Distance>,
speed: impl Into<Speed>,
) -> Result<()>
fn drive( &self, distance: impl Into<Distance>, speed: impl Into<Speed>, ) -> Result<()>
Drive the robot using the gyro to correct for errors
§Returns
Returns an error if an interrupt has been requested Otherwise, returns Ok(())
Sourcefn turn_named(
&self,
angle: Heading,
speed: impl Into<Speed>,
turn: TurnType,
) -> Result<()>
fn turn_named( &self, angle: Heading, speed: impl Into<Speed>, turn: TurnType, ) -> Result<()>
fn set_heading(&self, angle: Heading) -> Result<()>
fn color_sensor(&self, port: SensorPort) -> Option<RefMut<'_, dyn ColorSensor>>
Returns the status of the robot’s buttons
Provided Methods§
Sourcefn handle_interrupt(&self) -> Result<()>
fn handle_interrupt(&self) -> Result<()>
Returns an error if an interrupt has been requested Otherwise, returns Ok(())
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.