Revision 753ccd04
components/MotorControl.cpp | ||
---|---|---|
534 | 534 |
} |
535 | 535 |
|
536 | 536 |
for (int idxPWM = 0; idxPWM < 2; idxPWM++) |
537 |
pwmEnableChannel(this->pwmDriver, (idxWheel * 2) + idxPWM, widths[idxPWM]);
|
|
537 |
pwmEnableChannel(this->pwmDriver, (idxWheel * 2) + idxPWM, motorEnable ? widths[idxPWM] : 0);
|
|
538 | 538 |
} |
539 | 539 |
} |
540 |
|
|
541 |
|
|
542 |
void MotorControl::setGains(motorGains *motorConfig){ |
|
543 |
chSysLock(); |
|
544 |
this->pGain = motorConfig->pGain; |
|
545 |
this->iGain = motorConfig->iGain; |
|
546 |
this->dGain = motorConfig->dGain; |
|
547 |
chSysUnlock(); |
|
548 |
} |
|
549 |
|
|
550 |
void MotorControl::getGains(motorGains *motorConfig){ |
|
551 |
motorGains gains; |
|
552 |
motorConfig->pGain = this->pGain; |
|
553 |
motorConfig->iGain = this->iGain; |
|
554 |
motorConfig->dGain = this->dGain; |
|
555 |
} |
|
556 |
|
|
557 |
void MotorControl::setMotorEnable(bool enable){ |
|
558 |
this->motorEnable = enable; |
|
559 |
} |
|
560 |
|
|
561 |
bool MotorControl::getMotorEnable(){ |
|
562 |
return this->motorEnable; |
|
563 |
} |
|
564 |
|
|
565 |
void MotorControl::toggleMotorEnable(){ |
|
566 |
this->motorEnable = !this->motorEnable; |
|
567 |
} |
include/amiro/MotorControl.h | ||
---|---|---|
8 | 8 |
|
9 | 9 |
namespace amiro { |
10 | 10 |
|
11 |
struct motorGains |
|
12 |
{ |
|
13 |
int pGain = 0; |
|
14 |
float iGain = 0.0; |
|
15 |
float dGain = 0.0; |
|
16 |
}; |
|
17 |
|
|
11 | 18 |
class MotorControl : public chibios_rt::BaseStaticThread<512> { |
12 | 19 |
public: |
13 | 20 |
/** |
... | ... | |
135 | 142 |
*/ |
136 | 143 |
void resetGains(); |
137 | 144 |
|
145 |
void setGains(motorGains *motorConfig); |
|
146 |
|
|
147 |
void getGains(motorGains *motorConfig); |
|
148 |
|
|
149 |
void setMotorEnable(bool enable); |
|
150 |
bool getMotorEnable(); |
|
151 |
void toggleMotorEnable(); |
|
138 | 152 |
protected: |
139 | 153 |
virtual msg_t main(void); |
140 | 154 |
|
... | ... | |
262 | 276 |
bool startedZieglerCalibration = false; |
263 | 277 |
bool startedWheelCalibration = false; |
264 | 278 |
bool motorCalibration = true; |
279 |
bool motorEnable = true; |
|
265 | 280 |
|
266 | 281 |
|
267 | 282 |
|
Also available in: Unified diff