-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathConstants.java
189 lines (149 loc) · 7.57 KB
/
Constants.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
// 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;
import java.util.stream.Collector.Characteristics;
import edu.wpi.first.math.controller.SimpleMotorFeedforward;
import edu.wpi.first.math.geometry.Translation2d;
import edu.wpi.first.math.kinematics.SwerveDriveKinematics;
import edu.wpi.first.math.trajectory.TrapezoidProfile;
import edu.wpi.first.math.util.Units;
import edu.wpi.first.wpilibj.RobotBase;
import frc.robot.util.ConstantAxis;
import frc.robot.util.ConstantButton;
/**
* The Constants class provides a convenient place for teams to hold robot-wide numerical or boolean
* constants. This class should not be used for any other purpose. All constants should be declared
* globally (i.e. public static). Do not put anything functional in this class.
*
* <p>It is advised to statically import this class (or one of its inner classes) wherever the
* constants are needed, to reduce verbosity.
*/
public final class Constants {
//Distance to the Mid Bar
public static final double CLIMBER_ENCODER_DISTANCE_MID = 12;
//Distance to the Low Bar
public static final double CLIMBER_ENCODER_DISTANCE_LOW = 8;
//setpoint for pulling the robot off the ground using random values
public static final double RETRACTER_ENCODER_DISTANCE = 0; //random value need to test
public static final boolean IS_REAL = RobotBase.isReal();
public static final double AIM_SCALING_FACTOR_X = -0.5;
public static final double AIM_SCALING_FACTOR_Y = -0.5;
public static final double CLIMBER_ENCODER_DISTANCE = 12;
public static final double SHOOTER_LIMELIGHT_ANGLE = 0.5;
public static final int FALCON_MAX_RPM = 6380;
public static final int SHOOTER_RPM = 3000;
public static final class PID {
//Climb
public static final double P_CLIMB = 0.1;
public static final double I_CLIMB = 1e-4;
public static final double D_CLIMB = 1;
//Swerve
public static final double P_SWERVE_STEER = 2;//3.5;
public static final double I_SWERVE_STEER = 0.0;
public static final double D_SWERVE_STEER = 0;//10;
public static final double P_SWERVE_POWER = 0.00015;
public static final double I_SWERVE_POWER = 0.00;
public static final double D_SWERVE_POWER = 0.01;
// Linear drive feed forward
public static final SimpleMotorFeedforward DRIVE_FF = IS_REAL ?
new SimpleMotorFeedforward( // real
0.6, // Voltage to break static friction
2.5, // Volts per meter per second
1 // Volts per meter per second squared
)
:
new SimpleMotorFeedforward( // sim
0, // Voltage to break static friction -- we do not use kS with this method of simulation
2.5, // Volts per meter per second
0.4 // Volts per meter per second squared -- lower kA will give snappier control
);
// Steer feed forward
public static final SimpleMotorFeedforward STEER_FF = IS_REAL ?
new SimpleMotorFeedforward( // real
0, // Voltage to break static friction
0.15, // Volts per radian per second
0.04 // Volts per radian per second squared
)
:
new SimpleMotorFeedforward( // sim
0, // Voltage to break static friction
0.15, // Volts per radian per second
0.002 // Volts per radian per second squared
);
//Controller
public static final double P_X_CONTROLLER = 1.5;
public static final double P_Y_CONTROLLER = 1.5;
public static final double P_THETA_CONTROLLER = 3;
public static final double SHOOTER_P = 0.1;
public static final double SHOOTER_I = 1e-4;
public static final double SHOOTER_D = 1;
}
public static final class RobotDimensions {
// Distance between wheels
public static final double WIDTH = Units.inchesToMeters(24); //inches
public static final double LENGTH = Units.inchesToMeters(24); //inches
public static final double WHEEL_CIRCUMFRENCE = Units.inchesToMeters(4) * Math.PI;
}
public static final class Input {
//Axis
public static final ConstantButton CLIMB_MID_BUTTON = new ConstantButton(1, 1);
public static final ConstantButton CLIMB_LOW_BUTTON = new ConstantButton(1, 1);
public static final ConstantButton RETRACT_BUTTON = new ConstantButton(1, 1);
public static final ConstantButton OVERRIDE_UP_CLIMB = new ConstantButton(1, 1);
public static final ConstantButton OVERRIDE_DOWN_CLIMB = new ConstantButton(1, 1);
public static final ConstantAxis X_AXIS = new ConstantAxis(0, 0);
public static final ConstantAxis Y_AXIS = new ConstantAxis(0, 1);
public static final ConstantAxis ROTATION = new ConstantAxis(0, 4);
//Buttons
public static final ConstantButton CLIMB_BUTTON = new ConstantButton(1, 1);
public static final ConstantButton INTAKE_BUTTON = new ConstantButton(1, 5);
public static final ConstantButton STORAGE_TOGGLE = new ConstantButton(1, 0);
}
public static final class MotorSettings {
public static final double MOTOR_VELOCITY = 0.5;
public static final int MOTOR_EXPIRATION = 4;
}
public static final class Motor {
//Swerve
public static final int SWERVE_FRONT_LEFT_POWER = 4;
public static final int SWERVE_FRONT_LEFT_STEER = 15;
public static final int SWERVE_FRONT_RIGHT_POWER = 3;
public static final int SWERVE_FRONT_RIGHT_STEER = 14;
public static final int SWERVE_BACK_LEFT_POWER = 2;
public static final int SWERVE_BACK_LEFT_STEER = 13;
public static final int SWERVE_BACK_RIGHT_POWER = 1;
public static final int SWERVE_BACK_RIGHT_STEER = 12;
public static final SwerveDriveKinematics SWERVE_DRIVE_KINEMATICS = new SwerveDriveKinematics(
new Translation2d(-RobotDimensions.LENGTH / 2, RobotDimensions.WIDTH / 2),
new Translation2d(-RobotDimensions.LENGTH / 2, -RobotDimensions.WIDTH / 2),
new Translation2d(RobotDimensions.LENGTH / 2, RobotDimensions.WIDTH / 2),
new Translation2d(RobotDimensions.LENGTH / 2, -RobotDimensions.WIDTH / 2));
public static final double SWERVE_POWER_GEAR_RATIO = 6.55;
public static final double SWERVE_MAX_SPEED = 5.18; // m/s
public static final double SWERVE_MAX_ACCELERATION = 3; // m/s^2
public static final double SWERVE_ROTATION_MAX_SPEED = 2 * 2 * Math.PI; // rad/s
public static final double SWERVE_ROTATION_MAX_ACCELERATION = Math.PI / 4; // rad/s^2
public static final double SWERVE_NOMINAL_OUTPUT_PERCENT = 0.05;
public static final double SWERVE_NOMINAL_OUTPUT_STEER = 0.000;
public static final double SWERVE_DEADBAND = 0.05;
public static final TrapezoidProfile.Constraints THETA_CONTROL_CONSTRAINTS = new TrapezoidProfile.Constraints(SWERVE_ROTATION_MAX_SPEED, SWERVE_ROTATION_MAX_ACCELERATION);
//Storage
public static final int STORAGE_MOVEMENT_BELT = 8;
public static final int SHOOTER_PORT = 2;
public static final int EXAMPLE_INTAKE_CHANNEL = 3;
public static final int INTAKE = 5;
public static final double INTAKE_SPEED = 0.5;
public static final int LEFT_CLIMB_MOTOR = 0; //reset to actual later
public static final int RIGHT_CLIMB_MOTOR = 1; //reset to actual later
public static final double CLIMB_SPEED = 0.5;
}
public static final class Characteristics {
public static final double MPS_TO_RPM = 1315;
}
public static final class Sensor {
public static final int SWERVE_GYRO = 0;
public static final int WHEEL_ENCODER_CHANNEL_A = 4;
public static final int WHEEL_ENCODER_CHANNEL_B = 6;
}
}