Revision 29943713

View differences:

components/MotorControl.cpp
314 314

  
315 315
    //pgain #####################################
316 316
    chSysLock();
317
    int diffv =this->targetVelocity.x - this->currentVelocity.x;
318
    int diffw = this->targetVelocity.w_z - this->currentVelocity.w_z;
317
   
318
    int diffv = motorEnable ? this->targetVelocity.x - this->currentVelocity.x : 0;
319
    int diffw = motorEnable ? this->targetVelocity.w_z - this->currentVelocity.w_z: 0;
319 320
    chSysUnlock();
320 321

  
321 322
    //igain ####################################
......
534 535
    }
535 536

  
536 537
    for (int idxPWM = 0; idxPWM < 2; idxPWM++)
537
      pwmEnableChannel(this->pwmDriver, (idxWheel * 2) + idxPWM, motorEnable ? widths[idxPWM] : 0);
538
      pwmEnableChannel(this->pwmDriver, (idxWheel * 2) + idxPWM,widths[idxPWM]);
538 539
  }
539 540
}
540 541

  
......
559 560
}
560 561

  
561 562
bool MotorControl::getMotorEnable(){
563
  
562 564
  return this->motorEnable;
563 565
}
564 566

  
565 567
void MotorControl::toggleMotorEnable(){
568
  this->accumulatedErrorV = 0;
569
  this->accumulatedErrorW = 0;
566 570
  this->motorEnable = !this->motorEnable;
567 571
}

Also available in: Unified diff