-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from Team3256/feat/Turret
Feat/turret
- Loading branch information
Showing
12 changed files
with
562 additions
and
9 deletions.
There are no files selected for viewing
This file contains 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 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,92 @@ | ||
{ | ||
"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 | ||
} | ||
] | ||
} |
This file contains 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,5 @@ | ||
{ | ||
"NetworkTables Info": { | ||
"visible": true | ||
} | ||
} |
This file contains 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 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 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 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,26 @@ | ||
// Copyright (c) 2024 FRC 3256 | ||
// https://github.com/Team3256 | ||
// | ||
// Use of this source code is governed by a | ||
// license that can be found in the LICENSE file at | ||
// the root directory of this project. | ||
|
||
package frc.robot.subsystems.turret; | ||
|
||
import edu.wpi.first.math.geometry.Rotation2d; | ||
import org.littletonrobotics.junction.AutoLog; | ||
|
||
public interface EncoderIO { | ||
|
||
@AutoLog | ||
public static class EncoderIOInputs { | ||
public double encoderPositionDegrees = 0.0; | ||
public double encoderVelocity = 0.0; | ||
|
||
public Rotation2d turretMotorAbsolutePosition = new Rotation2d(); | ||
} | ||
|
||
public default void updateInputs(EncoderIOInputs inputs) {} | ||
|
||
public default void zero() {} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/main/java/frc/robot/subsystems/turret/EncoderIOCancoder.java
This file contains 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,50 @@ | ||
// Copyright (c) 2024 FRC 3256 | ||
// https://github.com/Team3256 | ||
// | ||
// Use of this source code is governed by a | ||
// license that can be found in the LICENSE file at | ||
// the root directory of this project. | ||
|
||
package frc.robot.subsystems.turret; | ||
|
||
import com.ctre.phoenix6.BaseStatusSignal; | ||
import com.ctre.phoenix6.StatusSignal; | ||
import com.ctre.phoenix6.hardware.CANcoder; | ||
import edu.wpi.first.math.util.Units; | ||
|
||
public class EncoderIOCancoder implements EncoderIO { | ||
|
||
private final CANcoder encoder; | ||
|
||
private final StatusSignal<Double> encoderPosition; | ||
private final StatusSignal<Double> encoderVelocity; | ||
|
||
public EncoderIOCancoder(int canCoderID) { | ||
encoder = new CANcoder(canCoderID, "mani"); | ||
var response = encoder.getConfigurator().apply(TurretConstants.canCoderConfig); | ||
|
||
if (!response.isOK()) { | ||
System.out.println( | ||
"CANcoder ID " + canCoderID + " failed config with error " + response.getDescription()); | ||
} | ||
|
||
encoderPosition = encoder.getAbsolutePosition(); | ||
encoderVelocity = encoder.getVelocity(); | ||
|
||
BaseStatusSignal.setUpdateFrequencyForAll( | ||
TurretConstants.updateFrequency, encoderPosition, encoderVelocity); | ||
encoder.optimizeBusUtilization(); | ||
} | ||
|
||
@Override | ||
public void updateInputs(EncoderIOInputs inputs) { | ||
BaseStatusSignal.refreshAll(encoderPosition, encoderVelocity); | ||
inputs.encoderPositionDegrees = Units.rotationsToDegrees(encoderPosition.getValueAsDouble()); | ||
inputs.encoderVelocity = encoderVelocity.getValueAsDouble(); | ||
} | ||
|
||
@Override | ||
public void zero() { | ||
encoder.setPosition(0.0); | ||
} | ||
} |
Oops, something went wrong.