Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions src/main/java/xbot/common/subsystems/arm/BaseArmSubsystem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package xbot.common.subsystems.arm;

import javax.inject.Singleton;

import org.wpilib.command2.Command;
import org.wpilib.command2.Commands;
import org.wpilib.units.measure.Angle;

import xbot.common.command.BaseSetpointSubsystem;
import xbot.common.controls.actuators.XCANMotorController;
import xbot.common.properties.TunableFactory;

@Singleton
public abstract class BaseArmSubsystem extends BaseSetpointSubsystem<Angle, Double> {

boolean isCalibrated = false;
boolean hasAbsoluteEncoder;

public BaseArmSubsystem(XCANMotorController.XCANMotorControllerFactory xcanMotorControllerFactory, TunableFactory tunableFactory) {
super();
tunableFactory.setPrefix(this);

}

public abstract Angle getTargetValue();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⭐ ⭐ this probably doesn't have to be abstract does it?


public abstract boolean hasAbsoluteEncoder();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⭐ ⭐ ⭐ this one for sure doesn't need to be abstract, you have an instance variable up above for is there an absolute encoder?


public abstract void setTargetValue(Angle desiredAngle);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⭐ ⭐ Same thing here


public abstract void setPower(Double power);

public abstract boolean isCalibrated();

protected abstract boolean areTwoTargetsEquivalent(Angle target1, Angle target2);

@Override

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⭐ ⭐ This periodic override isn't doing anything, the same as removing it. Or is there something that should happen here? Like recording properties?

public void periodic() {
super.periodic();
}

public abstract Angle getCurrentValue();

public Command getHasAbsoluteEncoder() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ what would this command be used for?

return Commands.runOnce(() -> {
hasAbsoluteEncoder = hasAbsoluteEncoder();
});
}

public Command getCalibrateCommand() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ I'm confused about what this one is for as well. Is it about calibrating the current arm position?

return Commands.runOnce(() -> {
isCalibrated = isCalibrated();
});
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package xbot.common.subsystems.arm.commands;

import org.wpilib.units.measure.Angle;

import xbot.common.command.BaseMaintainerCommand;
import xbot.common.logic.HumanVsMachineDecider;
import xbot.common.properties.TunableFactory;
import xbot.common.subsystems.arm.BaseArmSubsystem;

public abstract class BaseArmMaintainer extends BaseMaintainerCommand<Angle, Double> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⭐ ⭐ ⭐ this maintainer isn't doing much right now, it's basically the same as not having this class at all and people just extending BaseMaintainer themselves?


final BaseArmSubsystem baseArm;

public BaseArmMaintainer(TunableFactory tunableFactory, HumanVsMachineDecider.HumanVsMachineDeciderFactory hvmFactory, BaseArmSubsystem baseArm) {
super(baseArm, tunableFactory, hvmFactory, 1, 1);

this.baseArm = baseArm;
}

public abstract void initialize();

protected abstract void coastAction();

protected abstract void calibratedMachineControlAction();

protected abstract double getErrorMagnitude();

protected abstract Double getHumanInput();

protected abstract double getHumanInputMagnitude();
}
Loading