generated from StuyPulse/Phil
-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMotors.java
More file actions
99 lines (85 loc) · 3.86 KB
/
Motors.java
File metadata and controls
99 lines (85 loc) · 3.86 KB
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
/************************ PROJECT PHIL ************************/
/* Copyright (c) 2024 StuyPulse Robotics. All rights reserved.*/
/* This work is licensed under the terms of the MIT license. */
/**************************************************************/
package com.stuypulse.robot.constants;
import com.ctre.phoenix.motorcontrol.NeutralMode;
import com.ctre.phoenix.motorcontrol.can.WPI_TalonSRX;
import com.ctre.phoenix.motorcontrol.can.WPI_VictorSPX;
import com.revrobotics.spark.config.SparkBaseConfig;
import com.revrobotics.spark.config.SparkMaxConfig;
import com.revrobotics.spark.config.SparkBaseConfig.IdleMode;
/**
* File containing all of the configurations that different motors require.
*
* Such configurations include:
* - If it is Inverted
* - The Idle Mode of the Motor
* - The Current Limit
* - The Open Loop Ramp Rate
*/
public interface Motors {
public interface PivotConfig {
SparkBaseConfig PIVOT_ROLLER_MOTOR_CONFIG = new SparkMaxConfig().smartCurrentLimit(Settings.Pivot.PIVOT_ROLLER_MOTOR_CURRENT_LIMIT).idleMode(IdleMode.kBrake);
SparkBaseConfig PIVOT_MOTOR_CONFIG = new SparkMaxConfig().smartCurrentLimit(Settings.Pivot.PIVOT_MOTOR_CURRENT_LIMIT).idleMode(IdleMode.kBrake);
}
public interface ClimbConfig {
SparkBaseConfig CLIMB_MOTOR_CONFIG = new SparkMaxConfig().smartCurrentLimit(Settings.Climb.CLIMB_CURRENT_LIMIT).idleMode(IdleMode.kBrake);
}
public interface DrivetrainConfig {
SparkBaseConfig DRIVETRAIN_MOTOR_CONFIG = new SparkMaxConfig().smartCurrentLimit(Settings.Drivetrain.DRIVE_MOTOR_CURRENT_LIMIT).idleMode(IdleMode.kBrake);
}
/** Classes to store all of the values a motor needs */
public static class TalonSRXConfig {
public final boolean INVERTED;
public final NeutralMode NEUTRAL_MODE;
public final int PEAK_CURRENT_LIMIT_AMPS;
public final double OPEN_LOOP_RAMP_RATE;
public TalonSRXConfig(
boolean inverted,
NeutralMode neutralMode,
int peakCurrentLimitAmps,
double openLoopRampRate) {
this.INVERTED = inverted;
this.NEUTRAL_MODE = neutralMode;
this.PEAK_CURRENT_LIMIT_AMPS = peakCurrentLimitAmps;
this.OPEN_LOOP_RAMP_RATE = openLoopRampRate;
}
public TalonSRXConfig(boolean inverted, NeutralMode neutralMode, int peakCurrentLimitAmps) {
this(inverted, neutralMode, peakCurrentLimitAmps, 0.0);
}
public TalonSRXConfig(boolean inverted, NeutralMode neutralMode) {
this(inverted, neutralMode, 80);
}
public void configure(WPI_TalonSRX motor) {
motor.setInverted(INVERTED);
motor.setNeutralMode(NEUTRAL_MODE);
motor.configContinuousCurrentLimit(PEAK_CURRENT_LIMIT_AMPS - 10, 0);
motor.configPeakCurrentLimit(PEAK_CURRENT_LIMIT_AMPS, 0);
motor.configPeakCurrentDuration(100, 0);
motor.enableCurrentLimit(true);
motor.configOpenloopRamp(OPEN_LOOP_RAMP_RATE);
}
}
public static class VictorSPXConfig {
public final boolean INVERTED;
public final NeutralMode NEUTRAL_MODE;
public final double OPEN_LOOP_RAMP_RATE;
public VictorSPXConfig(
boolean inverted,
NeutralMode neutralMode,
double openLoopRampRate) {
this.INVERTED = inverted;
this.NEUTRAL_MODE = neutralMode;
this.OPEN_LOOP_RAMP_RATE = openLoopRampRate;
}
public VictorSPXConfig(boolean inverted, NeutralMode neutralMode) {
this(inverted, neutralMode, 0.0);
}
public void configure(WPI_VictorSPX motor) {
motor.setInverted(INVERTED);
motor.setNeutralMode(NEUTRAL_MODE);
motor.configOpenloopRamp(OPEN_LOOP_RAMP_RATE);
}
}
}