Writing the motor controller

The motor controllers in src/motor.rs will be responsible for making decisions regarding how much force to generate from the motor. The physics driver will supply current state information regarding all known measurements of location, velocity, and so on. Currently, the motor controller uses only the most current information to make control decisions. However, this may change in the future, in which case the controller may store past measurements.

Extracting the same control algorithm from the previous chapter, the new MotorController definition becomes as follows:

pub struct SimpleMotorController{   pub esp: ElevatorSpecification}impl MotorController for SimpleMotorController{ fn init(&mut self, esp: ElevatorSpecification, ...

Get Hands-On Functional Programming in Rust now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.