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

Advantagekit integration #5

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from
Draft

Advantagekit integration #5

wants to merge 18 commits into from

Conversation

devsamuelv
Copy link
Member

@devsamuelv devsamuelv commented Nov 1, 2023

Dev Note

Integrated AdvantageKit into the intake subsystem. Accomplished by creating an input layer for the intake & created a generic IO interface to allow for the transfer of common methods like processInputs, stop & inputs object.

Here's an example IO class using the custom IO interface. It's bare right now however as IO layers become more complicated, this will help with standardizing the process.

public abstract class IntakeIO extends IO<IntakeIOInputs> {
    public abstract void setVelocity(double speed);
}

Another thing, AdvantageKit creates a BuildConstants.java file to store build info about the project like current branch, commit id, etc. This helps with code tracking during testing & competition.

/**
 * Automatically generated file containing build version information.
 */
public final class BuildConstants {
  public static final String MAVEN_GROUP = "";
  public static final String MAVEN_NAME = "Cubezilla";
  public static final String VERSION = "unspecified";
  public static final int GIT_REVISION = 27;
  public static final String GIT_SHA = "1279ed054428f37e042782f7c354296845ee9b02";
  public static final String GIT_DATE = "2023-11-18 10:05:16 EST";
  public static final String GIT_BRANCH = "advantagekit-demo-sam";
  public static final String BUILD_DATE = "2023-11-23 15:03:35 EST";
  public static final long BUILD_UNIX_TIME = 1700769815067L;
  public static final int DIRTY = 1;

  private BuildConstants(){}
}

Also in the ArmSubsystem I decided to experiment with an alternative structure which doesn't use an IO layer, since using one can cause most of the control functionality moving into the IO layer which isn't ideal if your trying to keep subsystems involved. Hence the experiment, an actually I found that turning the subsystem into a layer is a good alternative.

I'll elaborate, If we combine the update logic that would typically reside in updateInputs method. We are basically giving some of the responsibilities of updating inputs to the subsystem. The subsystem now can log data however doing this removes the ability to change the behavior & objects being used which is crucial for simulation since sometimes their are completely different versions of the device classes being used when it comes to simulation. Now, I'm not saying you can't also combine that logic into the subsystem itself, but if your going to do that then try looking to the layer solution first.

public void periodic() {
    double leftArmEncoderValue = leftSparxMax.getEncoder().getPosition();
    double rightArmEncoderValue = rightSparxMax.getEncoder().getPosition();

    SmartDashboard.putNumber("left Arm Neo Encoder Value", (leftArmEncoderValue));
    SmartDashboard.putNumber("Right Arm Neo Encoder Value", (rightArmEncoderValue));

    inputs.armPosition = leftSparxMax.getEncoder().getPosition();

    Logger.getInstance().processInputs("Arm", inputs);
}

For more context, you also need to update the inputs when doing any control work like powering a motor or giving a PIDController a target like so.

public void setDesiredPos(double desiredPos) {
    leftSparxMax.getPIDController().setReference(desiredPos, CANSparkMax.ControlType.kPosition);

    inputs.armSetpoint = desiredPos;
}

devsamuelv and others added 14 commits October 7, 2023 19:30
corrected and added Motor IDs. Also added an arm command file
Created an arm pivot system. Arm moved to down pos when Y is pressed. Up pos untested due to extreme gear ratios.
created an arm speed cap
added a "back to start" button (x) that moves the arm back to the closed position. Also separated the tower and base joysticks.
@devsamuelv devsamuelv linked an issue Nov 17, 2023 that may be closed by this pull request
4 tasks
@devsamuelv devsamuelv added this to the PRE-2k24-KICKOFF milestone Nov 24, 2023
@devsamuelv devsamuelv self-assigned this Nov 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate Advantage Kit
3 participants