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

Merge first (and second) competition code into master #26

Draft
wants to merge 88 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from 81 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
c6d9c7d
Add Climbing.java
aidenpike Jan 15, 2022
f4050d8
Merge branch 'master' into climbing
Jan 18, 2022
6970b43
changed Climbing.java
aidenpike Jan 18, 2022
ebe30f5
Update Climbing.java
aidenpike Jan 19, 2022
75e6903
Refactor LoggableTimer to accept name
aidenpike Jan 21, 2022
d5138db
Merge branch 'climbing' of https://github.com/RAR1741/RA22_RobotCode …
aidenpike Jan 21, 2022
ed360cf
Implement timer and cycle algorithm
aidenpike Jan 21, 2022
b7a0dc9
Add ClimbingSensors class
aidenpike Jan 21, 2022
91f05a3
Implement ClimbingSensors
aidenpike Jan 21, 2022
b91979b
Add climberEnabled
aidenpike Jan 21, 2022
0636f20
Declared climbing variables
HungryIronApple Jan 22, 2022
eca328d
Added setPower method
HungryIronApple Jan 22, 2022
2261878
Add climber controls
HungryIronApple Jan 22, 2022
cbbb8af
Merge branch 'master' into climbing
dracco1993 Jan 24, 2022
5dfdd72
Merge branch 'master' into climbing
dracco1993 Jan 29, 2022
6fe4207
Merge branch 'master' into climbing
TheBitEffect Feb 5, 2022
fd60b36
Merge branch 'master' into climbing
TheBitEffect Feb 5, 2022
95eab83
Merge branch 'master' into climbing
TheBitEffect Feb 5, 2022
0dfb898
Merge branch 'master' into climbing
dracco1993 Feb 18, 2022
e432045
LoggableTimer formatting
dracco1993 Feb 19, 2022
801fc33
Climbing -> Climber and ClimbingSensors -> ClimberSensors
dracco1993 Feb 19, 2022
187354a
More auto formatting
dracco1993 Feb 19, 2022
5b9cd23
Move to passing the Solenoids into the climber
dracco1993 Feb 19, 2022
bf2571c
Add temporary manual climber driver controls
dracco1993 Feb 19, 2022
40ea3cc
Test Climber Controls
rar1741programmer Feb 19, 2022
a56be21
Fix possibly missing break statements in climber
TheBitEffect Feb 19, 2022
42b8a1d
TEMP: Advance climber state manually
TheBitEffect Feb 19, 2022
c3810c5
Changed Idle Mode
rar1741programmer Feb 19, 2022
e2f28f8
Merge branch 'climbing' of https://github.com/RAR1741/RA22_RobotCode …
rar1741programmer Feb 19, 2022
dd21d55
add loggablegyro
kryllyxofficial01 Feb 22, 2022
d3da78b
whitespace
kryllyxofficial01 Feb 22, 2022
4a0bcaf
Add To-Do Reminder Comment
aidenpike Feb 22, 2022
96284aa
Merge branch 'LoggableGyro' into climbing
kryllyxofficial01 Feb 23, 2022
8598fc5
Merge branch 'climbing' of https://github.com/RAR1741/RA22_RobotCode …
aidenpike Feb 23, 2022
af09047
add motorstates
kryllyxofficial01 Feb 23, 2022
755d9a0
Merge branch 'climbing' of https://github.com/RAR1741/RA22_RobotCode …
kryllyxofficial01 Feb 23, 2022
b84cf4d
add instances for motor states
kryllyxofficial01 Feb 23, 2022
21ce2b6
Formatting
dracco1993 Feb 23, 2022
2b32468
Add FirstOrderFilter
dracco1993 Feb 23, 2022
8b59184
remove extra motor state method
kryllyxofficial01 Feb 23, 2022
9699d1c
Fix LoggableFirstOrderFilter
dracco1993 Feb 23, 2022
a1d1bb7
Fix conflict in setMotorState
dracco1993 Feb 23, 2022
f7b6dea
Merge branch 'climbing' of https://github.com/RAR1741/RA22_RobotCode …
dracco1993 Feb 23, 2022
a53e235
Ops...
dracco1993 Feb 23, 2022
2495ead
Log both climber filters
dracco1993 Feb 26, 2022
cca5439
Add more manual controls for testing
sreeves750 Feb 26, 2022
8ec5aba
Merge branch 'climbing' of https://github.com/RAR1741/RA22_RobotCode …
sreeves750 Feb 26, 2022
e259f8a
Update climber logging
dracco1993 Feb 26, 2022
443f1d7
Redfine the ClimbingStates enum
dracco1993 Feb 26, 2022
9044350
Put touch sensors into the same class
sreeves750 Feb 26, 2022
d9c9e3c
Add more climbing states
dracco1993 Feb 26, 2022
1f34030
Merge branch 'climbing' of https://github.com/RAR1741/RA22_RobotCode …
dracco1993 Feb 26, 2022
56a384f
WIP on climbing states
dracco1993 Feb 26, 2022
1533de4
Add automatic current shutoff
dracco1993 Feb 26, 2022
811be51
Ad getNextClimbingState
dracco1993 Feb 26, 2022
67741c1
Update next step setup
dracco1993 Feb 26, 2022
c2b3fe6
Comment out old code
dracco1993 Feb 26, 2022
efaadf8
Add next state current detection
dracco1993 Feb 26, 2022
1ec7032
Add climbing photogates for pistons
sreeves750 Feb 26, 2022
526d996
Merge branch 'climbing' of https://github.com/RAR1741/RA22_RobotCode …
sreeves750 Feb 26, 2022
8f6b8aa
Fix climber variable naming
dracco1993 Feb 28, 2022
26b50e5
Merge branch 'climbing' of https://github.com/RAR1741/RA22_RobotCode …
dracco1993 Feb 28, 2022
b0a398a
change wpilib version
kryllyxofficial01 Mar 1, 2022
c0958e8
add simulation configs
kryllyxofficial01 Mar 1, 2022
efac58a
modify debug configs
kryllyxofficial01 Mar 1, 2022
6a13a8a
fix indenting
kryllyxofficial01 Mar 2, 2022
d02495c
change climbingstates formatting
kryllyxofficial01 Mar 2, 2022
60aa96f
Initial testing for using current to change states
rar1741programmer Mar 3, 2022
b8af89d
Merge branch 'climbing' of https://github.com/RAR1741/RA22_RobotCode …
rar1741programmer Mar 3, 2022
2a7e5cf
Set motors to predetermined velocity when climbing
sreeves750 Mar 3, 2022
14a3aba
Add in automatic progression with climbing gates
sreeves750 Mar 3, 2022
461e060
Add automatic progression after swinging
sreeves750 Mar 3, 2022
3411dbb
Change resting piston positions
sreeves750 Mar 3, 2022
b7c0e41
Manually override formatting
dracco1993 Mar 3, 2022
90d6976
Merge branch 'climbing' of https://github.com/RAR1741/RA22_RobotCode …
dracco1993 Mar 3, 2022
7c3cc73
Remove old comment section
dracco1993 Mar 3, 2022
5f40e26
Add more allowed words
dracco1993 Mar 3, 2022
a2533ad
It worked 3 times in a row...
rar1741programmer Mar 15, 2022
5a1d546
Comp Code
rar1741programmer Mar 21, 2022
982f8ca
Tippy code featuring autobalancing & speed control
rar1741programmer Apr 7, 2022
9af3b88
Merge branch 'master' into first-comp
TheBitEffect Apr 8, 2022
4ced966
Remove Shooter code
TheBitEffect Apr 11, 2022
6d5ed0a
Remove Climber from Robot.java
TheBitEffect Apr 11, 2022
3572b0f
Start implimenting reworked climber execution plan
TheBitEffect Apr 12, 2022
c8faf9a
Fix left and right loggables erroring
TheBitEffect Apr 12, 2022
2e47e3e
Merge branch 'master' into first-comp
TheBitEffect Apr 12, 2022
740aae1
Push state comp code
rar1741programmer Apr 18, 2022
ff3a96a
Merge branch 'first-comp' of https://github.com/RAR1741/RA22_RobotCod…
rar1741programmer Apr 18, 2022
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
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ dependencies {
implementation wpi.java.deps.wpilib()
implementation wpi.java.vendor.java()

implementation 'com.google.code.gson:gson:2.9.0'

roborioDebug wpi.java.deps.wpilibJniDebug(wpi.platforms.roborio)
roborioDebug wpi.java.vendor.jniDebug(wpi.platforms.roborio)

Expand Down
28 changes: 28 additions & 0 deletions src/main/deploy/autos/auto-test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"auto": [
{
"type": "drive",
"unit": "SECONDS",
"amount": 0.1,
"args": [
-0.05,
-0.05
]
},
{
"type": "wait",
"args": [
1
]
},
{
"type": "turnDeg",
"unit": "DEGREES",
"amount": -90,
"args": [
0.1,
-0.1
]
}
]
}
13 changes: 13 additions & 0 deletions src/main/deploy/autos/autonomous.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"auto": [
{
"type": "drive",
"unit": "FEET",
"amount": 3.00,
"args": [
-0.1,
-0.1
]
}
]
}
28 changes: 28 additions & 0 deletions src/main/deploy/autos/current-test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"auto": [
{
"type": "drive",
"unit": "CURRENT",
"amount": 20,
"args": [
0.05,
0.05
]
},
{
"type": "wait",
"args": [
1
]
},
{
"type": "drive",
"unit": "FEET",
"amount": 5,
"args": [
-0.05,
-0.05
]
}
]
}
76 changes: 76 additions & 0 deletions src/main/deploy/autos/distance-test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"auto": [
{
"type": "drive",
"unit": "INCHES",
"amount": 50,
"args": [
-0.05,
-0.05
]
},
{
"type": "turnDeg",
"unit": "DEGREES",
"amount": 90,
"args": [
-0.05,
0.05
]
},
{
"type": "drive",
"unit": "INCHES",
"amount": 50,
"args": [
-0.05,
-0.05
]
},
{
"type": "turnDeg",
"unit": "DEGREES",
"amount": 90,
"args": [
-0.05,
0.05
]
},
{
"type": "drive",
"unit": "INCHES",
"amount": 50,
"args": [
-0.05,
-0.05
]
},
{
"type": "turnDeg",
"unit": "DEGREES",
"amount": 90,
"args": [
-0.05,
0.05
]
},
{
"type": "drive",
"unit": "INCHES",
"amount": 50,
"args": [
-0.05,
-0.05
]
},
{
"type": "turnDeg",
"unit": "DEGREES",
"amount": 90,
"args": [
-0.05,
0.05
]
}
]
}
17 changes: 17 additions & 0 deletions src/main/deploy/autos/shooter-test.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"auto": [
{
"type": "shoot",
"unit": "SPEED",
"args": [
1000
]
},
{
"type": "wait",
"args": [
5
]
}
]
}
5 changes: 5 additions & 0 deletions src/main/java/frc/robot/Autonomous.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package frc.robot;

public abstract class Autonomous {
public abstract void run();
}
28 changes: 14 additions & 14 deletions src/main/java/frc/robot/BoostInput.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@

package frc.robot;

public class BoostInput implements InputScaler
{
private final double powerCap;
private boolean enabled;
public class BoostInput implements InputScaler {
private final double powerCap;
private double boostScale;

public BoostInput(double powerCap) {
this.powerCap = powerCap;
this.enabled = false;
}
public BoostInput(double powerCap) {
this.powerCap = powerCap;
this.boostScale = 0;
}

public double scale(double input) {
return enabled ? input : input * powerCap;
}
public double scale(double input) {
double scale = (1 - powerCap) * boostScale;
return input * (powerCap + scale);
}

public void setEnabled(boolean enabled) {
this.enabled = enabled;
}
public void setScale(double boostScale) {
this.boostScale = boostScale;
}
}
64 changes: 39 additions & 25 deletions src/main/java/frc/robot/Climber.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,16 +44,18 @@ enum MotorStates {
}

public static double MAX_INSTANT_CURRENT = 200.0;
public static double MAX_AVERAGE_CURRENT = 110.0;
public static double MAX_AVERAGE_CURRENT = 120.0;
public static double NEXT_AB_STATE_CURRENT = 65.0;
public static double NEXT_BC_STATE_CURRENT = 45.0;
public static int FILTER_FRAME_RANGE = 10;

public static double TOUCH_A_POSITION = 0; // TBD
public static double SWING_AB_POSITION = 0; // TBD
public static double SWING_B_POSITION = 0; // TBD
public static double SWING_BC_POSITION = 0; // TBD
public static double SWING_MIN_VELOCITY = 1000; // TBD
public static double TOUCH_A_POSITION = 144000; // TBD
public static double SWING_AB_POSITION = 43000; // TBD
public static double SWING_B_POSITION = 900; // TBD
public static double SWING_BC_POSITION = 107000; // TBD
public static double SWING_MIN_VELOCITY = 1500; // TBD

private double motorSpeed;

TalonFX climbingMotor;
TalonFX secondaryClimbingMotor;
Expand Down Expand Up @@ -133,8 +135,8 @@ public void update() {
// 00 RESTING: Default resting
case RESTING:
climberSolenoidA.set(false);
climberSolenoidB1.set(true);
climberSolenoidB2.set(true);
climberSolenoidB1.set(false);
climberSolenoidB2.set(false);
climberSolenoidC.set(false);
break;

Expand All @@ -147,11 +149,12 @@ public void update() {
climberSolenoidB2.set(false);
climberSolenoidC.set(true);
// TODO: set motor target here
// climbingMotor.set(ControlMode.Position, TOUCH_A_POSITION);
setSpeed(motorSpeed);
break;

// 10 TOUCH_A: Pin A (button/sensor)
case TOUCH_A:
setSpeed(0);
climberSolenoidA.set(false);
climberSolenoidB1.set(true);
climberSolenoidB2.set(false);
Expand All @@ -167,16 +170,20 @@ public void update() {
case ROTATE_B:
// TODO: set motor power here
this.setSpeed(-0.4);
if (climbingMotor.getStatorCurrent() > NEXT_AB_STATE_CURRENT
|| secondaryClimbingMotor.getStatorCurrent() > NEXT_AB_STATE_CURRENT) {
setClimbingState(ClimbingStates.TOUCH_AB);
this.setSpeed(0);
}
climberSolenoidA.set(false);
climberSolenoidB1.set(true);
climberSolenoidB2.set(false);
climberSolenoidC.set(true);
// if (climbingMotor.getStatorCurrent() > NEXT_AB_STATE_CURRENT
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block of commented-out lines of code should be removed.

// || secondaryClimbingMotor.getStatorCurrent() > NEXT_AB_STATE_CURRENT) {
// setClimbingState(ClimbingStates.TOUCH_AB);
// this.setSpeed(0);
// }
break;

// 20 TOUCH_AB: Pin B (high current/sensor)
case TOUCH_AB:
this.setSpeed(0);
this.setSpeed(-0.05);
climberSolenoidA.set(false);
climberSolenoidB1.set(false);
climberSolenoidB2.set(false);
Expand All @@ -190,10 +197,9 @@ public void update() {
case ROTATE_AB_DOWN:
this.setPower(0);
// TODO: set motor target here
if (Math.abs(climbingMotor.getSelectedSensorPosition() - SWING_AB_POSITION) < 500) {// Determine
// tolerance
if (climbingMotor.getSelectedSensorPosition() > SWING_AB_POSITION) {// Was less then when broken
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is longer than 100 characters (found 112).

System.out.println("DONE SWINGING!");
// setClimbingState(ClimbingStates.RELEASE_A);
setClimbingState(ClimbingStates.RELEASE_A);
}
break;

Expand All @@ -206,18 +212,18 @@ public void update() {
climberSolenoidC.set(true);
// TODO: set motor target here
// if (!gates.getA()) {
// setClimbingState(ClimbingStates.ROTATE_B_DOWN);;
setClimbingState(ClimbingStates.ROTATE_B_DOWN);;
// }
break;

// 35 ROTATE_B_DOWN: Wait for swinging (photogate)
case ROTATE_B_DOWN:
// TODO: set motor target here
this.setPower(0);
if (Math.abs(climbingMotor.getSelectedSensorPosition() - SWING_B_POSITION) < 500
if (Math.abs(climbingMotor.getSelectedSensorPosition() - SWING_B_POSITION) < 1000
&& Math.abs(
climbingMotor.getSelectedSensorVelocity()) < SWING_MIN_VELOCITY) {// Determine
// tolerance
// tolerance
System.out.println("DONE SWINGING!");
// setClimbingState(ClimbingStates.ROTATE_C);
}
Expand All @@ -226,7 +232,7 @@ public void update() {
// 40 ROTATE_C: Rotate to C bar (gyro/accel)
case ROTATE_C:
// TODO: set motor target here
this.setSpeed(-0.2);
this.setSpeed(-0.3);
if (climbingMotor.getStatorCurrent() > NEXT_BC_STATE_CURRENT
|| secondaryClimbingMotor.getStatorCurrent() > NEXT_BC_STATE_CURRENT) {
setClimbingState(ClimbingStates.TOUCH_BC);
Expand All @@ -251,8 +257,7 @@ public void update() {
case ROTATE_BC_DOWN:
// TODO: set motor target here
this.setPower(0);
if (Math.abs(climbingMotor.getSelectedSensorPosition() - SWING_BC_POSITION) < 500) {// Determine
// tolerance
if (climbingMotor.getSelectedSensorPosition() < SWING_BC_POSITION) {// Determine tolerance
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is longer than 100 characters (found 106).

System.out.println("DONE SWINGING!");
// setClimbingState(ClimbingStates.RELEASE_B);
}
Expand Down Expand Up @@ -302,6 +307,14 @@ public ClimbingStates getNextClimbingState() {
return ClimbingStates.values()[this.currentClimberState.ordinal() + 1];
}

public ClimbingStates getPreviousClimbingState() {
return ClimbingStates.values()[this.currentClimberState.ordinal() - 1];
}

public int getClimberStateId() {
return this.currentClimberState.ordinal();
}

public void disableClimber() {
// Stop the motors
this.climbingMotor.set(ControlMode.PercentOutput, 0);
Expand Down Expand Up @@ -397,7 +410,8 @@ public void setMotors(double value) {
break;

case ACTIVE:
setSpeed(value);
motorSpeed = value;
setSpeed(motorSpeed);
break;

default:
Expand Down
6 changes: 4 additions & 2 deletions src/main/java/frc/robot/ClimberGates.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public void setupLogging(Logger logger) {

@Override
public void log(Logger logger) {
// TODO Auto-generated method stub

logger.log("GateA", this.getA());
logger.log("GateB1", this.getB2());
logger.log("GateB2", this.getB2());
logger.log("GateC", this.getC());
}
}
Loading