Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drivetrain acceleration limits causes significant lag #31

Open
ProfessorAtomicManiac opened this issue Mar 7, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@ProfessorAtomicManiac
Copy link
Contributor

ProfessorAtomicManiac commented Mar 7, 2024

if(translationalAcceleration > autoMaxAccelMps2) {
Translation2d limitedAccelerationVector = new Translation2d(autoMaxAccelMps2, Rotation2d.fromRadians(Math.atan2(accelerationY, accelerationX)));
Translation2d limitedVelocityVector = limitedAccelerationVector.times(robotPeriod);
currentForwardVel += limitedVelocityVector.getX();
currentStrafeVel += limitedVelocityVector.getY();
} else {

If only the else statement runs, then there is no lag. The if statement is meant to limit the acceleration of the robot to avoid tipping over. It is suspected that the lag is caused by acceleration/velocity limits that don't allow it to deaccelerate fast enough.

Please see Constants.java to see all the variables used to calculate the acceleration limit.
The mu variable is meant to account for the friction of the carpet. Increasing mu which should increase the acceleration limit should reduce lag, but the reduction of lag is not significant.

public static final double mu = 1; /* 70/83.2; */

Based on current observations, it seems like the if statement is running as intended. Would suggest calculating a better acceleration limit using better physics calculations or "guess and check" a better value.

@ProfessorAtomicManiac ProfessorAtomicManiac added the bug Something isn't working label Mar 7, 2024
@brettle
Copy link
Member

brettle commented Mar 7, 2024

Per my mattermost post, the acceleration limit isn't actually causing the lag per se. It is preventing the driver from using the stick to manually do what the velocity PID should be doing for them. The real bug is that velocity PID is not responding quickly enough.

The current calculation of autoMaxAccelMps2 is correct. To verify, follow the steps in this post.

While removing (or sufficiently raising) the acceleration limit will make the lag go away, it will force the driver to do what they shouldn't need to do and could also cause them to develop driving habits that will not be appropriate when the underlying bug of slow velocity control is fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants