Skip to content
This repository was archived by the owner on Jul 25, 2022. It is now read-only.

Commit 68d5985

Browse files
committed
Tuned adjusted amplitude for faster drive.
1 parent afd0dad commit 68d5985

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

robot-control-src/Drives.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,18 @@ bool Drive<MOTORCONTROL, motorControlpin, DIRECTIONPIN, directionPin, ODOPIN, od
3333
* cycle of the right motor control.
3434
*
3535
* The calibration fraction is defined as follows: It has been observed, that when the
36-
* duty cycle of the left is 350/1023, then the right should be 325/1023 in order for the
36+
* duty cycle of the left is x/1023, then the right should be y/1023 in order for the
3737
* drives to be equally fast. The linear functions is such that the difference is 0 with
3838
* a duty cycle of 100%.
3939
*/
4040
static Amplitude calcRightSpeed(const Amplitude leftSpeed)
4141
{
42-
constexpr double calibrationFraction = 25.0 / (maxAmplitude - 350.0);
43-
constexpr float a = 1.0 + calibrationFraction;
44-
constexpr float b = maxAmplitude * calibrationFraction;
45-
return a*leftSpeed - b;
42+
constexpr Amplitude leftAmplitude = 350; // x
43+
constexpr Amplitude rightMatchingAmplitude = 290; // y
44+
constexpr double calibrationFraction = (leftAmplitude
45+
- rightMatchingAmplitude)
46+
/ static_cast<double>(maxAmplitude - leftAmplitude);
47+
return leftSpeed - calibrationFraction * (maxAmplitude - leftSpeed);
4648
}
4749

4850
void rotateCounter(const Counter steps, const Amplitude amplitude, bool const clockwise)

0 commit comments

Comments
 (0)