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

Swerve module configuration after angle set. #155

Closed
astaugaard opened this issue Jan 25, 2024 · 2 comments
Closed

Swerve module configuration after angle set. #155

astaugaard opened this issue Jan 25, 2024 · 2 comments

Comments

@astaugaard
Copy link

Hi, sorry if this is an already known issue. When my team was setting up yagsl on our swerve drive we noticed that the conversion factors for angle motors and the inversion of the motor are set after the position of the motor was being set. This seemed to cause the motors to be set to about the (angle conversion factor) times higher than what they theoretically should be, and moving the setting of the conversion factor to before the position is set fixed the issue for us. And there was also a similar issue for us with the inversion.

    absoluteEncoder = moduleConfiguration.absoluteEncoder;
    if (absoluteEncoder != null)
    {
      absoluteEncoder.factoryDefault();
      absoluteEncoder.configure(moduleConfiguration.absoluteEncoderInverted);
      angleMotor.setPosition(getAbsolutePosition());
    }

    // Config angle motor/controller
    angleMotor.configureIntegratedEncoder(moduleConfiguration.conversionFactors.angle);
    angleMotor.configurePIDF(moduleConfiguration.anglePIDF);
    angleMotor.configurePIDWrapping(0, 180);
    angleMotor.setInverted(moduleConfiguration.angleMotorInverted);
    angleMotor.setMotorBrake(false);

vs

    absoluteEncoder = moduleConfiguration.absoluteEncoder;
    angleMotor.configureIntegratedEncoder(moduleConfiguration.conversionFactors.angle);
    if (absoluteEncoder != null)
    {
      absoluteEncoder.factoryDefault();
      absoluteEncoder.configure(moduleConfiguration.absoluteEncoderInverted);
      angleMotor.setPosition(getAbsolutePosition());
    }

    // Config angle motor/controller
    angleMotor.configurePIDF(moduleConfiguration.anglePIDF);
    angleMotor.configurePIDWrapping(0, 180);
    angleMotor.setInverted(moduleConfiguration.angleMotorInverted); // haven't yet tested moving this line yet but we fixed the issue in an other very hacky way(not a universal way)
    angleMotor.setMotorBrake(false);

Thanks for your time, and this great library.

p.s. if I forgot to include something, sorry

@thenetworkgrinch thenetworkgrinch transferred this issue from BroncBotz3481/YAGSL Jan 25, 2024
@thenetworkgrinch
Copy link
Contributor

This shouldn't cause any issue however it never hurts to be verbose. If you would like to create a PR from https://github.com/BroncBotz3481/YAGSL-Example/tree/dev I will include this in the upcoming version and credit you in the changelogs!

@thenetworkgrinch
Copy link
Contributor

Fixed in this commit. 6adb7d0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants