Skip to content

Commit e798f14

Browse files
y0shiy0shiIgniteRobotics
authored
Merge slew rate changes with extras. (#29)
* Testing tunable slew rates. * git checkout * Replaced bad pipeline with states version. * Make driver able to outtake. * Sunday Oct 16 Climb Limit setting Co-authored-by: y0shi <y0shi@noreply.github.com> Co-authored-by: IgniteRobotics <ignite@igniterobtics.com>
1 parent c2eeb26 commit e798f14

8 files changed

Lines changed: 75 additions & 34 deletions

File tree

Pipeline_Name.vpr

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,22 @@
11
area_max:100
22
area_min:0
33
area_similarity:0
4-
aspect_max:20
5-
aspect_min:0.07206001250000002
6-
black_level:7
4+
aspect_max:9.265007812499999
5+
aspect_min:0.03532201249999999
6+
black_level:11
77
blue_balance:998
88
calibration_type:0
99
contour_grouping:3
1010
contour_sort_final:6
1111
convexity_max:100
1212
convexity_min:12
1313
corner_approx:5.000000
14+
crop_x_max:1.000000
15+
crop_x_min:-1.000000
16+
crop_y_max:1.000000
17+
crop_y_min:-1.000000
1418
cross_a_a:1
15-
cross_a_x:0
19+
cross_a_x:-0.05
1620
cross_a_y:0
1721
cross_b_a:1
1822
cross_b_x:0
@@ -22,11 +26,11 @@ desired_contour_region:0
2226
dilation_steps:1
2327
direction_filter:0
2428
dual_close_sort_origin:0
25-
erosion_steps:1
29+
erosion_steps:0
2630
exposure:3
2731
force_convex:1
28-
hue_max:72
29-
hue_min:47
32+
hue_max:80
33+
hue_min:39
3034
image_flip:0
3135
image_source:0
3236
img_to_show:0
@@ -39,11 +43,11 @@ pipeline_led_enabled:1
3943
pipeline_led_power:100
4044
pipeline_res:0
4145
pipeline_type:0
42-
red_balance:1198
46+
red_balance:2301
4347
roi_x:0.000000
4448
roi_y:0.000000
4549
sat_max:255
46-
sat_min:208
50+
sat_min:128
4751
send_corners:0
4852
send_raw_contours:0
4953
solve3d:0
@@ -57,8 +61,8 @@ solve3d_precies:1
5761
solve3d_precise:0
5862
solve3d_zoffset:0.000000
5963
val_max:244
60-
val_min:115
61-
x_outlier_miqr:1.5
64+
val_min:82
65+
x_outlier_miqr:1.1
6266
y_max:1.000000
6367
y_min:-1.000000
64-
y_outlier_miqr:1.5
68+
y_outlier_miqr:1

networktables.ini

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,27 @@
11
[NetworkTables Storage 3.0]
22
string "/Preferences/.type"="RobotPreferences"
33
double "/Preferences/Belt Delay"=0.35
4+
double "/Preferences/Climb Down Effort"=1
5+
double "/Preferences/Climb Up Effort"=1
46
double "/Preferences/Default Turret Position"=0
7+
double "/Preferences/Drive Slew Rate"=2.5
58
double "/Preferences/Eject Velocity"=9000
69
double "/Preferences/FenderHigh Velocity"=7000
710
double "/Preferences/FenderLow Velocity"=2500
11+
double "/Preferences/Forward Drive Multiplier"=0.7
812
double "/Preferences/Hood Set Position"=0
13+
double "/Preferences/Indexer/Belt Speed"=1
14+
double "/Preferences/Indexer/Kickup Speed"=1
915
double "/Preferences/Initial Turret Offset"=0
16+
double "/Preferences/Intake Speed"=0.5
1017
double "/Preferences/Passive shooter velocity"=7500
18+
double "/Preferences/Reverse Drive Multiplier"=0.7
19+
double "/Preferences/Rotation Slew Rate"=3
20+
double "/Preferences/Shooter Feed Effort"=0.5
1121
double "/Preferences/Shooter Set Velocity"=0
22+
double "/Preferences/Shooter kD"=0.03
23+
double "/Preferences/Shooter kF"=0.05568
24+
double "/Preferences/Shooter kP"=0.2
25+
double "/Preferences/Slow Mode Multiplier"=0.4
26+
double "/Preferences/Turn Multiplier"=0.69
1227
double "/Preferences/VELOCITY OFFSET"=0

networktables.ini.bak

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[NetworkTables Storage 3.0]
2+
string "/Preferences/.type"="RobotPreferences"
3+
double "/Preferences/Belt Delay"=0.35
4+
double "/Preferences/Default Turret Position"=0
5+
double "/Preferences/Eject Velocity"=9000
6+
double "/Preferences/FenderHigh Velocity"=7000
7+
double "/Preferences/FenderLow Velocity"=2500
8+
double "/Preferences/Hood Set Position"=0
9+
double "/Preferences/Initial Turret Offset"=0
10+
double "/Preferences/Passive shooter velocity"=7500
11+
double "/Preferences/Shooter Set Velocity"=0
12+
double "/Preferences/VELOCITY OFFSET"=0

src/main/java/frc/robot/Robot.java

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,28 @@ public void robotInit() {
5252
pneumaticHub.enableCompressorAnalog(100, 120);
5353
compressor.enableDigital();
5454
m_robotContainer.m_driveTrain.setNeutralMode(NeutralMode.Coast);
55-
final UsbCamera camera = CameraServer.startAutomaticCapture();
55+
if (Robot.isReal()){
56+
final UsbCamera camera = CameraServer.startAutomaticCapture();
5657

57-
visionThread = new Thread(() -> {
58-
CvSink cvSink = CameraServer.getVideo();
59-
CvSource outputStream = CameraServer.putVideo("Driver Camera", 600, 800);
58+
visionThread = new Thread(() -> {
59+
CvSink cvSink = CameraServer.getVideo();
60+
CvSource outputStream = CameraServer.putVideo("Driver Camera", 600, 800);
6061

61-
Mat imageMat = new Mat();
62+
Mat imageMat = new Mat();
6263

63-
Scalar color = new Scalar(255, 0, 0);
64+
Scalar color = new Scalar(255, 0, 0);
6465

65-
while(!Thread.interrupted()) {
66-
if(cvSink.grabFrame(imageMat) == 0) continue;
66+
while(!Thread.interrupted()) {
67+
if(cvSink.grabFrame(imageMat) == 0) continue;
6768

68-
Imgproc.circle(imageMat, new Point(imageMat.width() / 2, imageMat.height() / 2), 5, color);
69+
Imgproc.circle(imageMat, new Point(imageMat.width() / 2, imageMat.height() / 2), 5, color);
6970

70-
outputStream.putFrame(imageMat);
71-
}
72-
});
73-
74-
visionThread.start();
71+
outputStream.putFrame(imageMat);
72+
}
73+
});
7574

75+
visionThread.start();
76+
}
7677
m_robotContainer.stableSensor.schedule();
7778
}
7879

src/main/java/frc/robot/commands/drivetrain/ArcadeDrive.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public class ArcadeDrive extends CommandBase { // TODO Figure out how to make a
1919
private DoublePreference driveMultiplier = new DoublePreference("Forward Drive Multiplier", 0.7);
2020
private DoublePreference reverseDriveMultiplier = new DoublePreference("Reverse Drive Multiplier", 0.7);
2121
private DoublePreference slowMultiplier = new DoublePreference("Slow Mode Multiplier", 0.4);
22+
private DoublePreference velocityRateLimit = new DoublePreference("Drive Slew Rate", 2.5);
23+
private DoublePreference rotationRateLimit = new DoublePreference("Rotation Slew Rate", 3.0);
2224

2325
private Drivetrain m_driveTrain = null;
2426
private XboxController driverController = null;
@@ -41,6 +43,7 @@ public ArcadeDrive(XboxController driveController, Drivetrain driveTrain) {
4143
// Called when the command is initially scheduled.
4244
@Override
4345
public void initialize() {
46+
this.m_driveTrain.updateSlewRates(velocityRateLimit.getValue(), rotationRateLimit.getValue());
4447
}
4548

4649
// Called every time the scheduler runs while the command is scheduled.

src/main/java/frc/robot/commands/intake/RunIntake.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,14 @@ public void execute() {
4747
return;
4848
} else {
4949
//spin will extend
50+
// intake.spin();
51+
// }
52+
if (this.direction){
5053
intake.spin();
54+
} else {
55+
intake.outtake();
56+
}
5157
}
52-
// if (this.direction){
53-
// intake.spin(Intake.INTAKE_SPEED);
54-
// } else {
55-
// intake.spin(Intake.OUTTAKE_SPEED);
56-
// }
5758

5859
}
5960

src/main/java/frc/robot/constants/ClimbConstants.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
public class ClimbConstants {
44
public static final int CLIMBER_FORWARD_LIMIT_LEFT = 337000;
55
public static final int CLIMBER_REVERSE_LIMIT_LEFT = 100;
6-
public static final int CLIMBER_FORWARD_LIMIT_RIGHT = 336463;
6+
public static final int CLIMBER_FORWARD_LIMIT_RIGHT = 385000;
77
public static final int CLIMBER_REVERSE_LIMIT_RIGHT = 100;
88

99
//Defines speeds for climber movement

src/main/java/frc/robot/subsystems/Drivetrain.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ public class Drivetrain extends SubsystemBase {
7777

7878
private final DifferentialDriveOdometry m_odometry;
7979

80-
private final SlewRateLimiter speedRateLimiter = new SlewRateLimiter(SPEED_RATE_LIMIT_ARCADE);
81-
private final SlewRateLimiter rotationRateLimiter = new SlewRateLimiter(ROTATION_RATE_LIMIT_ARCADE);
80+
private SlewRateLimiter speedRateLimiter = new SlewRateLimiter(SPEED_RATE_LIMIT_ARCADE);
81+
private SlewRateLimiter rotationRateLimiter = new SlewRateLimiter(ROTATION_RATE_LIMIT_ARCADE);
8282

8383
private SensorProfile sensorProfile = new SensorProfile(2048, 10);
8484

@@ -182,6 +182,11 @@ public void resetOdometry(Pose2d startingPose) {
182182
m_odometry.resetPosition(startingPose, navX.getRotation2d());
183183
}
184184

185+
public void updateSlewRates(double velocityLimit, double rotationLimit){
186+
this.speedRateLimiter = new SlewRateLimiter(velocityLimit);
187+
this.rotationRateLimiter = new SlewRateLimiter(rotationLimit);
188+
}
189+
185190
public void arcadeDrive(final double speed, final double rotation, final boolean useSquares) {
186191
var xSpeed = speedRateLimiter.calculate(safeClamp(speed));
187192
var zRotation = rotationRateLimiter.calculate(safeClamp(rotation));

0 commit comments

Comments
 (0)