-
Notifications
You must be signed in to change notification settings - Fork 0
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
Omer elevator #7
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
{ | ||
"enableCppIntellisense": false, | ||
"currentLanguage": "java", | ||
"projectYear": "2020", | ||
"projectYear": "2021", | ||
"teamNumber": 5987 | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-6.0.1-all.zip | ||
distributionBase=GRADLE_USER_HOME | ||
distributionPath=permwrapper/dists | ||
zipStorePath=permwrapper/dists | ||
distributionUrl=https\://services.gradle.org/distributions/gradle-7.3.3-bin.zip | ||
zipStoreBase=GRADLE_USER_HOME | ||
zipStorePath=permwrapper/dists |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,6 +16,17 @@ | |
* constants are needed, to reduce verbosity. | ||
*/ | ||
public final class Constants { | ||
public static final class Elevator { | ||
|
||
public static final double kP = 0; | ||
public static final double kI = 0; | ||
public static final double kD = 0; | ||
public static final double kF = 0; | ||
public static final double RADIUS = 0.66; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Radius of what? |
||
public static final double GEAR_RATIO = 0.1; | ||
public static final double TICKS_PER_METER = 2048. / (2*Math.PI*RADIUS) * GEAR_RATIO; | ||
} | ||
|
||
public static final class Gripper { | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
package frc.robot; | ||
|
||
public class Ports { | ||
public static class Gripper { | ||
public static final int LEFTMOTOR = 0; | ||
public static class Elevator { | ||
public static final int motor = 0; | ||
Comment on lines
-4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you delete gripper constants?
Comment on lines
-4
to
+5
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why did you delete gripper constants? |
||
public static final int RIGHTMOTOR = 0; | ||
public static final int SOLENOID = 0; | ||
|
||
|
This file was deleted.
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,44 @@ | ||||||
package frc.robot.subsystems.elevator; | ||||||
|
||||||
import com.ctre.phoenix.motorcontrol.ControlMode; | ||||||
import com.ctre.phoenix.motorcontrol.TalonFXInvertType; | ||||||
import com.ctre.phoenix.motorcontrol.can.TalonFX; | ||||||
import com.ctre.phoenix.motorcontrol.can.WPI_TalonFX; | ||||||
import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||||||
import frc.robot.Constants; | ||||||
import frc.robot.Ports; | ||||||
import frc.robot.subsystems.UnitModel; | ||||||
|
||||||
import javax.sound.sampled.Port; | ||||||
|
||||||
public class Elevator extends SubsystemBase { | ||||||
private final WPI_TalonFX motor = new WPI_TalonFX(Ports.Elevator.motor); | ||||||
private final UnitModel unitModel = new UnitModel(Constants.Elevator.TICKS_PER_METER); | ||||||
private static Elevator INSTANCE = null; | ||||||
private Elevator(){ | ||||||
motor.setInverted(TalonFXInvertType.Clockwise); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't that be a constant? |
||||||
motor.config_kP(0, Constants.Elevator.kP); | ||||||
motor.config_kI(0, Constants.Elevator.kI); | ||||||
motor.config_kD(0, Constants.Elevator.kD); | ||||||
motor.config_kF(0, Constants.Elevator.kF); | ||||||
|
||||||
} | ||||||
public static Elevator getInstance(){ | ||||||
if (INSTANCE == null){ | ||||||
INSTANCE = new Elevator(); | ||||||
|
||||||
} | ||||||
return INSTANCE; | ||||||
} | ||||||
|
||||||
public double getheight(){ | ||||||
return unitModel.toUnits(motor.getSensorCollection().getIntegratedSensorPosition()); | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can simply use
Suggested change
|
||||||
} | ||||||
public void setHeight(double height){ | ||||||
motor.set(ControlMode.Position,unitModel.toTicks(height)); | ||||||
} | ||||||
|
||||||
public void stop(){ | ||||||
motor.set(0); | ||||||
} | ||||||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package frc.robot.subsystems.elevator.commands; | ||
|
||
import edu.wpi.first.wpilibj2.command.CommandBase; | ||
import frc.robot.subsystems.elevator.Elevator; | ||
|
||
public class Height extends CommandBase { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Command names need to start with a verb. |
||
Elevator elevator; | ||
double height; | ||
|
||
public Height(Elevator elevator, double height) { | ||
this.height = height; | ||
this.elevator = elevator; | ||
addRequirements(elevator); | ||
} | ||
|
||
@Override | ||
public void initialize() { | ||
elevator.setHeight(height); | ||
} | ||
|
||
@Override | ||
public void end(boolean interrupted) { | ||
elevator.stop(); | ||
} | ||
|
||
@Override | ||
public boolean isFinished() { | ||
return Math.abs( elevator.getheight() - height); | ||
} | ||
} | ||
Comment on lines
+26
to
+30
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A few unrelated notes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Radius of what?