-
Notifications
You must be signed in to change notification settings - Fork 0
Emily bottom arm #25
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
Open
emilycxliu
wants to merge
26
commits into
main
Choose a base branch
from
emily-arm
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
Emily bottom arm #25
Changes from 18 commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
4dd7c98
added the bottom arm's motor controlller and absolute encoder
emilycxliu 409754e
added relative encoders, WIP
emilycxliu 102a401
checked if bottom encoder is synced
emilycxliu 4a10a7a
wip
emilycxliu c6bd8df
added a command to control bottom arm
emilycxliu 762cd08
cleaned up code
emilycxliu 028a830
added some comments
emilycxliu 88c2692
added comments for absolute encoder units
emilycxliu 06f4510
removed unused code
emilycxliu 2d8bec8
changed arm degree value
emilycxliu 25f1edb
set sparkmax encoders before checking encoder synchronization
emilycxliu da309c4
added more comments
emilycxliu 9fb2b06
added encoder synchronization logs to console
emilycxliu 361f61b
added more test codes for arm encoder synchronization
emilycxliu 9b27aea
added error checks
emilycxliu 4180a1d
added new command to check encoders are synced
emilycxliu 7302c10
Merge branch 'main' of https://github.com/FRC2706/2023-2706-Fall-Pose…
emilycxliu 3f2dd14
uncommented a line
emilycxliu 322e718
add another check for the arm encoder sync
emilycxliu 29d8030
12/11 code
emilycxliu f91bc71
fixed units, finished bottom arm code
emilycxliu b000f68
december 28 code
emilycxliu 52c607e
dec 28 top arm changes
emilycxliu 19e7f4a
top arm testing dec 28
emilycxliu 52f1b67
added top arm + profiled pid
emilycxliu b17c2f0
updated with profiledpid for the top arm
emilycxliu 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 hidden or 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 hidden or 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,25 @@ | ||
| package frc.robot; | ||
|
|
||
| import com.ctre.phoenix.ErrorCode; | ||
| import com.revrobotics.REVLibError; | ||
|
|
||
| import edu.wpi.first.wpilibj.DriverStation; | ||
|
|
||
| public class ErrorCheck { | ||
| public static int count = -1; | ||
| public static boolean errREV(REVLibError error) { | ||
| if (error == REVLibError.kOk) { | ||
| return true; | ||
| } | ||
| DriverStation.reportError("REV DEVICE Error" + error.toString(), true); | ||
| return false; | ||
| } | ||
| public static boolean errCTRE(ErrorCode error) { | ||
| if (error == ErrorCode.OK) { | ||
| return true; | ||
| } | ||
|
|
||
| DriverStation.reportError("CTRE Device Error: " + error.toString(), true); | ||
| return false; | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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
51 changes: 51 additions & 0 deletions
51
src/main/java/frc/robot/commands/CheckArmEncodersSync.java
This file contains hidden or 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,51 @@ | ||
| // Copyright (c) FIRST and other WPILib contributors. | ||
| // Open Source Software; you can modify and/or share it under the terms of | ||
| // the WPILib BSD license file in the root directory of this project. | ||
|
|
||
| package frc.robot.commands; | ||
|
|
||
| import edu.wpi.first.wpilibj.DriverStation; | ||
| import edu.wpi.first.wpilibj2.command.CommandBase; | ||
| import frc.robot.subsystems.ArmSubsystem; | ||
|
|
||
| public class CheckArmEncodersSync extends CommandBase { | ||
| /** Creates a new CheckArmEncodersSync. */ | ||
| public CheckArmEncodersSync() { | ||
| // Use addRequirements() here to declare subsystem dependencies. | ||
| addRequirements(ArmSubsystem.getInstance()); | ||
|
|
||
| } | ||
|
|
||
| // Called when the command is initially scheduled. | ||
| @Override | ||
| public void initialize() {} | ||
|
|
||
| // Called every time the scheduler runs while the command is scheduled. | ||
| @Override | ||
| public void execute() { | ||
| if (ArmSubsystem.getInstance().areEncodersSynced()==false) { | ||
| DriverStation.reportWarning ("CheckArmEncoders: Arm encoders are not synced", false); | ||
| System.out.println("*****CheckArmEncoders: Arm encoders are not synced*****"); | ||
| } | ||
| else { | ||
| DriverStation.reportWarning ("CheckArmEncoders: Arm encoders are synced", false); | ||
| System.out.println("*****CheckArmEncoders: Arm encoders are synced*****"); | ||
| } | ||
|
|
||
| } | ||
|
|
||
| // Called once the command ends or is interrupted. | ||
| @Override | ||
| public void end(boolean interrupted) {} | ||
|
|
||
| // Returns true when the command should end. | ||
| @Override | ||
| public boolean isFinished() { | ||
| return true; | ||
| } | ||
|
|
||
| @Override | ||
| public boolean runsWhenDisabled() { | ||
| return true; | ||
| } | ||
| } |
This file contains hidden or 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,62 @@ | ||
| // Copyright (c) FIRST and other WPILib contributors. | ||
| // Open Source Software; you can modify and/or share it under the terms of | ||
| // the WPILib BSD license file in the root directory of this project. | ||
|
|
||
| package frc.robot.commands; | ||
|
|
||
| import edu.wpi.first.wpilibj.Timer; | ||
| import edu.wpi.first.wpilibj2.command.CommandBase; | ||
| import frc.robot.subsystems.ArmPneumaticsSubsystem; | ||
| import frc.robot.subsystems.ArmSubsystem; | ||
|
|
||
| public class SetBottomArm extends CommandBase { | ||
| double bottomArmAngleRadians; | ||
| final double TIMEOUT_S=2; | ||
|
|
||
| Timer m_timer = new Timer(); | ||
| /** Creates a new SetBottomArm. */ | ||
| public SetBottomArm(double angleDegree) { | ||
| bottomArmAngleRadians = Math.toRadians(angleDegree); | ||
| // Use addRequirements() here to declare subsystem dependencies. | ||
| addRequirements(ArmSubsystem.getInstance()); | ||
| addRequirements(ArmPneumaticsSubsystem.getInstance()); | ||
| } | ||
|
|
||
| // Called when the command is initially scheduled. | ||
| @Override | ||
| public void initialize() { | ||
| //ArmSubsystem.getInstance().controlBottomArmBrake(false); | ||
| ArmPneumaticsSubsystem.getInstance().controlBottomBrake(false, false); | ||
| m_timer.stop(); | ||
| m_timer.reset(); | ||
| //todo: | ||
| m_timer.start(); | ||
| } | ||
|
|
||
| // Called every time the scheduler runs while the command is scheduled. | ||
| @Override | ||
| public void execute() { | ||
| ArmSubsystem.getInstance().setBottomJointAngle(bottomArmAngleRadians); | ||
| } | ||
|
|
||
| // Called once the command ends or is interrupted. | ||
| @Override | ||
| public void end(boolean interrupted) { | ||
| ArmSubsystem.getInstance().stopMotors(); | ||
| if (interrupted == false) | ||
| { | ||
| //ArmSubsystem.getInstance().controlBottomArmBrake(true); | ||
| ArmPneumaticsSubsystem.getInstance().controlBottomBrake(true, true); | ||
|
|
||
| } | ||
| m_timer.stop(); | ||
| } | ||
|
|
||
| // Returns true when the command should end. | ||
| @Override | ||
| public boolean isFinished() { | ||
| //todo: check if bottom arm reaches the position | ||
| //time out, finished | ||
| return m_timer.hasElapsed(TIMEOUT_S); | ||
| } | ||
| } |
This file contains hidden or 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,65 @@ | ||
| // Copyright (c) FIRST and other WPILib contributors. | ||
| // Open Source Software; you can modify and/or share it under the terms of | ||
| // the WPILib BSD license file in the root directory of this project. | ||
|
|
||
| package frc.robot.commands; | ||
|
|
||
| import edu.wpi.first.wpilibj.DriverStation; | ||
| import edu.wpi.first.wpilibj.DriverStation; | ||
| import edu.wpi.first.wpilibj2.command.CommandBase; | ||
| import frc.robot.subsystems.ArmSubsystem; | ||
|
|
||
| public class SyncArmEncoders extends CommandBase { | ||
| int counter; | ||
| boolean bSynced; | ||
| /** Creates a new SyncArmEncoders. */ | ||
| public SyncArmEncoders() { | ||
| counter = 0; | ||
| bSynced = false; | ||
| addRequirements(ArmSubsystem.getInstance()); | ||
| // Use addRequirements() here to declare subsystem dependencies. | ||
| } | ||
|
|
||
| // Called when the command is initially scheduled. | ||
| @Override | ||
| public void initialize() {} | ||
|
|
||
| // Called every time the scheduler runs while the command is scheduled. | ||
| @Override | ||
| public void execute() { | ||
| counter ++; | ||
| if (ArmSubsystem.getInstance().areEncodersSynced()==false) { | ||
| DriverStation.reportWarning ("Arm encoders are not synced", false); | ||
| System.out.println("*****Arm encoders are not synced*****"); | ||
| } | ||
| else { | ||
| DriverStation.reportWarning ("Arm encoders are synced", false); | ||
| System.out.println("*****Arm encoders are synced*****"); | ||
| bSynced = true; | ||
| ArmSubsystem.getInstance().burnFlash(); | ||
| } | ||
|
|
||
|
|
||
| } | ||
|
|
||
| // Called once the command ends or is interrupted. | ||
| @Override | ||
| public void end(boolean interrupted) {} | ||
|
|
||
| @Override | ||
| public boolean runsWhenDisabled() { | ||
| return true; | ||
| } | ||
|
|
||
| // Returns true when the command should end. | ||
| @Override | ||
| public boolean isFinished() { | ||
| if (counter >= 10 || bSynced == true) { | ||
| return true; | ||
| } | ||
| else { | ||
|
|
||
| return false; | ||
| } | ||
| } | ||
| } |
This file contains hidden or 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 hidden or 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,54 @@ | ||
| package frc.robot.subsystems; | ||
|
|
||
| import frc.robot.Config; | ||
|
|
||
| public class ArmConfig { | ||
| public static final boolean TOP_SET_INVERTED = true; | ||
| public static final boolean BOTTOM_SET_INVERTED = true; | ||
|
|
||
| public static final int CURRENT_LIMIT = 60; | ||
|
|
||
| //soft limit constants for top arm | ||
| public static final float top_arm_forward_limit = (float)Math.toRadians(190); //converts degree to radian | ||
| public static final float top_arm_reverse_limit = (float)Math.toRadians(7); | ||
| public static final boolean TOP_SOFT_LIMIT_ENABLE = true; | ||
|
|
||
| //soft limit constant for bottom arm | ||
| public static final float bottom_arm_forward_limit = (float)Math.toRadians(135); | ||
| public static final float bottom_arm_reverse_limit = (float)Math.toRadians(40); | ||
| public static final boolean BOTTOM_SOFT_LIMIT_ENABLE = true; | ||
|
|
||
| //PID constants | ||
| public static final double bottom_arm_kP = 1.4; | ||
| public static final double bottom_arm_kI = 0.0003; | ||
| public static final double bottom_arm_kD = 0.9; | ||
| public static final double bottom_arm_kIz = 0.3; | ||
| public static final double bottom_arm_kFF = 0; | ||
| public static final double min_output = -1; | ||
| public static final double max_output = 1; | ||
|
|
||
|
|
||
|
|
||
|
|
||
| //duty cycle encoders | ||
| public static final int bottom_duty_cycle_channel = 7; | ||
|
|
||
| //arm offsets | ||
| public static final double bottom_arm_offset = 307.800000; | ||
|
|
||
| //syncing encoders | ||
| public static double ENCODER_SYNCING_TOLERANCE = 0.01; //radians | ||
|
|
||
| public static final double BOTTOM_NEO_GEAR_RATIO = Config.robotSpecific(62.5,0.0,0.0,0.0); | ||
|
|
||
| public static final double bottomArmPositionConversionFactor = 2 * Math.PI / BOTTOM_NEO_GEAR_RATIO; | ||
| public static final double bottomArmVelocityConversionFactor = bottomArmPositionConversionFactor / 60.0; | ||
|
|
||
| public static final double BOTTOM_MAX_VEL = Math.PI * 3; | ||
| public static final double BOTTOM_MAX_ACCEL = Math.PI *3; | ||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
| } |
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.
Both commands require the ArmSubsystem and one of them is cancelling the other.
This will detach the requirement from the WaitCommand(10):
new WaitCommand(10).andThen(new ScheduleCommand(new CheckArmEncodersSync())).schedule();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.
added that line, it works