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

Tomer-arm #9

Open
wants to merge 33 commits into
base: on-robot
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
f8c5528
Yoni - added joyysticks
itamaroryan Jul 17, 2024
ed95af0
tomer and guy - robot
itamaroryan Jul 17, 2024
23dd4a6
yotam and tomer - PID
itamaroryan Jul 21, 2024
12cd07f
guy and tomer robot code
tomer-hershman Jul 24, 2024
e0629d5
guy and tomer robot code
tomer-hershman Jul 24, 2024
6b1ef28
guy and tomer robot arm
tomer-hershman Jul 28, 2024
dc34dc6
tomer and guy sarted PID on arm
tomer-hershman Jul 31, 2024
d1a1c59
Tomer- finished PID Wrist and Roller
tomer-hershman Aug 4, 2024
012fdf1
tomer-finished
tomer-hershman Aug 4, 2024
0746e76
cr 1
tomer-hershman Aug 7, 2024
37b8586
cr 1
tomer-hershman Aug 7, 2024
7db3775
cr 1
tomer-hershman Aug 7, 2024
da02665
cr 1
tomer-hershman Aug 7, 2024
421e234
hilel and tomer spotless
tomer-hershman Aug 7, 2024
0b0b3ad
tomer - started moving stuf
tomer-hershman Aug 7, 2024
7c7b3ab
tomer-finised comends(or at least I think so)
tomer-hershman Aug 11, 2024
3e154de
tomer- worct on the hole arm manely elbow
tomer-hershman Aug 21, 2024
97414be
tomer- warked on the elbow
tomer-hershman Aug 21, 2024
a766980
tomer- warked on factory
tomer-hershman Aug 21, 2024
205a997
tomer- warked on factory
tomer-hershman Aug 21, 2024
4f8dfa9
tomer- warked on factory
tomer-hershman Aug 21, 2024
e96b5ef
tomer- warked on factory
tomer-hershman Aug 21, 2024
90b6b86
tomer- warked on factory
tomer-hershman Aug 21, 2024
09ff21b
tomer-finised shahar cr
tomer-hershman Aug 23, 2024
a512ee8
tomer-finished elbow simulation
tomer-hershman Aug 24, 2024
5f9a33b
tomer-finished elbow simulation
tomer-hershman Aug 24, 2024
0355a62
tomer-finished elbow simulation
tomer-hershman Aug 25, 2024
ce86a66
rtomer-request approval cr
tomer-hershman Aug 25, 2024
63a7ddf
rtomer-request approval cr
tomer-hershman Aug 25, 2024
d982715
rtomer-request approval cr
tomer-hershman Aug 25, 2024
ffdf1b2
rtomer-request approval cr
tomer-hershman Aug 25, 2024
3776f75
rtomer-request approval cr
tomer-hershman Aug 25, 2024
ead3740
rtomer-request approval cr
tomer-hershman Aug 25, 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
9 changes: 9 additions & 0 deletions src/main/java/training/commands/MoveElbowToAngle.java
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package training.commands;

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

