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 all 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
1 change: 1 addition & 0 deletions networktables.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[]
97 changes: 97 additions & 0 deletions simgui-ds.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
{
"keyboardJoysticks": [
{
"axisConfig": [
{
"decKey": 65,
"incKey": 68
},
{
"decKey": 87,
"incKey": 83
},
{
"decKey": 69,
"decayRate": 0.0,
"incKey": 82,
"keyRate": 0.009999999776482582
}
],
"axisCount": 3,
"buttonCount": 4,
"buttonKeys": [
90,
88,
67,
86
],
"povConfig": [
{
"key0": 328,
"key135": 323,
"key180": 322,
"key225": 321,
"key270": 324,
"key315": 327,
"key45": 329,
"key90": 326
}
],
"povCount": 1
},
{
"axisConfig": [
{
"decKey": 74,
"incKey": 76
},
{
"decKey": 73,
"incKey": 75
}
],
"axisCount": 2,
"buttonCount": 4,
"buttonKeys": [
77,
44,
46,
47
],
"povCount": 0
},
{
"axisConfig": [
{
"decKey": 263,
"incKey": 262
},
{
"decKey": 265,
"incKey": 264
}
],
"axisCount": 2,
"buttonCount": 6,
"buttonKeys": [
260,
268,
266,
261,
269,
267
],
"povCount": 0
},
{
"axisCount": 0,
"buttonCount": 0,
"povCount": 0
}
],
"robotJoysticks": [
{
"guid": "Keyboard0"
}
]
}
10 changes: 10 additions & 0 deletions simgui.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"NTProvider": {
"types": {
"/FMSInfo": "FMSInfo"
}
},
"NetworkTables Info": {
"visible": true
}
}
3 changes: 3 additions & 0 deletions src/main/java/training/Robot.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
package training;

import training.subsystems.elbow.Elbow;

public class Robot {

// Enter your subsystems...

public Robot() {
// Boot your subsystems...
Elbow.init();
}

// Add your subsystems getters...
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/training/TrainingRobotManager.java
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
package training;

import edu.wpi.first.math.geometry.Rotation2d;
import training.commands.elbow.MoveElbowToAngle;
import training.subsystems.elbow.RobotTypes;
import utils.DefaultRobotManager;
import utils.joysticks.JoystickPorts;
import utils.joysticks.SmartJoystick;

public class TrainingRobotManager extends DefaultRobotManager {

private Robot robot;

public static final RobotTypes ROBOT_TYPE = RobotTypes.SIMULATION;

@Override
public void trainingInit() {
this.robot = new Robot();
configureBindings();
}

public void configureBindings() {
SmartJoystick smartJoystick = new SmartJoystick(JoystickPorts.MAIN);
smartJoystick.A.whileTrue(new MoveElbowToAngle(Rotation2d.fromDegrees(45)));
smartJoystick.B.whileTrue(new MoveElbowToAngle(Rotation2d.fromDegrees(90)));
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/training/commands/elbow/MoveElbowToAngle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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;
private Elbow elbow;

public MoveElbowToAngle(Rotation2d targetAngle) {
this.targetAngle = targetAngle;
this.elbow = Elbow.getInstance();
addRequirements(this.elbow);
}

@Override
public void execute() {
elbow.goToAngle(targetAngle);
}

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

public void end(boolean interrupted) {
elbow.stayAtPosition();
}

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

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

public class MoveRollerToSpeed extends Command {

private double targetSpeed;
private Roller roller;

public MoveRollerToSpeed(double targetSpeed) {
this.targetSpeed = targetSpeed;
this.roller = Roller.getInstance();
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
addRequirements(roller);
}

@Override
public void execute() {
roller.goToSpeed(targetSpeed);
}

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

}
31 changes: 31 additions & 0 deletions src/main/java/training/commands/wrist/MoveWristToAngle.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
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 MoveWristToAngle extends Command {

private Rotation2d targetAngle;
private Wrist wrist;

public MoveWristToAngle(Rotation2d targetAngle) {
this.targetAngle = targetAngle;
this.wrist = Wrist.getInstance();
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
addRequirements(wrist);
}

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

public boolean isFinished() {
return wrist.isAtAngle(targetAngle);
maya1414 marked this conversation as resolved.
Show resolved Hide resolved
}

public void end(boolean interrupted) {
wrist.stayAtPosition();
}

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

import edu.wpi.first.math.geometry.Rotation2d;
import org.littletonrobotics.junction.Logger;
import utils.GBSubsystem;

public class Elbow extends GBSubsystem {

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

private final IElbow elbow;

private ElbowInputsAutoLogged inputs;

maya1414 marked this conversation as resolved.
Show resolved Hide resolved
private Elbow() {
this.elbow = ElbowFactory.create();
this.inputs = new ElbowInputsAutoLogged();
}

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

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

public Rotation2d getPosition() {
return inputs.position;
}

public Rotation2d getVelocity() {
return inputs.velocity;
}

public void goToAngle(Rotation2d targetAngle) {
elbow.goToAngle(targetAngle);
}

public boolean isAtAngle(Rotation2d targetAngle) {
return Math.abs(targetAngle.getRotations() - inputs.position.getRotations()) <= ElbowConstants.TOLERANCE.getRotations();
}

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

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

@Override
protected void subsystemPeriodic() {
elbow.updateInputs(inputs);
Logger.processInputs("Elbow/", inputs);
}

}
48 changes: 48 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,48 @@
package training.subsystems.elbow;


import edu.wpi.first.math.controller.ArmFeedforward;
import edu.wpi.first.math.geometry.Rotation2d;

public class ElbowConstants {

public enum PresetPositions {

SAFE(Rotation2d.fromDegrees(0)),
INTAKE(Rotation2d.fromDegrees(0)),
SCORE(Rotation2d.fromDegrees(0)),
STARTING(Rotation2d.fromDegrees(0)),
TRANSFER(Rotation2d.fromDegrees(0));

public final Rotation2d ANGLE;

PresetPositions(Rotation2d angle) {
this.ANGLE = angle;
}

}

public static final int MOTOR_ID = 5;
public static final int P = 10;

public static final int I = 0;

public static final int D = 1;

public static final int PID_SLOT = 0;

public static final ArmFeedforward ARM_FEEDFORWARD = new ArmFeedforward(0, 0, 0, 0);

public static final double GEAR_RATIO = 1 / (28.0 * (60.0 / 16.0));

public static final double ARM_LENGTH = 0.44;

public static final double ARM_MASS_KG = 0.44;

public static final Rotation2d BACKWARD_ANGLE_LIMIT = Rotation2d.fromDegrees(-81);

public static final Rotation2d FORWARD_ANGLE_LIMIT = Rotation2d.fromDegrees(90);

public static final Rotation2d TOLERANCE = Rotation2d.fromDegrees(3);

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

import training.TrainingRobotManager;

public class ElbowFactory {

public static IElbow create() {
return switch (TrainingRobotManager.ROBOT_TYPE) {
case SIMULATION -> new ElbowSimulation();
case SYNCOPA -> new NeoElbow();
};
}

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

import edu.wpi.first.math.geometry.Rotation2d;
import org.littletonrobotics.junction.AutoLog;

@AutoLog
public class ElbowInputs {

public Rotation2d position;
public Rotation2d velocity;

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