Skip to content

Commit fbe410f

Browse files
Use exponential acceleration instead of linear.
No consideration made for time delta. Assuming constant delta. This may bite us. STATUS: Tested on compbot. - Logan H-D
1 parent e5bb4a7 commit fbe410f

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/main/cpp/subsystems/DriveTrain.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -185,14 +185,14 @@ void DriveTrain::ArcadeDrive(double xSpeed, double zRotation, bool squareInputs)
185185
// v_{i+1} is the next velocity to send to the motors,
186186
// a is the max acceleration, and
187187
// dt is the time delta in seconds since the velocity step.
188-
double allowedLeft = ComputeNextOutputDelta(
188+
double allowedLeft = ComputeNextOutput(
189189
currentLeft,
190190
desiredLeft,
191191
maxLeftAccel,
192192
timeDelta
193193
);
194194

195-
double allowedRight = ComputeNextOutputDelta(
195+
double allowedRight = ComputeNextOutput(
196196
currentRight,
197197
desiredRight,
198198
maxRightAccel,
@@ -292,7 +292,7 @@ void DriveTrain::UseDukesSpeedLimit() {
292292
#endif
293293
}
294294

295-
double DriveTrain::ComputeNextOutputDelta(double iVel, double fVel, double maxAccel, double timeDelta) {
295+
double DriveTrain::ComputeNextOutput(double iVel, double fVel, double maxAccel, double timeDelta) {
296296
double deltaVel = fVel - iVel;
297-
return iVel + std::copysign(std::min(std::abs(deltaVel), maxAccel * timeDelta), deltaVel);
297+
return iVel + deltaVel / 2.0;
298298
}

src/main/include/subsystems/DriveTrain.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ class DriveTrain : public frc::Subsystem, public frc::RobotDriveBase {
8282
double m_MaxAcceleration;
8383
StopWatch m_TimeDelta;
8484

85-
double ComputeNextOutputDelta(double iVel, double fVel, double maxAccel, double timeDelta);
85+
double ComputeNextOutput(double iVel, double fVel, double maxAccel, double timeDelta);
8686

8787
// Config setpoints.
8888
double m_MaxNormalSpeed;

0 commit comments

Comments
 (0)