-
Notifications
You must be signed in to change notification settings - Fork 1
driving works #5
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
ArmedBot22
wants to merge
11
commits into
main
Choose a base branch
from
team1111
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
32da32e
driving works
ArmedBot22 44b7bbe
Merge branch 'main' of https://github.com/DevilBotz2876/RomiTutorial2…
BrownGenius d6ed271
Add gripper support (right stick, left/right)
BrownGenius e018d49
WIP arm/gripper
ArmedBot22 f60c0fd
Fixed_teleop-need_auto
ArmedBot22 111a3fa
fixedTeleop
ArmedBot22 bec7df0
FinishedRomi
ArmedBot22 119c1a0
FinalRomiProgram
ArmedBot22 44e6532
autoAndProgramFinished
ArmedBot22 90f14b1
TrulyAbsolutlyTotallyFinishedRomiCode
ArmedBot22 fa47dfb
postGameLagCorrections
ArmedBot22 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 @@ | ||
| [] |
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,98 @@ | ||
| { | ||
| "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": "78696e70757401000000000000000000", | ||
| "useGamepad": 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,31 @@ | ||
| { | ||
| "HALProvider": { | ||
| "Other Devices": { | ||
| "RomiGyro": { | ||
| "header": { | ||
| "open": true | ||
| } | ||
| } | ||
| } | ||
| }, | ||
| "NTProvider": { | ||
| "types": { | ||
| "/FMSInfo": "FMSInfo", | ||
| "/SmartDashboard/Field": "Field2d", | ||
| "/SmartDashboard/SendableChooser[0]": "String Chooser" | ||
| } | ||
| }, | ||
| "NetworkTables": { | ||
| "transitory": { | ||
| "Shuffleboard": { | ||
| "open": true | ||
| }, | ||
| "SmartDashboard": { | ||
| "SendableChooser[0]": { | ||
| "open": true | ||
| }, | ||
| "open": 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
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 | ||||||
|---|---|---|---|---|---|---|---|---|
| @@ -1,9 +1,11 @@ | ||||||||
| package frc.robot.commands; | ||||||||
|
|
||||||||
| import java.util.function.DoubleSupplier; | ||||||||
|
|
||||||||
| import edu.wpi.first.math.MathUtil; | ||||||||
| import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||||||||
| import edu.wpi.first.wpilibj2.command.CommandBase; | ||||||||
| import frc.robot.subsystems.Arm; | ||||||||
| import java.util.function.DoubleSupplier; | ||||||||
|
|
||||||||
|
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. [spotless] reported by reviewdog 🐶
Suggested change
|
||||||||
| public class ArmCommand extends CommandBase { | ||||||||
| // the arm subsystem used by this comment | ||||||||
|
|
@@ -13,18 +15,18 @@ public class ArmCommand extends CommandBase { | |||||||
| private final DoubleSupplier m_baseSpeed; | ||||||||
|
|
||||||||
| // default start position for the arm when the command is first scheduled | ||||||||
| private final double m_defaultPosition = 0.5; | ||||||||
| private final double m_defaultPosition = 0.2; | ||||||||
|
|
||||||||
| private final double m_deadband = | ||||||||
| 0.05; // to prevent stick drift, this value sets the min absolute value the speed needs to be | ||||||||
|
|
||||||||
| // to prevent stick drift, this value sets the min absolute value the speed needs to be | ||||||||
| // before we assume it is not zero | ||||||||
| private final double m_speedScale = | ||||||||
| 16; // to reduce stick sensitivity, this value indicates how much to scale the returned speed | ||||||||
| 64; // to reduce stick sensitivity, this value indicates how much to scale the returned speed | ||||||||
| // by | ||||||||
| private final double m_minBaseRange = 0; // min range for the arm's base | ||||||||
| private final double m_maxBaseRange = 1; // max range for the arm's base | ||||||||
| private final double m_minBaseRange = 0.2; // min range for the arm's base | ||||||||
| private final double m_maxBaseRange = 0.525; // max range for the arm's base | ||||||||
|
|
||||||||
| public ArmCommand(Arm arm, DoubleSupplier baseSpeed) { | ||||||||
| m_arm = arm; | ||||||||
|
|
@@ -58,5 +60,8 @@ public void execute() { | |||||||
|
|
||||||||
| // Finally, set the arm base positon to the new calculated arm position. | ||||||||
| m_arm.setArmBasePosition(newArmPosition); | ||||||||
|
|
||||||||
| SmartDashboard.putNumber("Arm Position", m_arm.getArmBasePosition()); | ||||||||
| SmartDashboard.putNumber("New Arm Position", newArmPosition); | ||||||||
| } | ||||||||
| } | ||||||||
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 | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -16,9 +16,10 @@ public class AutonomousDistance extends SequentialCommandGroup { | |||||||||||||||||
| */ | ||||||||||||||||||
| public AutonomousDistance(Drivetrain drivetrain) { | ||||||||||||||||||
| addCommands( | ||||||||||||||||||
| new DriveDistance(-0.5, 10, drivetrain), | ||||||||||||||||||
| new TurnDegrees(-0.5, 180, drivetrain), | ||||||||||||||||||
| new DriveDistance(-0.5, 10, drivetrain), | ||||||||||||||||||
| new TurnDegrees(0.5, 180, drivetrain)); | ||||||||||||||||||
| new DriveDistance(0.65, 11, drivetrain) | ||||||||||||||||||
| //new TurnDegrees(0.3, 80, drivetrain), | ||||||||||||||||||
| //new DriveDistance(0.5, 5, drivetrain), | ||||||||||||||||||
| //new TurnDegrees(0.35, 90, drivetrain) | ||||||||||||||||||
| ); | ||||||||||||||||||
|
Comment on lines
+20
to
+23
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. [spotless] reported by reviewdog 🐶
Suggested change
|
||||||||||||||||||
| } | ||||||||||||||||||
| } | ||||||||||||||||||
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,68 @@ | ||
| package frc.robot.commands; | ||
|
|
||
| import edu.wpi.first.math.MathUtil; | ||
| import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard; | ||
| import edu.wpi.first.wpilibj2.command.CommandBase; | ||
| import frc.robot.subsystems.Gripper; | ||
| import java.util.function.DoubleSupplier; | ||
|
|
||
| public class GripperCommand extends CommandBase { | ||
| // the gripper subsystem used by this comment | ||
| private final Gripper m_gripper; | ||
|
|
||
| // the supplier of the desired speed | ||
| private final DoubleSupplier m_baseSpeed; | ||
|
|
||
| // default start position for the gripper when the command is first scheduled | ||
| private final double m_defaultPosition = 0.5; | ||
|
|
||
| private final double m_deadband = | ||
| 0.05; // to prevent stick drift, this value sets the min absolute value the speed needs to be | ||
|
|
||
| // to prevent stick drift, this value sets the min absolute value the speed needs to be | ||
| // before we assume it is not zero | ||
| private final double m_speedScale = | ||
| 16; // to reduce stick sensitivity, this value indicates how much to scale the returned speed | ||
| // by | ||
| private final double m_minBaseRange = -1.50; // min range for the gripper's base | ||
| private final double m_maxBaseRange = 4.00; // max range for the gripper's base | ||
|
|
||
| public GripperCommand(Gripper gripper, DoubleSupplier baseSpeed) { | ||
| m_gripper = gripper; | ||
| m_baseSpeed = baseSpeed; | ||
|
|
||
| // To prevent scheduling conflicts, all commands need to indicate which sub-system(s) it uses | ||
| addRequirements(gripper); | ||
| } | ||
|
|
||
| @Override | ||
| public void initialize() { | ||
| // We set the gripper's base position to the default position when this command is first | ||
| // scheduled | ||
| m_gripper.setClawPosition(m_defaultPosition); | ||
| } | ||
|
|
||
| @Override | ||
| public void execute() { | ||
| // Variable that will store the new calculated gripper position | ||
| double newClawPosition; | ||
|
|
||
| // Determine the requested speed, but ignoring inputs near-zero (i.e. +/= m_deadband) | ||
| double newBasePositionDelta = MathUtil.applyDeadband(m_baseSpeed.getAsDouble(), m_deadband); | ||
| // Scale the speed as desired to reduce sensitivity | ||
| newBasePositionDelta /= m_speedScale; | ||
|
|
||
| // Calculate the gripper position by adding the computer speed to the gripper base's current | ||
| // position | ||
| newClawPosition = m_gripper.getClawPosition() + newBasePositionDelta; | ||
|
|
||
| // Clamp the gripper's upper/lower position to the min/max range allowed | ||
| newClawPosition = MathUtil.clamp(newClawPosition, m_minBaseRange, m_maxBaseRange); | ||
|
|
||
| // Finally, set the gripper base positon to the new calculated gripper position. | ||
| m_gripper.setClawPosition(newClawPosition); | ||
|
|
||
| SmartDashboard.putNumber("Gripper Position", m_gripper.getClawPosition()); | ||
| SmartDashboard.putNumber("New Gripper Position", newClawPosition); | ||
| } | ||
| } |
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,40 @@ | ||
| package frc.robot.subsystems; | ||
|
|
||
| import edu.wpi.first.wpilibj.Servo; | ||
| import edu.wpi.first.wpilibj2.command.SubsystemBase; | ||
|
|
||
| public class Gripper extends SubsystemBase { | ||
| // This code assumes we are using the ROMI's external IO configuration and the arm claw servo is | ||
| // connected to Romi Pin EXT4 which is configured as PWM and mapped to port 2 | ||
| // https://docs.wpilib.org/en/stable/docs/romi-robot/web-ui.html#external-io-configuration | ||
| private final Servo m_armClawServo = new Servo(3); | ||
|
|
||
| // Note: If you have a multi-axis arm, you could create another Servo object using a differemt PWM | ||
| // channel and add the corresponding methods for controlling the position. | ||
| // private final Servo m_armElbowServo = new Servo(2); | ||
|
|
||
| /** | ||
| * Moves the arm claw to the desired position. -1.0 is max down, and 1.0 is max up | ||
| * | ||
| * <p>Note: The concept of "up and down" depends on how the servo is mounted to the arm. E.g. if | ||
| * the servo is flipped, the directions would be reversed. This module abstracts the hardware | ||
| * implementation details and follows the convention of 1.0 is up. | ||
| * | ||
| * @param position desired target position for arm claw [0.0 to 1.0] | ||
| */ | ||
| public void setClawPosition(double position) { | ||
| // Note: This code doesn't validate the requested position. If we don't want the arm to move | ||
| // within the entire range (e.g. due to physical constraints), we could clamp the position to | ||
| // the min/max values before setting the servo's position | ||
| m_armClawServo.set(position); | ||
| } | ||
|
|
||
| /** | ||
| * @return the current desired target position for arm claw. Note: since the basic servo doesn't | ||
| * have any feedback, this is just the _requested_ position. The actual servo position is not | ||
| * known. | ||
| */ | ||
| public double getClawPosition() { | ||
| return m_armClawServo.get(); | ||
| } | ||
| } |
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.
[spotless] reported by reviewdog 🐶