@@ -39,7 +39,7 @@ DriveTrain::DriveTrain(wpi::json &jsonConfig) : frc::Subsystem("DriveTrain") {
39
39
Subsystem::AddChild (" Left Drive PID" , &m_LeftPID);
40
40
Subsystem::AddChild (" Right Drive PID" , &m_RightPID);
41
41
#else
42
- m_MaxAcceleration = jsonConfig[" drive" ][" max -acceleration" ];
42
+ m_MinAcceleration = jsonConfig[" drive" ][" min -acceleration" ];
43
43
44
44
m_MaxNormalSpeed = jsonConfig[" drive" ][" max-normal-speed" ];
45
45
m_SandstormStepSpeed = jsonConfig[" drive" ][" sandstorm-step-speed" ];
@@ -147,27 +147,7 @@ void DriveTrain::ArcadeDrive(double xSpeed, double zRotation, bool squareInputs)
147
147
double currentLeft = m_LeftMotors.Get () / m_maxOutput;
148
148
double currentRight = m_RightMotors.Get () / m_maxOutput;
149
149
150
- double maxLeftAccel = m_MaxAcceleration, maxRightAccel = m_MaxAcceleration;
151
-
152
- /* *
153
- // Descrease the max velocity step size for the slower drive side so
154
- // turning takes effect sooner.
155
- //
156
- // WARNING: Doesn't really work from initial testing. Robot drives more straight.
157
- if (0.01 < std::abs(desiredLeft) - std::abs(desiredRight)) {
158
- // Left speed is faster than right.
159
- maxLeftAccel = m_MaxAcceleration;
160
- maxRightAccel = m_MaxAcceleration * desiredRight / desiredLeft;
161
- } else if (0.01 < std::abs(desiredRight) - std::abs(desiredLeft)) {
162
- // Right speed is faster than left.
163
- maxLeftAccel = m_MaxAcceleration * desiredLeft / desiredRight;
164
- maxRightAccel = m_MaxAcceleration;
165
- } else {
166
- // Both speeds are effectively same.
167
- maxLeftAccel = m_MaxAcceleration;
168
- maxRightAccel = m_MaxAcceleration;
169
- }
170
- /* */
150
+ double minLeftAccel = m_MinAcceleration, minRightAccel = m_MinAcceleration;
171
151
172
152
double timeDelta = m_TimeDelta.Split ();
173
153
@@ -182,14 +162,14 @@ void DriveTrain::ArcadeDrive(double xSpeed, double zRotation, bool squareInputs)
182
162
double allowedLeft = ComputeNextOutput (
183
163
currentLeft,
184
164
desiredLeft,
185
- maxLeftAccel ,
165
+ minLeftAccel ,
186
166
timeDelta
187
167
);
188
168
189
169
double allowedRight = ComputeNextOutput (
190
170
currentRight,
191
171
desiredRight,
192
- maxRightAccel ,
172
+ minRightAccel ,
193
173
timeDelta
194
174
);
195
175
@@ -318,7 +298,7 @@ void DriveTrain::UseDukesSpeedLimit() {
318
298
#endif
319
299
}
320
300
321
- double DriveTrain::ComputeNextOutput (double iVel, double fVel , double maxAccel , double timeDelta) {
322
- double deltaVel = fVel - iVel;
323
- return iVel + deltaVel / 2.0 ;
301
+ double DriveTrain::ComputeNextOutput (double iVel, double fVel , double minAccel , double timeDelta) {
302
+ double deltaVel = ( fVel - iVel) * 0.4 ;
303
+ return iVel + std::copysign ( std::min ( std::fabs ( deltaVel), minAccel), deltaVel) ;
324
304
}
0 commit comments