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 7 commits
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
27 changes: 27 additions & 0 deletions src/main/java/training/commands/elbow/MoveElbowToAngle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package training.commands.elbow;

import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.wpilibj2.command.Command;
import training.subsystems.elbow.Elbow;

public class MoveElbowToAngle extends Command {

private Rotation2d targetAngle;

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

@Override
public void initialize() {
Elbow.goToAngel(targetAngle);
}

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

public void end(boolean interrupted){
Elbow.getInstance().stop();
}
}
22 changes: 22 additions & 0 deletions src/main/java/training/commands/roller/MoveToSpeedRoller.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package training.commands.roller;

import edu.wpi.first.wpilibj2.command.Command;
import training.subsystems.roller.Roller;

public class MoveToSpeedRoller extends Command {
maya1414 marked this conversation as resolved.
Show resolved Hide resolved

private double targetSpeed;

public void MoveToSpeedSpeed(double targetSpeed){
this.targetSpeed = targetSpeed;
}


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

public void end(boolean interrupted){
Roller.getInstance().stop();
}
}
30 changes: 30 additions & 0 deletions src/main/java/training/commands/wrist/MoveToAngleWrist.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package training.commands.wrist;

import edu.wpi.first.math.geometry.Rotation2d;
import edu.wpi.first.wpilibj2.command.Command;
import training.subsystems.wrist.Wrist;

public class MoveToAngleWrist extends Command {
maya1414 marked this conversation as resolved.
Show resolved Hide resolved

private Rotation2d targetAngle;

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

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

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

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



53 changes: 53 additions & 0 deletions src/main/java/training/subsystems/elbow/Elbow.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
package training.subsystems.elbow;

import com.revrobotics.CANSparkBase;
import com.revrobotics.CANSparkLowLevel;
import com.revrobotics.CANSparkMax;
import edu.wpi.first.math.geometry.Rotation2d;
import utils.GBSubsystem;

public class Elbow extends GBSubsystem {

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

private Elbow() {
motor = new CANSparkMax(ElbowConstants.MOTOR_ID, CANSparkLowLevel.MotorType.kBrushless);
motor.getPIDController().setP(ElbowConstants.MOTOR_ID_P);
motor.getPIDController().setI(ElbowConstants.MOTOR_ID_I);
motor.getPIDController().setD(ElbowConstants.MOTOR_ID_D);
}

public static void init() {
if (instance == null) {
instance = new Elbow();
}
}

public static Elbow getInstance() {
init();
return instance;
}

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

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() {
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
motor.set(0);
}


@Override
protected String getLogPath() {
return "Elbow";
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
protected void subsystemPeriodic() {}

}
11 changes: 11 additions & 0 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
@@ -0,0 +1,11 @@
package training.subsystems.elbow;


public class ElbowConstants {

public static final int MOTOR_ID = 5;
public static final int MOTOR_ID_P = 1;
public static final int MOTOR_ID_I = 0;
public static final int MOTOR_ID_D = 0;
maya1414 marked this conversation as resolved.
Show resolved Hide resolved

}
62 changes: 62 additions & 0 deletions src/main/java/training/subsystems/roller/Roller.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package training.subsystems.roller;

import com.revrobotics.CANSparkBase;
import com.revrobotics.CANSparkLowLevel;
import com.revrobotics.CANSparkMax;
import edu.wpi.first.math.geometry.Rotation2d;
import training.subsystems.elbow.Elbow;
import training.subsystems.elbow.ElbowConstants;
import utils.GBSubsystem;

public class Roller extends GBSubsystem {

private static CANSparkMax motor;
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
private static Roller instance;
private Roller() {
motor = new CANSparkMax(RollerConstants.MOTOR_ID, CANSparkLowLevel.MotorType.kBrushless);
motor.getPIDController().setP(RollerConstants.MOTOR_ID_P);
motor.getPIDController().setI(RollerConstants.MOTOR_ID_I);
motor.getPIDController().setD(RollerConstants.MOTOR_ID_D);
}

maya1414 marked this conversation as resolved.
Show resolved Hide resolved

public static void init() {
if (instance == null) {
instance = new Roller();
}
}
public boolean isAtVelocity(double targetVelocity) {
return Math.abs(targetVelocity - motor.getEncoder().getVelocity()) == 0.0;
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
}

public void goToSpeed(double targetSpeed) {
motor.getPIDController().setReference(targetSpeed, CANSparkBase.ControlType.kVelocity);
}

public static Roller getInstance() {
init();
return instance;
}
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
public void stop() {
motor.set(0);
}

maya1414 marked this conversation as resolved.
Show resolved Hide resolved


@Override
protected String getLogPath() {
return null;
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
protected void subsystemPeriodic() {}
maya1414 marked this conversation as resolved.
Show resolved Hide resolved

}








10 changes: 10 additions & 0 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
@@ -0,0 +1,10 @@
package training.subsystems.roller;

public class RollerConstants {
public static final int MOTOR_ID = 22;
public static final int MOTOR_ID_P = 1;
public static final int MOTOR_ID_I = 0;
public static final int MOTOR_ID_D = 0;


maya1414 marked this conversation as resolved.
Show resolved Hide resolved
}
66 changes: 66 additions & 0 deletions src/main/java/training/subsystems/wrist/Wrist.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package training.subsystems.wrist;

import com.ctre.phoenix.motorcontrol.can.TalonSRX;
import com.revrobotics.CANSparkBase;
import com.revrobotics.CANSparkLowLevel;
import com.revrobotics.CANSparkMax;
import edu.wpi.first.math.geometry.Rotation2d;
import training.subsystems.elbow.ElbowConstants;
import training.subsystems.roller.Roller;
import training.subsystems.roller.RollerConstants;
import utils.GBSubsystem;

public class Wrist extends GBSubsystem {

private static CANSparkMax motor;
private static Wrist instance;

private Wrist() {
motor = new CANSparkMax(WristConstant.MOTOR_ID, CANSparkLowLevel.MotorType.kBrushless);
motor.getPIDController().setP(WristConstant.MOTOR_ID_P);
motor.getPIDController().setI(WristConstant.MOTOR_ID_I);
motor.getPIDController().setD(WristConstant.MOTOR_ID_D);
}

public static void init() {
if (instance == null) {
instance = new Wrist();
}
}

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

public boolean isAtAngle(Rotation2d targetAngle) {
return Math.abs(targetAngle.getDegrees() - motor.getEncoder().getPosition()) == 0;
}

public static Wrist getInstance() {
init();
return instance;
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
}
public void stop() {
motor.set(0);
}



@Override
protected String getLogPath() {
return "Wrist";
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
protected void subsystemPeriodic() {}

maya1414 marked this conversation as resolved.
Show resolved Hide resolved
}









8 changes: 8 additions & 0 deletions src/main/java/training/subsystems/wrist/WristConstant.java
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package training.subsystems.wrist;

public class WristConstant {
public static final int MOTOR_ID = 11;
public static final int MOTOR_ID_P = 1;
public static final int MOTOR_ID_I = 0;
public static final int MOTOR_ID_D = 0;
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
}
Loading