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

Maya arm #13

Open
wants to merge 27 commits into
base: on-robot
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
7ea49a3
maya-add-subsystem
maya1414 Jul 31, 2024
fe1cc4c
maya-add-final-to-motor
maya1414 Aug 4, 2024
7471280
maya and danna - added pid and move to angle
maya1414 Aug 4, 2024
d2b078c
merge on-robot
maya1414 Aug 7, 2024
eb16230
finish isAtAngle
maya1414 Aug 7, 2024
4338039
maya add roller elbow and wrist subsystems
maya1414 Aug 7, 2024
e4f4f9b
maya add to MoveToAngleWrist, MoveToSpeedRoller, MoveElbowToAngle com…
maya1414 Aug 11, 2024
78f4089
maya-change
maya1414 Aug 18, 2024
e19e438
maya-fix-after-CR
maya1414 Aug 18, 2024
6dfc768
add ElbowSimulation, work on Elbow, IElbow, add to SimulationElbowCon…
maya1414 Aug 18, 2024
5b1dd6a
maya- fixed according to CR
maya1414 Aug 20, 2024
3eeddbe
maya- fixed according to CR.. tolerance...
maya1414 Aug 20, 2024
0c12770
maya- fixed according to CR
maya1414 Aug 21, 2024
9fc7b1a
maya- fixed according to CR
maya1414 Aug 21, 2024
83bfcac
maya- add to ElbowFactory, ElbowNEO, ElbowSimulation, TrainingRobotMa…
maya1414 Aug 21, 2024
1ec631e
work on CR
maya1414 Aug 21, 2024
3b7a013
work on CR
maya1414 Aug 21, 2024
7763e14
maya- add PID...
maya1414 Aug 21, 2024
96fe322
maya- fixed according to CR
maya1414 Aug 21, 2024
8fd0df9
maya- work on CR
maya1414 Aug 21, 2024
0bf1b22
maya- work on CR
maya1414 Aug 23, 2024
1c4801c
maya- work on CR
maya1414 Aug 23, 2024
9d8ceac
maya- work on joystick
maya1414 Aug 23, 2024
a608f3a
maya- work on joystick
maya1414 Aug 23, 2024
ed50ad2
maya- work on CR
maya1414 Aug 23, 2024
c8560e2
maya- work on inputs
maya1414 Aug 23, 2024
fb80cc5
maya- work on CR
maya1414 Aug 23, 2024
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
12 changes: 8 additions & 4 deletions src/main/java/training/commands/elbow/MoveElbowToAngle.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,25 @@ public class MoveElbowToAngle extends Command {

private Rotation2d targetAngle;

public Elbow getInstance() {
return Elbow.getInstance();
}
maya1414 marked this conversation as resolved.
Show resolved Hide resolved

public MoveElbowToAngle(Rotation2d targetAngle) {
this.targetAngle = targetAngle;
}

@Override
public void initialize() {
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
Elbow.getInstance().goToAngle(targetAngle);
getInstance().goToAngle(targetAngle);
}

public boolean isFinished() {
return Elbow.getInstance().isAtAngle(targetAngle);
return getInstance().isAtAngle(targetAngle);
}

public void end(boolean interrupted) {
Elbow.getInstance().stop();
getInstance().stayAtPosition();
}

}
}
11 changes: 7 additions & 4 deletions src/main/java/training/commands/roller/MoveToSpeedRoller.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,20 @@ public class MoveToSpeedRoller extends Command {

private double targetSpeed;

public Roller getInstance() {
return Roller.getInstance();
}
maya1414 marked this conversation as resolved.
Show resolved Hide resolved

public void MoveToSpeedSpeed(double targetSpeed) {
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
this.targetSpeed = targetSpeed;
}


public boolean isFinished() {
return Roller.getInstance().isAtVelocity(targetSpeed);
return getInstance().isAtVelocity(targetSpeed);
}

public void end(boolean interrupted) {
Roller.getInstance().stop();
getInstance().stop();
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,29 @@
import edu.wpi.first.wpilibj2.command.Command;
import training.subsystems.wrist.Wrist;

public class MoveToAngleWrist extends Command {
public class MoveWristToAngle extends Command {

private Rotation2d targetAngle;

public MoveToAngleWrist(Rotation2d targetAngle) {
public Wrist getInstance() {
return Wrist.getInstance();
}
maya1414 marked this conversation as resolved.
Show resolved Hide resolved

public MoveWristToAngle(Rotation2d targetAngle) {
this.targetAngle = targetAngle;
}

@Override
public void initialize() {
Wrist.goToAngle(targetAngle);
getInstance().goToAngle(targetAngle);
}

public boolean isFinished() {
return Wrist.getInstance().isAtAngle(targetAngle);
return getInstance().isAtAngle(targetAngle);
}

public void end(boolean interrupted) {
Wrist.getInstance().stop();
getInstance().stop();
}

}

}
21 changes: 10 additions & 11 deletions src/main/java/training/subsystems/elbow/Elbow.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@

public class Elbow extends GBSubsystem {

private final CANSparkMax motor;
private static Elbow instance;
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
private ArmFeedforward armFeedforward;
private final CANSparkMax motor;
private final ArmFeedforward armFeedforward;
maya1414 marked this conversation as resolved.
Show resolved Hide resolved

private Elbow() {
this.armFeedforward = ElbowConstants.ARM_FEEDFORWARD;
this.motor = new CANSparkMax(ElbowConstants.MOTOR_ID, CANSparkLowLevel.MotorType.kBrushless);
motor.getPIDController().setP(ElbowConstants.MOTOR_P);
motor.getPIDController().setI(ElbowConstants.MOTOR_I);
motor.getPIDController().setD(ElbowConstants.MOTOR_D);
motor.getPIDController().setP(ElbowConstants.P);
motor.getPIDController().setI(ElbowConstants.I);
motor.getPIDController().setD(ElbowConstants.D);
}

public static void init() {
Expand All @@ -40,7 +40,6 @@ public Rotation2d getVelocity() {
return Rotation2d.fromRotations(motor.getEncoder().getVelocity());
}


public void goToAngle(Rotation2d targetAngle) {
motor.getPIDController()
.setReference(
Expand All @@ -55,17 +54,17 @@ public boolean isAtAngle(Rotation2d targetAngle) {
return Math.abs(targetAngle.getDegrees() - motor.getEncoder().getPosition()) == 0;
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
}

public void stop() {
public void stayAtPosition() {
goToAngle(getPosition());
}


@Override
protected String getLogPath() {
return "";
return "Elbow/";
}

@Override
protected void subsystemPeriodic() {}
protected void subsystemPeriodic() {
}

}
}
8 changes: 4 additions & 4 deletions src/main/java/training/subsystems/elbow/ElbowConstants.java
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public enum PresetPositions {


public static final int MOTOR_ID = 5;
public static final int MOTOR_P = 1;
public static final int MOTOR_I = 0;
public static final int MOTOR_D = 0;
public static final int P = 1;
public static final int I = 0;
public static final int D = 0;

public static final int PID_SLOT = 0;

Expand All @@ -41,4 +41,4 @@ public enum PresetPositions {
public static final Rotation2d BACKWARD_ANGLE_LIMIT = Rotation2d.fromDegrees(-81);
public static final Rotation2d FORWARD_ANGLE_LIMIT = Rotation2d.fromDegrees(90);

}
}
2 changes: 1 addition & 1 deletion src/main/java/training/subsystems/elbow/ElbowFactory.java
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package training.subsystems.elbow;

public class ElbowFactory {
}
}
13 changes: 6 additions & 7 deletions src/main/java/training/subsystems/elbow/ElbowNEO.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import edu.wpi.first.math.controller.ArmFeedforward;
import edu.wpi.first.math.geometry.Rotation2d;

public class ElbowNEO implements IElbow {
public class ElbowNEO {
maya1414 marked this conversation as resolved.
Show resolved Hide resolved

private CANSparkMax motor;
private static ElbowNEO instance;
Expand All @@ -15,9 +15,9 @@ public class ElbowNEO implements IElbow {
private ElbowNEO() {
this.armFeedforward = ElbowConstants.ARM_FEEDFORWARD;
this.motor = new CANSparkMax(ElbowConstants.MOTOR_ID, CANSparkLowLevel.MotorType.kBrushless);
motor.getPIDController().setP(ElbowConstants.MOTOR_P);
motor.getPIDController().setI(ElbowConstants.MOTOR_I);
motor.getPIDController().setD(ElbowConstants.MOTOR_D);
motor.getPIDController().setP(ElbowConstants.P);
motor.getPIDController().setI(ElbowConstants.I);
motor.getPIDController().setD(ElbowConstants.D);
}

public void init() {
Expand Down Expand Up @@ -56,9 +56,8 @@ public boolean isAtAngle(Rotation2d targetAngle) {
return Math.abs(targetAngle.getDegrees() - motor.getEncoder().getPosition()) == 0;
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
}

public void stop() {
public void stayAtPosition() {
goToAngle(getPosition());
}


}
}
16 changes: 8 additions & 8 deletions src/main/java/training/subsystems/elbow/ElbowSimulation.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public class ElbowSimulation implements IElbow {
private SingleJointedArmSimulation elbowSimulation;
private ArmFeedforward armFeedforward;
private PIDController controller;
private PositionVoltage pos;
maya1414 marked this conversation as resolved.
Show resolved Hide resolved

private ElbowSimulation() {
SingleJointedArmSim armSim = new SingleJointedArmSim(
Expand All @@ -35,6 +36,11 @@ private ElbowSimulation() {
elbowSimulation.applyConfiguration(config);
}

public void goToAngle(Rotation2d targetAngle) {
pos = new PositionVoltage(targetAngle.getRotations());
elbowSimulation.setControl(pos);
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
}

public Rotation2d getPosition() {
return elbowSimulation.getPosition();
}
Expand All @@ -43,14 +49,8 @@ public Rotation2d getVelocity() {
return elbowSimulation.getVelocity();
}


public void goToAngle(Rotation2d targetAngle) {
PositionVoltage pos = new PositionVoltage(targetAngle.getRotations());
elbowSimulation.setControl(pos);
}

public void stop() {
public void stayAtPosition() {
goToAngle(getPosition());
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@ public class SimulationElbowConstants {

public static final double D = 0;

}
}
10 changes: 1 addition & 9 deletions src/main/java/training/subsystems/roller/IRoller.java
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,6 @@

public interface IRoller {

void stop();

Roller getInstance();

void goToSpeed(double targetSpeed);

boolean isAtVelocity(double targetVelocity);

void init();

}
}
17 changes: 8 additions & 9 deletions src/main/java/training/subsystems/roller/Roller.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@

public class Roller extends GBSubsystem {

private static CANSparkMax motor;
private static Roller instance;
private final CANSparkMax motor;

private Roller() {
motor = new CANSparkMax(RollerConstants.MOTOR_ID, CANSparkLowLevel.MotorType.kBrushless);
motor.getPIDController().setP(RollerConstants.MOTOR_P);
motor.getPIDController().setI(RollerConstants.MOTOR_I);
motor.getPIDController().setD(RollerConstants.MOTOR_D);
motor.getPIDController().setP(RollerConstants.P);
motor.getPIDController().setI(RollerConstants.I);
motor.getPIDController().setD(RollerConstants.D);
}

maya1414 marked this conversation as resolved.
Show resolved Hide resolved

Expand All @@ -41,14 +41,13 @@ public void stop() {
motor.set(0);
}

maya1414 marked this conversation as resolved.
Show resolved Hide resolved

@Override
protected String getLogPath() {
return "";
return "Roller/";
}

@Override
protected void subsystemPeriodic() {}

}
protected void subsystemPeriodic() {
}

}
9 changes: 4 additions & 5 deletions src/main/java/training/subsystems/roller/RollerConstants.java
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@
public class RollerConstants {

public static final int MOTOR_ID = 22;
public static final int MOTOR_P = 1;
public static final int MOTOR_I = 0;
public static final int MOTOR_D = 0;
public static final int P = 1;
public static final int I = 0;
public static final int D = 0;


}
}
8 changes: 2 additions & 6 deletions src/main/java/training/subsystems/wrist/IWrist.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,8 @@ public interface IWrist {

void init();
maya1414 marked this conversation as resolved.
Show resolved Hide resolved

void goToAngel(Rotation2d targetAngle);

boolean isAtAngle(Rotation2d targetAngle);

Wrist getInstance();
void goToAngle(Rotation2d targetAngle);

void stop();

}
}
19 changes: 9 additions & 10 deletions src/main/java/training/subsystems/wrist/Wrist.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

public class Wrist extends GBSubsystem {

private static CANSparkMax motor;
private static Wrist instance;
private final CANSparkMax motor;

private Wrist() {
motor = new CANSparkMax(WristConstant.MOTOR_ID, CANSparkLowLevel.MotorType.kBrushless);
motor.getPIDController().setP(WristConstant.MOTOR_P);
motor.getPIDController().setI(WristConstant.MOTOR_I);
motor.getPIDController().setD(WristConstant.MOTOR_D);
motor.getPIDController().setP(WristConstant.P);
motor.getPIDController().setI(WristConstant.I);
motor.getPIDController().setD(WristConstant.D);
}

public static Wrist getInstance() {
Expand All @@ -29,7 +29,7 @@ public static void init() {
}
}

public static void goToAngle(Rotation2d targetAngle) {
public void goToAngle(Rotation2d targetAngle) {
motor.getPIDController().setReference(targetAngle.getDegrees(), CANSparkBase.ControlType.kPosition);
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
}

Expand All @@ -41,14 +41,13 @@ public void stop() {
motor.set(0);
}


@Override
protected String getLogPath() {
return "Wrist";
return "Wrist/";
}

@Override
protected void subsystemPeriodic() {}

}
protected void subsystemPeriodic() {
}

}
Loading
Loading