public class MoveElbowToAngle {
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
public static void moveElbowToAngle(Rotation2d position){

}
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package training.subsystems.RobotArm;

public class ElbowConstants {

public static final double BIGINNING_POSITION = 0, KP = 20, KI = 0, KD = 0, KS = 0, KA = 0, KV = 0, KG = 0,
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
ARE_FEED_FORWARDS = 0;
public static final int MOTOR_ID = 0, PID_SLOT = 0;

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

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

public class ElbowSubsystem extends GBSubsystem {
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved

private CANSparkMax motor;
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
private Rotation2d position;
private static ElbowSubsystem instance;


private ElbowSubsystem() {
this.motor = new CANSparkMax(ElbowConstants.MOTOR_ID, CANSparkLowLevel.MotorType.kBrushless);
this.position = new Rotation2d(ElbowConstants.BIGINNING_POSITION);
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
motor.getPIDController().setP(ElbowConstants.KP);
motor.getPIDController().setI(ElbowConstants.KI);
motor.getPIDController().setD(ElbowConstants.KD);
}

public static ElbowSubsystem getInstance() {
if (instance != null)
instance = new ElbowSubsystem();
return instance;
}

public void goToPosition(Rotation2d position) {
motor.getPIDController()
.setReference(
position.getRadians(),
CANSparkBase.ControlType.kPosition,
ElbowConstants.PID_SLOT,
ElbowConstants.ARE_FEED_FORWARDS
);
}

public Rotation2d getPosition() {
return Rotation2d.fromDegrees(motor.getEncoder().getPosition());
}

tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved

protected String getLogPath() {
return "";
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
}

@Override
protected void subsystemPeriodic() {}

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

public class RolerConstens {
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved

public static final double KP = 20,
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
KI = 0,
KD = 0,
KS = 0,
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
KA = 0,
KV = 0,
KG = 0,
ARB_FEED_FOWORDS = 0;
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
public static final int MOTOR_ID = 0,
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
PID_SLOT = 0;

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

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

public class Roller extends GBSubsystem {

private CANSparkMax motor;
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
private static Roller instance;

private Roller() {
this.motor = new CANSparkMax(RolerConstens.MOTOR_ID, CANSparkLowLevel.MotorType.kBrushless);
motor.getPIDController().setP(RolerConstens.KP);
motor.getPIDController().setI(RolerConstens.KI);
motor.getPIDController().setD(RolerConstens.KD);
}

public static Roller getInstance() {
if (instance != null)
instance = new Roller();
return instance;
}

public void moveAtSpeed(double velocity) {
motor.getPIDController()
.setReference(
velocity,
CANSparkBase.ControlType.kVelocity,
RolerConstens.PID_SLOT,
RolerConstens.ARB_FEED_FOWORDS
);
}

tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
public Rotation2d getPower() {
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
return Rotation2d.fromDegrees(motor.getEncoder().getPosition());
}

protected String getLogPath() {
return "";
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
}


protected void subsystemPeriodic() {}

}


// public void setPosition(Rotation2d position){
// motor.getPIDController().setReference(position.getRotations(), CANSparkBase.ControlType.kPosition);
//
// }


// @Override
// public boolean isFinished() {
// return Math.abs(module.getAngularPosition().getDegrees() - position.getDegrees()) <= ModuleConstants.ANGULAR_TOLERANCE.getDegrees();
// }
//
// @Override
// public void end(boolean interrupted) {
// module.stopAngularMotor();
// Logger.recordOutput("Angular position of module",module.getAngularPosition());
// }
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved

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

import com.ctre.phoenix.motorcontrol.can.TalonSRXConfiguration;

public class WristConstans {

public static final double KP = 20, KI = 0, KD = 0, KS = 0, KA = 0, KV = 0, KG = 0, ARB_FEED_FOWORDS = 0,
MAG_ENCODER_CONVERSION_FACTOR = 8192;
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
public static final int MOTOR_ID = 0, PID_SLOT = 0, TIME_OUT_FOR_CONFIGS_SET = 0;
public static final TalonSRXConfiguration TALON_SRX_CONFIGURATION = new TalonSRXConfiguration();

static {
TALON_SRX_CONFIGURATION.slot0.kP = KP;
TALON_SRX_CONFIGURATION.slot0.kI = KI;
TALON_SRX_CONFIGURATION.slot0.kD = KD;
}

}
41 changes: 41 additions & 0 deletions src/main/java/training/subsystems/RobotArm/WristSubsystem.java
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package training.subsystems.RobotArm;

import com.ctre.phoenix.motorcontrol.ControlMode;
import com.ctre.phoenix.motorcontrol.FeedbackDevice;
import com.ctre.phoenix.motorcontrol.can.TalonSRX;
import edu.wpi.first.math.geometry.Rotation2d;
import utils.GBSubsystem;

public class WristSubsystem extends GBSubsystem {
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved

private TalonSRX motor;
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
private Rotation2d position;
private static WristSubsystem instance;

private WristSubsystem() {
this.motor = new TalonSRX(WristConstans.MOTOR_ID);
this.position = new Rotation2d();
motor.configAllSettings(WristConstans.TALON_SRX_CONFIGURATION);
motor.configSelectedFeedbackSensor(
FeedbackDevice.CTRE_MagEncoder_Relative,
WristConstans.PID_SLOT,
WristConstans.TIME_OUT_FOR_CONFIGS_SET
);
}


tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
public void goToPosition(Rotation2d position) {
motor.selectProfileSlot(WristConstans.PID_SLOT, 0);
motor.set(ControlMode.Position, (position.getRotations() * WristConstans.MAG_ENCODER_CONVERSION_FACTOR));
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
}


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

@Override
protected void subsystemPeriodic() {}

}
2 changes: 1 addition & 1 deletion src/main/java/utils/DefaultRobotManager.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package utils;

import edu.wpi.first.wpilibj2.command.CommandScheduler;
import utils.logger.LoggerFactory;
import org.littletonrobotics.junction.LoggedRobot;
import utils.logger.LoggerFactory;
tomer-hershman marked this conversation as resolved.
Show resolved Hide resolved
import utils.simulation.SimulationManager;

public abstract class DefaultRobotManager extends LoggedRobot {
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/utils/joysticks/Axis.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package utils.joysticks;

import edu.wpi.first.wpilibj.Joystick;

public enum Axis {

LEFT_X(0, true),
LEFT_Y(1, true),
LEFT_TRIGGER(2, false),
RIGHT_TRIGGER(3, false),
RIGHT_X(4, false),
RIGHT_Y(5, true);

private final int id;
private final int invertedSign;

Axis(int id, boolean isInverted) {
this.id = id;
this.invertedSign = isInverted ? -1 : 1;
}

AxisButton getAsButton(Joystick joystick, double threshold) {
return new AxisButton(joystick, id, threshold);
}

double getValue(Joystick joystick) {
return invertedSign * joystick.getRawAxis(id);
}

}
12 changes: 12 additions & 0 deletions src/main/java/utils/joysticks/AxisButton.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package utils.joysticks;

import edu.wpi.first.wpilibj.GenericHID;
import edu.wpi.first.wpilibj2.command.button.Trigger;

public class AxisButton extends Trigger {

public AxisButton(GenericHID joystick, int axis, double threshold) {
super(() -> Math.abs(joystick.getRawAxis(axis)) >= threshold);
}

}
34 changes: 34 additions & 0 deletions src/main/java/utils/joysticks/ButtonID.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package utils.joysticks;

enum ButtonID {

A(1),
B(2),
X(3),
Y(4),

L1(5),
R1(6),

BACK(7),
START(8),

L3(9),
R3(10),

POV_UP(0),
POV_RIGHT(90),
POV_DOWN(180),
POV_LEFT(270);

private final int id;

ButtonID(int id) {
this.id = id;
}

public int getId() {
return id;
}

}
22 changes: 22 additions & 0 deletions src/main/java/utils/joysticks/JoystickPorts.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package utils.joysticks;

public enum JoystickPorts {

MAIN(0),
SECOND(1),
THIRD(2),
FOURTH(3),
FIFTH(4),
SIXTH(5);

private final int port;

JoystickPorts(int port) {
this.port = port;
}

public int getPort() {
return port;
}

}
Loading
Loading