5 #include "../../include/commands/DriveMotorRPM.h" 11 this->motorHardware = motorHardware;
12 this->encoder = encoder;
13 this->direction = direction;
14 this->desiredRPM = desiredRPM;
24 double currentRPM = encoder->
getRPM();
25 double diff = this->desiredRPM - currentRPM;
27 double pd = this->k_p * diff + this->k_d * (diff - lastDiff);
28 this->setpoint = this->setpoint + pd;
31 if(this->setpoint > FULL_FORWARD) {
32 this->setpoint = FULL_FORWARD;
34 if(this->setpoint < FULL_BACKWARD) {
35 this->setpoint = FULL_BACKWARD;
45 this->lastDiff = diff;
DriveMotorRPM(Communicator *comm, Hardware motorHardware, EncoderSensor *encoder, int desiredRPM, int direction)
bool cleanup(bool canceled) override
void queueMessage(IMessage *message)