-
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
Elevator #11
Open
janetmeng
wants to merge
34
commits into
main
Choose a base branch
from
elevator
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Elevator #11
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
9307a2d
copied over arm file and can id
25laurenj 064579d
telescopingarm sensor, gain, deadband and buttons
25laurenj d97532f
created telescoping arm state machine, init and periodic methods, imp…
janetmeng 14d9e87
added arm rotation and edited telescoping
25laurenj c3ece14
skeleton for elevator subsystem
janetmeng 374ea19
added gains, sensorPhase constant, and deadband constant
janetmeng 5acbcb9
configured gains
25laurenj 323156c
deleted gains in constants
25laurenj ac08c80
deleted kf cleaned up constants file
janetmeng 889c912
elevator
laurenmarymcdonald 813c856
made four bar linkage subsystem
janetmeng d00e55c
deleted rotate and 4 bar linkage code, polished gains
janetmeng ead7477
transferred buttons from buttonOfficial branch
86e1105
changed ticks per inch constant
janetmeng f25007c
changed ticks per inch constant
janetmeng df026e3
changed wheel_diameter and gearratio
janetmeng 7d0313e
tested elevator but zipties broke
gatorbotics 930bf33
added 1/3 speed control for high elevator state in driveTeleop()
d03ae04
changed controlmode.position vals
gatorbotics e36eca4
added limit switch
25laurenj 853061c
added bottom limit switch and stop command
25laurenj 37c2c3c
changed some constants and added comments
gatorbotics 6251060
deleted unnecessary import
25laurenj 67559b5
Merge branch 'main' into elevator
25krobertson d040edf
added scorelow score mid score high methods b/c deleted from buttonof…
janetmeng 667d9b5
added scorelow scoremid scorehigh methods b/c deleted from buttonoffi…
janetmeng c9ecdf3
merged
janetmeng 8adc6c1
added shelf arm length
janetmeng 7f4021a
not my changes not my monkeys
gatorbotics f9e1b4d
cleaned up code, mostly deleting unused imports, and comments about u…
25krobertson 6e02691
changed elevator can id to 25
gatorbotics 95a8462
Merge branch 'elevator' of https://github.com/gatorbotics1700/swerve_…
gatorbotics bbb14d5
tested elevator
gatorbotics 7415567
set sensor position to 0 in test init()
gatorbotics File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Class that organizes gains used when assigning values to slots | ||
*/ | ||
package frc.robot; | ||
|
||
public class Gains { //Gain is a proportional value that shows the relationship between the magnitude of an input signal to the magnitude of an output signal at steady-state. | ||
public final double kP; | ||
public final double kI; | ||
public final double kD; | ||
public final int kIzone; //can be used to auto clear the integral accumulator if the sensor pos is too far from the target. This prevent unstable oscillation if the kI is too large. Value is in sensor units. | ||
public final double kPeakOutput; //Absolute max motor output during closed-loop control modes only. A value of ‘1’ represents full output in both directions. | ||
|
||
|
||
public Gains(double _kP, double _kI, double _kD, int _kIzone, double _kPeakOutput){ | ||
kP = _kP; | ||
kI = _kI; | ||
kD = _kD; | ||
|
||
kIzone = _kIzone; | ||
kPeakOutput = _kPeakOutput; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,59 +6,39 @@ | |
|
||
import edu.wpi.first.wpilibj.TimedRobot; | ||
import frc.robot.subsystems.*; | ||
import frc.robot.OI; | ||
import edu.wpi.first.wpilibj.smartdashboard.Field2d; | ||
import edu.wpi.first.wpilibj.smartdashboard.SendableChooser; | ||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
import frc.robot.autonomous.*; | ||
import frc.robot.Constants; | ||
import frc.robot.subsystems.ElevatorSubsystem.ElevatorStates; | ||
|
||
import com.fasterxml.jackson.core.sym.Name; | ||
|
||
import edu.wpi.first.math.controller.PIDController; | ||
import edu.wpi.first.math.geometry.Pose2d; | ||
import edu.wpi.first.math.kinematics.ChassisSpeeds; | ||
import edu.wpi.first.math.trajectory.Trajectory; | ||
import edu.wpi.first.networktables.GenericEntry; | ||
import edu.wpi.first.networktables.NetworkTableEntry; | ||
import edu.wpi.first.networktables.NetworkTable.*; | ||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import edu.wpi.first.math.geometry.Translation2d; | ||
import edu.wpi.first.math.geometry.Pose2d; | ||
import edu.wpi.first.math.kinematics.ChassisSpeeds; | ||
import edu.wpi.first.wpilibj.shuffleboard.ShuffleboardTab; | ||
|
||
/** | ||
* The VM is configured to automatically run this class, and to call the functions corresponding to | ||
* each mode, as described in the TimedRobot documentation. If you change the name of this class or | ||
* the package after creating this project, you must also update the build.gradle file in the | ||
* project. | ||
*/ | ||
|
||
/*public class Robot extends TimedRobot { | ||
private static final String kDefaultAuto = "Default"; | ||
private static final String kCustomAuto = "My Auto"; | ||
private String m_autoSelected; | ||
private final SendableChooser<String> m_chooser = new SendableChooser<>(); | ||
//private final AutonomousBase autonomousBasePD = new AutonomousBasePD(new Pose2d(0*Constants.TICKS_PER_INCH, -20*Constants.TICKS_PER_INCH, new Rotation2d(0)), 0.0, new Pose2d(), 0.0); | ||
public static final DrivetrainSubsystem m_drivetrainSubsystem = new DrivetrainSubsystem(); | ||
|
||
*/ | ||
Comment on lines
+25
to
+33
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 is this commented out? Can we delete it? |
||
|
||
//private AutonomousBasePD mScore = new AutonomousBasePD(new Translation2d(222.037, 0), new Translation2d(135.091, -41.307), new Translation2d(0, -44.163), new Translation2d(222.894, -50.377), new Translation2d(0, -65.388), new Translation2d(0, -65.388)); | ||
|
||
public class Robot extends TimedRobot { | ||
private AutonomousBase m_autoSelected; | ||
private final SendableChooser<AutonomousBase> m_chooser = new SendableChooser<AutonomousBase>(); | ||
private AutonomousBasePD noGo = new AutonomousBasePD(new Pose2d(0, 0, new Rotation2d(0)), new Pose2d(0, 0, new Rotation2d(0)), new Pose2d(0, 0, new Rotation2d(0)), new Pose2d(0,0, new Rotation2d(0)), new Pose2d(0, 0, new Rotation2d(0)), new Pose2d(0,0, new Rotation2d(0)), new Pose2d(0,0, new Rotation2d(0))); | ||
private AutonomousBasePD placeNLeave = new AutonomousBasePD(new Pose2d(0, 0, new Rotation2d(0)), new Pose2d(160.0, 0, new Rotation2d(0)), new Pose2d(160.0, 0, new Rotation2d(0)), new Pose2d(160.0, 0, new Rotation2d(0)), new Pose2d(160.0, 0, new Rotation2d(0)), new Pose2d(160.0, 0, new Rotation2d(0)), new Pose2d(160.0, 0, new Rotation2d(0))); | ||
private AutonomousBasePD antiCharge = new AutonomousBasePD(new Pose2d(86.840, -45.282, new Rotation2d(0)), new Pose2d(221.978, 19.463, new Rotation2d(0)), new Pose2d(135.091, -19.421, new Rotation2d(0)), new Pose2d(0, -22.277, new Rotation2d(0)), new Pose2d(222.491, -28.492, new Rotation2d(0)), new Pose2d(0, -43.502, new Rotation2d(0)), new Pose2d(0, -43.502, new Rotation2d(0))); | ||
private AutonomousBasePD antiChargeOpposite = new AutonomousBasePD(new Pose2d(86.840, 45.282, new Rotation2d(0)), new Pose2d(221.978, -19.463, new Rotation2d(0)), new Pose2d(135.091, 19.421, new Rotation2d(0)), new Pose2d(0, 22.277, new Rotation2d(0)), new Pose2d(222.491, 28.492, new Rotation2d(0)), new Pose2d(0, 43.502, new Rotation2d(0)), new Pose2d(0, 43.502, new Rotation2d(0))); | ||
private AutonomousBasePD engageCharge = new AutonomousBasePD(new Pose2d(97.759, 0, new Rotation2d(0)), new Pose2d(97.759, 0, new Rotation2d(0)), new Pose2d(97.759, 0, new Rotation2d(0)), new Pose2d(97.759, 0, new Rotation2d(0)), new Pose2d(97.759, 0, new Rotation2d(0)), new Pose2d(97.759, 0, new Rotation2d(0)), new Pose2d(97.759, 0, new Rotation2d(0))); | ||
private AutonomousBasePD placeTwoEngage = new AutonomousBasePD(new Pose2d(223.014, 16.468, new Rotation2d(0)), new Pose2d(0, 22.683, new Rotation2d(0)), new Pose2d(135.615, 25.539, new Rotation2d(0)), new Pose2d(222.191, 64.230, new Rotation2d(0)), new Pose2d(97.711, 64.230, new Rotation2d(0)), new Pose2d(97.711, 64.230, new Rotation2d(0)), new Pose2d(97.711, 64.230, new Rotation2d(0))); | ||
private AutonomousBaseTimed timedPath = new AutonomousBaseTimed(); | ||
private AutonomousBasePD testPath = new AutonomousBasePD(new Pose2d(0, 20, new Rotation2d(0)), new Pose2d(0, 20, new Rotation2d(0)), new Pose2d(0, 20, new Rotation2d(0)), new Pose2d(0, 20, new Rotation2d(0)), new Pose2d(0, 20, new Rotation2d(0)), new Pose2d(0, 20, new Rotation2d(0)), new Pose2d(0, 20, new Rotation2d(0))); | ||
private AutonomousBaseMP motionProfiling = new AutonomousBaseMP(Trajectories.uno, Trajectories.dos, Trajectories.tres); | ||
|
||
//above coordinates didn't work | ||
private AutonomousBasePD leave = new AutonomousBasePD(new Pose2d(56.069, 17.332, new Rotation2d(0)), new Pose2d(219.915, 17.332, new Rotation2d(0)), new Pose2d(219.915, 17.332, new Rotation2d(0)), new Pose2d(219.915, 17.332, new Rotation2d(0)), new Pose2d(219.915, 17.332, new Rotation2d(0)), new Pose2d(219.915, 17.332, new Rotation2d(0)), new Pose2d(219.915, 17.332, new Rotation2d(0))); | ||
private AutonomousBasePD placeTwoEngageReal = new AutonomousBasePD(new Pose2d(56.069, 17.332, new Rotation2d(0)), new Pose2d(278.999, 37.193, new Rotation2d(0)), new Pose2d(257.650, 64.004, new Rotation2d(0)), new Pose2d(156.859, 83.368, new Rotation2d(0)), new Pose2d(156.859, 83.368, new Rotation2d(0)), new Pose2d(156.859, 83.368, new Rotation2d(0)), new Pose2d(156.859, 83.368, new Rotation2d(0))); | ||
|
||
//these paths score 3 balls without touching the charge station, requires 7 Pose2ds! | ||
private AutonomousBasePD threeUnderChargeStation = new AutonomousBasePD(new Pose2d(56.069, 17.332, new Rotation2d(0)), new Pose2d(278.999, 37.193, new Rotation2d(0)), new Pose2d(56.222, 43.068, new Rotation2d(0)), new Pose2d(197.484,45.934, new Rotation2d(0)), new Pose2d(279.077, 85.622, new Rotation2d(0)), new Pose2d(197.484,40.000, new Rotation2d(0)), new Pose2d(56.154,66.117, new Rotation2d(0))); | ||
private AutonomousBasePD threeAboveChargeStation = new AutonomousBasePD(new Pose2d(56.069, 200.046, new Rotation2d(0)), new Pose2d(278.999, 180.683, new Rotation2d(0)), new Pose2d(56.069, 174.725, new Rotation2d(0)), new Pose2d(207.006, 174.725, new Rotation2d(0)), new Pose2d(278.006, 133.515, new Rotation2d(0)), new Pose2d(200.552, 185.151, new Rotation2d(0)), new Pose2d(57.062, 154.368, new Rotation2d(0))); | ||
|
||
|
||
|
||
public ElevatorSubsystem elevatorSubsystem = new ElevatorSubsystem(); | ||
|
||
public static final DrivetrainSubsystem m_drivetrainSubsystem = new DrivetrainSubsystem(); //if anything breaks in the future it might be this | ||
private final Field2d m_field = new Field2d(); | ||
ChassisSpeeds m_ChassisSpeeds; | ||
|
@@ -67,32 +47,34 @@ public class Robot extends TimedRobot { | |
public static GenericEntry kI; | ||
public static GenericEntry kD; | ||
|
||
public static DrivetrainSubsystem getDrivetrainSubsystem(){ | ||
return m_drivetrainSubsystem; | ||
} | ||
|
||
/** | ||
* This function is run when the robot is first started up and should be used for any | ||
* initialization code. | ||
*/ | ||
@Override | ||
public void robotInit() { //creates options for different autopaths, names are placeholders | ||
|
||
System.out.println("#I'm Awake"); | ||
m_chooser.setDefaultOption("Default Auto", testPath); | ||
m_chooser.addOption("My Auto 1", noGo); | ||
m_chooser.addOption("My Auto 2",placeNLeave); | ||
m_chooser.addOption("My Auto 3", antiCharge); | ||
m_chooser.addOption("My Auto 4", antiChargeOpposite); | ||
// System.out.println("#I'm Awake"); | ||
// m_chooser.setDefaultOption("Default Auto", testPath); | ||
// m_chooser.addOption("My Auto 1", noGo); | ||
// m_chooser.addOption("My Auto 2",placeNLeave); | ||
// m_chooser.addOption("My Auto 3", antiCharge); | ||
// m_chooser.addOption("My Auto 4", antiChargeOpposite); | ||
//m_chooser.addOption(name: "My Auto 5", engageCharge); | ||
// m_chooser.addOption(name: "My Auto 6",placeTwoEngage); | ||
m_chooser.addOption("My Auto timed", timedPath); | ||
m_chooser.addOption("Motion profiling path", motionProfiling); | ||
//m_chooser.addOption(name: "My Auto 6",placeTwoEngage); | ||
//m_chooser.addOption("My Auto timed", timedPath); | ||
//m_chooser.addOption("Motion profiling path", motionProfiling); | ||
|
||
SmartDashboard.putData("Auto choices", m_chooser); | ||
|
||
ShuffleboardTab tab = DrivetrainSubsystem.tab; | ||
kP = tab.add("Auto kP", 0.1).getEntry(); | ||
kI = tab.add("Auto kI", 0.0).getEntry(); | ||
kD = tab.add("Auto kD", 0.0).getEntry(); | ||
|
||
|
||
// ShuffleboardTab tab = DrivetrainSubsystem.tab; | ||
// kP = tab.add("Auto kP", 0.1).getEntry(); | ||
// kI = tab.add("Auto kI", 0.0).getEntry(); | ||
// kD = tab.add("Auto kD", 0.0).getEntry(); | ||
} | ||
|
||
/** | ||
|
@@ -121,18 +103,25 @@ public void robotPeriodic() { | |
*/ | ||
@Override | ||
public void autonomousInit() { | ||
m_autoSelected = m_chooser.getSelected(); | ||
m_autoSelected.init(); | ||
|
||
//autonomousBasePD.init(); | ||
|
||
elevatorSubsystem.init(); | ||
// m_autoSelected = m_chooser.getSelected(); | ||
// m_autoSelected = SmartDashboard.getString("Auto Selector", kDefaultAuto); | ||
// System.out.println("Auto selected: " + m_autoSelected); | ||
|
||
} | ||
|
||
/** This function is called periodically during autonomous. */ | ||
@Override | ||
public void autonomousPeriodic() { | ||
|
||
m_autoSelected.periodic(); | ||
m_drivetrainSubsystem.drive(); | ||
//System.out.println("Odometry: "+ DrivetrainSubsystem.m_odometry.getPoseMeters()); | ||
|
||
|
||
//autonomousBasePD.periodic(); | ||
elevatorSubsystem.setState(ElevatorStates.SHELF_ELEVATOR_HEIGHT); | ||
elevatorSubsystem.periodic(); | ||
//m_drivetrainSubsystem.drive(); | ||
} | ||
|
||
/** This function is called once when teleop is enabled. */ | ||
|
@@ -168,17 +157,23 @@ public void disabledPeriodic() {} | |
/** This function is called once when test mode is enabled. */ | ||
@Override | ||
public void testInit() { | ||
System.out.println("Trajectory: " + Trajectories.uno); | ||
ElevatorSubsystem.elevatorMotor.setSelectedSensorPosition(0, Constants.kPIDLoopIdx, Constants.kTimeoutMs); | ||
//m_drivetrainSubsystem.m_pose = new Pose2d(20, 30, new Rotation2d(Math.PI/4)); | ||
//System.out.println("m_pose: " + m_drivetrainSubsystem.m_pose); | ||
//autonomousBasePD.init(); | ||
} | ||
|
||
/** This function is called periodically during test mode. */ | ||
@Override | ||
public void testPeriodic() { | ||
|
||
//elevatorSubsystem.setState(ElevatorStates.ZERO); | ||
//elevatorSubsystem.periodic(); | ||
|
||
/*intial test!*/ | ||
m_drivetrainSubsystem.setSpeed(new ChassisSpeeds(-0.2, -0.2, 0)); | ||
// m_drivetrainSubsystem.setSpeed(new ChassisSpeeds(-0.2, -0.2, 0)); | ||
|
||
m_drivetrainSubsystem.drive(); | ||
// m_drivetrainSubsystem.drive(); | ||
} | ||
|
||
/** This function is called once when the robot is first started up. */ | ||
|
@@ -188,4 +183,4 @@ public void simulationInit() {} | |
/** This function is called periodically whilst in simulation. */ | ||
@Override | ||
public void simulationPeriodic() {} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
You might want to specify in the variable name that this is ticks per inch for the elevator. Otherwise we might accidentally use this for one of the other subsystems.