7.10午
This commit is contained in:
@@ -100,23 +100,6 @@
|
|||||||
"false_icon": "None"
|
"false_icon": "None"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"title": "Shooter At Voltage",
|
|
||||||
"x": 192.0,
|
|
||||||
"y": 128.0,
|
|
||||||
"width": 192.0,
|
|
||||||
"height": 128.0,
|
|
||||||
"type": "Boolean Box",
|
|
||||||
"properties": {
|
|
||||||
"topic": "/Superstructure/shooterAtVoltage",
|
|
||||||
"period": 0.06,
|
|
||||||
"data_type": "boolean",
|
|
||||||
"true_color": 4283215696,
|
|
||||||
"false_color": 4294198070,
|
|
||||||
"true_icon": "None",
|
|
||||||
"false_icon": "None"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"title": "Drive Aimed",
|
"title": "Drive Aimed",
|
||||||
"x": 384.0,
|
"x": 384.0,
|
||||||
@@ -292,37 +275,6 @@
|
|||||||
"line_width": 2.0
|
"line_width": 2.0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"title": "Flywheel Target Voltage",
|
|
||||||
"x": 384.0,
|
|
||||||
"y": 0.0,
|
|
||||||
"width": 256.0,
|
|
||||||
"height": 128.0,
|
|
||||||
"type": "Text Display",
|
|
||||||
"properties": {
|
|
||||||
"topic": "/Shooter/flywheelTargetVoltage",
|
|
||||||
"period": 0.06,
|
|
||||||
"data_type": "double",
|
|
||||||
"show_submit_button": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Flywheel At Voltage",
|
|
||||||
"x": 640.0,
|
|
||||||
"y": 0.0,
|
|
||||||
"width": 256.0,
|
|
||||||
"height": 128.0,
|
|
||||||
"type": "Boolean Box",
|
|
||||||
"properties": {
|
|
||||||
"topic": "/Shooter/flywheelAtVoltage",
|
|
||||||
"period": 0.06,
|
|
||||||
"data_type": "boolean",
|
|
||||||
"true_color": 4283215696,
|
|
||||||
"false_color": 4294198070,
|
|
||||||
"true_icon": "None",
|
|
||||||
"false_icon": "None"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"title": "Flywheel Velocity Difference",
|
"title": "Flywheel Velocity Difference",
|
||||||
"x": 384.0,
|
"x": 384.0,
|
||||||
@@ -1058,33 +1010,6 @@
|
|||||||
"data_type": "boolean"
|
"data_type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"title": "Flywheel Run",
|
|
||||||
"x": 128.0,
|
|
||||||
"y": 192.0,
|
|
||||||
"width": 128.0,
|
|
||||||
"height": 128.0,
|
|
||||||
"type": "Toggle Switch",
|
|
||||||
"properties": {
|
|
||||||
"topic": "/Tuning/flywheel/flywheelEnableRunning",
|
|
||||||
"period": 0.06,
|
|
||||||
"data_type": "boolean"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Flywheel Run Volts",
|
|
||||||
"x": 256.0,
|
|
||||||
"y": 192.0,
|
|
||||||
"width": 256.0,
|
|
||||||
"height": 128.0,
|
|
||||||
"type": "Text Display",
|
|
||||||
"properties": {
|
|
||||||
"topic": "/Tuning/flywheel/flywheelRunningVolts",
|
|
||||||
"period": 0.06,
|
|
||||||
"data_type": "double",
|
|
||||||
"show_submit_button": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"title": "Shooter Conv Enable",
|
"title": "Shooter Conv Enable",
|
||||||
"x": 0.0,
|
"x": 0.0,
|
||||||
@@ -1098,33 +1023,6 @@
|
|||||||
"data_type": "boolean"
|
"data_type": "boolean"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"title": "Shooter Conv Run",
|
|
||||||
"x": 128.0,
|
|
||||||
"y": 384.0,
|
|
||||||
"width": 128.0,
|
|
||||||
"height": 128.0,
|
|
||||||
"type": "Toggle Switch",
|
|
||||||
"properties": {
|
|
||||||
"topic": "/Tuning/conveyor/conveyorEnableRunning",
|
|
||||||
"period": 0.06,
|
|
||||||
"data_type": "boolean"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"title": "Shooter Conv Run Volts",
|
|
||||||
"x": 256.0,
|
|
||||||
"y": 384.0,
|
|
||||||
"width": 256.0,
|
|
||||||
"height": 128.0,
|
|
||||||
"type": "Text Display",
|
|
||||||
"properties": {
|
|
||||||
"topic": "/Tuning/conveyor/conveyorRunningVolts",
|
|
||||||
"period": 0.06,
|
|
||||||
"data_type": "double",
|
|
||||||
"show_submit_button": true
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"title": "Backboard Enable",
|
"title": "Backboard Enable",
|
||||||
"x": 0.0,
|
"x": 0.0,
|
||||||
@@ -2689,20 +2587,6 @@
|
|||||||
"line_width": 2.0
|
"line_width": 2.0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"title": "Target Volts Estimate",
|
|
||||||
"x": 0.0,
|
|
||||||
"y": 1024.0,
|
|
||||||
"width": 256.0,
|
|
||||||
"height": 128.0,
|
|
||||||
"type": "Text Display",
|
|
||||||
"properties": {
|
|
||||||
"topic": "/Shooter/flywheelTargetVoltage",
|
|
||||||
"period": 0.06,
|
|
||||||
"data_type": "double",
|
|
||||||
"show_submit_button": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"title": "Left Output Volts",
|
"title": "Left Output Volts",
|
||||||
"x": 256.0,
|
"x": 256.0,
|
||||||
|
|||||||
-1582
File diff suppressed because it is too large
Load Diff
@@ -11,7 +11,7 @@ public final class Constants {
|
|||||||
public static final boolean LEDUsing = false;
|
public static final boolean LEDUsing = false;
|
||||||
|
|
||||||
public static class Shooter {
|
public static class Shooter {
|
||||||
// 机构 CAN ID 目前是占位值;季后赛最终接线确认后,只需要改这里。
|
// Placeholder mechanism CAN IDs; update here after final wiring.
|
||||||
public static final int leftFlywheelID = 38;
|
public static final int leftFlywheelID = 38;
|
||||||
public static final int rightFlywheelID = 39;
|
public static final int rightFlywheelID = 39;
|
||||||
public static final int leftConveyorID = 40;
|
public static final int leftConveyorID = 40;
|
||||||
@@ -26,16 +26,7 @@ public final class Constants {
|
|||||||
public static final double flywheelReadyVelocityTolerance = 2.0;
|
public static final double flywheelReadyVelocityTolerance = 2.0;
|
||||||
public static final double flywheelReadyDelaySeconds = 0.5;
|
public static final double flywheelReadyDelaySeconds = 0.5;
|
||||||
|
|
||||||
// 距离(米) -> 飞轮电压(V) 射表。当前为占位点;
|
// Distance (meters) -> flywheel velocity (rotations per second).
|
||||||
// 真车试射后按实测数据加点即可,查表自动线性插值并在两端取边界值。
|
|
||||||
public static final InterpolatingDoubleTreeMap flywheelVoltageByDistance = new InterpolatingDoubleTreeMap();
|
|
||||||
static {
|
|
||||||
flywheelVoltageByDistance.put(1.2, 2.0);
|
|
||||||
flywheelVoltageByDistance.put(2.5, 2.1);
|
|
||||||
flywheelVoltageByDistance.put(3.5, 2.2);
|
|
||||||
flywheelVoltageByDistance.put(5.0, 2.3);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final InterpolatingDoubleTreeMap flywheelVelocityByDistance = new InterpolatingDoubleTreeMap();
|
public static final InterpolatingDoubleTreeMap flywheelVelocityByDistance = new InterpolatingDoubleTreeMap();
|
||||||
static {
|
static {
|
||||||
flywheelVelocityByDistance.put(1.2, 2.0 / flywheelNominalKv);
|
flywheelVelocityByDistance.put(1.2, 2.0 / flywheelNominalKv);
|
||||||
@@ -140,7 +131,7 @@ public final class Constants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Intaker {
|
public static class Intaker {
|
||||||
// 进球机构 CAN ID 同样是占位值,真实 ID 确认后集中在这里修改。
|
// Placeholder intake CAN IDs; update here after wiring is confirmed.
|
||||||
public static final int leftIntakeRollerID = 20;
|
public static final int leftIntakeRollerID = 20;
|
||||||
public static final int rightIntakeRollerID = 47;
|
public static final int rightIntakeRollerID = 47;
|
||||||
public static final int leftIntakeRotaterID = 48;
|
public static final int leftIntakeRotaterID = 48;
|
||||||
@@ -162,7 +153,7 @@ public final class Constants {
|
|||||||
.withKV(0.00).withKA(0.00).withKS(0.00);
|
.withKV(0.00).withKA(0.00).withKS(0.00);
|
||||||
|
|
||||||
public static final double IntakeGetterSpeedforAuto = 0.5;
|
public static final double IntakeGetterSpeedforAuto = 0.5;
|
||||||
// 这里给出可用的占位值,真车调好位置闭环后再收紧。
|
// Placeholder values; tighten after the real mechanism is tuned.
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Conveyor {
|
public static class Conveyor {
|
||||||
@@ -176,7 +167,7 @@ public final class Constants {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static class Superstructure {
|
public static class Superstructure {
|
||||||
// 状态机时间和门控容差。真车基础动作验证后,需要现场调这些值。
|
// State-machine timing and gate tolerances; tune on the real robot.
|
||||||
public static final double shooterFeedVoltage = Shooter.shooterConveyorFeedVoltage;
|
public static final double shooterFeedVoltage = Shooter.shooterConveyorFeedVoltage;
|
||||||
public static final double shooterReverseVoltage = Shooter.shooterConveyorReverseVoltage;
|
public static final double shooterReverseVoltage = Shooter.shooterConveyorReverseVoltage;
|
||||||
public static final double shooterFeedVelocity = Shooter.shooterConveyorFeedVelocity;
|
public static final double shooterFeedVelocity = Shooter.shooterConveyorFeedVelocity;
|
||||||
@@ -188,10 +179,10 @@ public final class Constants {
|
|||||||
public static final double passBallFlywheelVelocity = Shooter.defaultFlywheelVelocity;
|
public static final double passBallFlywheelVelocity = Shooter.defaultFlywheelVelocity;
|
||||||
public static final double passBallBackboardPosition = 175.0;
|
public static final double passBallBackboardPosition = 175.0;
|
||||||
|
|
||||||
// 射击时背板的目标位置(外接编码器计数)。
|
// Shoot backboard target position in external encoder counts.
|
||||||
public static final double backboardShootPosition = 175.0;
|
public static final double backboardShootPosition = 175.0;
|
||||||
public static final double backboardReadyPositionTolerance = 100.0;
|
public static final double backboardReadyPositionTolerance = 100.0;
|
||||||
// 射击门控是否要求底盘接近静止。
|
// Whether the shooting gate requires the drivetrain to be nearly still.
|
||||||
public static final boolean stationaryGateEnabled = true;
|
public static final boolean stationaryGateEnabled = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -77,9 +77,9 @@ public class RobotContainer {
|
|||||||
private final DriveGainsTuner driveGainsTuner = new DriveGainsTuner(drivetrain);
|
private final DriveGainsTuner driveGainsTuner = new DriveGainsTuner(drivetrain);
|
||||||
private final GameData2026 gameData2026 = new GameData2026();
|
private final GameData2026 gameData2026 = new GameData2026();
|
||||||
private ConfigTalonFXMotorTuner configFlywheelTuner =
|
private ConfigTalonFXMotorTuner configFlywheelTuner =
|
||||||
new ConfigTalonFXMotorTuner(shooterSubsystem.leftFlywheel, "flywheel", Constants.Shooter.flyWheelSlot0Configs);
|
new ConfigTalonFXMotorTuner(shooterSubsystem.leftFlywheel, "flywheel", Constants.Shooter.flyWheelSlot0Configs, false);
|
||||||
private ConfigTalonFXMotorTuner configConveyorTuner =
|
private ConfigTalonFXMotorTuner configConveyorTuner =
|
||||||
new ConfigTalonFXMotorTuner(shooterSubsystem.leftConveyor, "conveyor", Constants.Shooter.conveyorSlot0Configs);
|
new ConfigTalonFXMotorTuner(shooterSubsystem.leftConveyor, "conveyor", Constants.Shooter.conveyorSlot0Configs, false);
|
||||||
private ConfigTalonFXSMotorTuner configBackboardTuner =
|
private ConfigTalonFXSMotorTuner configBackboardTuner =
|
||||||
new ConfigTalonFXSMotorTuner(shooterSubsystem.backboardMotor, "backboard", Constants.Shooter.backboardSlot0Configs);
|
new ConfigTalonFXSMotorTuner(shooterSubsystem.backboardMotor, "backboard", Constants.Shooter.backboardSlot0Configs);
|
||||||
private ConfigTalonFXMotorTuner configMainConveyorTuner =
|
private ConfigTalonFXMotorTuner configMainConveyorTuner =
|
||||||
|
|||||||
@@ -6,10 +6,10 @@ import edu.wpi.first.wpilibj2.command.SubsystemBase;
|
|||||||
import frc.robot.Constants;
|
import frc.robot.Constants;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 对现有 LimelightHelpers 的薄只读封装。
|
* Thin read-only wrapper around the existing LimelightHelpers.
|
||||||
*
|
*
|
||||||
* 本类不做视觉融合,也不控制任何机构;只给 Superstructure 提供稳定的
|
* This subsystem does not fuse vision or command mechanisms; it only gives
|
||||||
* 目标和距离读取接口。
|
* Superstructure stable target and distance read APIs.
|
||||||
*/
|
*/
|
||||||
public class LimelightSubsystem extends SubsystemBase {
|
public class LimelightSubsystem extends SubsystemBase {
|
||||||
private final String limelightName;
|
private final String limelightName;
|
||||||
@@ -35,8 +35,8 @@ public class LimelightSubsystem extends SubsystemBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public double getDistanceToTarget() {
|
public double getDistanceToTarget() {
|
||||||
// DriveControls 已经把基于场地位姿计算的距离发布到 AutoControl;
|
// DriveControls publishes the field-pose distance under AutoControl.
|
||||||
// 这里复用该值,保留旧定位和目标计算逻辑。
|
// Reuse that value to preserve the existing target calculation path.
|
||||||
return NetworkTableInstance.getDefault()
|
return NetworkTableInstance.getDefault()
|
||||||
.getTable("AutoControl")
|
.getTable("AutoControl")
|
||||||
.getEntry("distanceToHub")
|
.getEntry("distanceToHub")
|
||||||
@@ -47,11 +47,6 @@ public class LimelightSubsystem extends SubsystemBase {
|
|||||||
return LimelightHelpers.getBotPoseEstimate_wpiBlue_MegaTag2(limelightName).pose;
|
return LimelightHelpers.getBotPoseEstimate_wpiBlue_MegaTag2(limelightName).pose;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getShooterVoltageByDistance() {
|
|
||||||
// 查 Constants 里的插值射表;真车试射后往表里加实测点即可。
|
|
||||||
return Constants.Shooter.flywheelVoltageByDistance.get(getDistanceToTarget());
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getShooterVelocityByDistance() {
|
public double getShooterVelocityByDistance() {
|
||||||
return Constants.Shooter.flywheelVelocityByDistance.get(getDistanceToTarget());
|
return Constants.Shooter.flywheelVelocityByDistance.get(getDistanceToTarget());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -136,11 +136,6 @@ public class ShooterSubsystem extends SubsystemBase {
|
|||||||
rightFlywheel.getConfigurator().apply(configs);
|
rightFlywheel.getConfigurator().apply(configs);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlywheelVoltage(double outputVolts) {
|
|
||||||
double clampedOutputVolts = MathUtil.clamp(outputVolts, -12.0, 12.0);
|
|
||||||
setFlywheelVelocity(clampedOutputVolts / Constants.Shooter.flywheelNominalKv);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFlywheelVelocity(double targetVelocityRps) {
|
public void setFlywheelVelocity(double targetVelocityRps) {
|
||||||
double clampedTargetVelocity = MathUtil.clamp(
|
double clampedTargetVelocity = MathUtil.clamp(
|
||||||
targetVelocityRps,
|
targetVelocityRps,
|
||||||
@@ -155,15 +150,6 @@ public class ShooterSubsystem extends SubsystemBase {
|
|||||||
setRightFlywheelFollowLeft();
|
setRightFlywheelFollowLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlywheelVoltageByDistance(double distance) {
|
|
||||||
setFlywheelVelocityByDistance(distance);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFlywheelVelocityByDistance(double distance) {
|
|
||||||
double targetVelocity = Constants.Shooter.flywheelVelocityByDistance.get(distance);
|
|
||||||
setFlywheelVelocity(targetVelocity);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopFlywheel() {
|
public void stopFlywheel() {
|
||||||
setFlywheelVelocity(0.0);
|
setFlywheelVelocity(0.0);
|
||||||
}
|
}
|
||||||
@@ -181,9 +167,6 @@ public class ShooterSubsystem extends SubsystemBase {
|
|||||||
>= Constants.Shooter.flywheelReadyDelaySeconds;
|
>= Constants.Shooter.flywheelReadyDelaySeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean atVoltage() {
|
|
||||||
return atVelocity();
|
|
||||||
}
|
|
||||||
public double getLeftFlywheelVelocity() {
|
public double getLeftFlywheelVelocity() {
|
||||||
return leftFlywheel.getVelocity().getValueAsDouble();
|
return leftFlywheel.getVelocity().getValueAsDouble();
|
||||||
}
|
}
|
||||||
@@ -208,10 +191,6 @@ public class ShooterSubsystem extends SubsystemBase {
|
|||||||
return Math.abs(flywheelTargetVelocity) - getAverageFlywheelVelocity();
|
return Math.abs(flywheelTargetVelocity) - getAverageFlywheelVelocity();
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getTargetFlywheelVoltage() {
|
|
||||||
return flywheelTargetVelocity * Constants.Shooter.flywheelNominalKv;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ====================== */
|
/* ====================== */
|
||||||
/* shooter conveyor */
|
/* shooter conveyor */
|
||||||
/* ====================== */
|
/* ====================== */
|
||||||
@@ -226,11 +205,6 @@ public class ShooterSubsystem extends SubsystemBase {
|
|||||||
setRightConveyorFollowLeft();
|
setRightConveyorFollowLeft();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void runShooterConveyorVoltage(double outputVolts) {
|
|
||||||
double clampedOutputVolts = MathUtil.clamp(outputVolts, -12.0, 12.0);
|
|
||||||
runShooterConveyorVelocity(clampedOutputVolts / Constants.Shooter.shooterConveyorNominalKv);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void stopShooterConveyor() {
|
public void stopShooterConveyor() {
|
||||||
runShooterConveyorVelocity(0.0);
|
runShooterConveyorVelocity(0.0);
|
||||||
}
|
}
|
||||||
@@ -369,17 +343,13 @@ public class ShooterSubsystem extends SubsystemBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFlywheelTuningControlActive() {
|
public boolean isFlywheelTuningControlActive() {
|
||||||
boolean voltageTunerEnabled = flywheelTuningTable.getEntry("flywheelEnable").getBoolean(false);
|
|
||||||
boolean voltageTunerRunning = flywheelTuningTable.getEntry("flywheelEnableRunning").getBoolean(false);
|
|
||||||
boolean velocityTunerEnabled = flywheelTuningTable.getEntry("flywheelVelocityEnable").getBoolean(false);
|
boolean velocityTunerEnabled = flywheelTuningTable.getEntry("flywheelVelocityEnable").getBoolean(false);
|
||||||
return (voltageTunerEnabled && voltageTunerRunning) || velocityTunerEnabled;
|
return velocityTunerEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShooterConveyorTuningControlActive() {
|
public boolean isShooterConveyorTuningControlActive() {
|
||||||
boolean voltageTunerEnabled = conveyorTuningTable.getEntry("conveyorEnable").getBoolean(false);
|
|
||||||
boolean voltageTunerRunning = conveyorTuningTable.getEntry("conveyorEnableRunning").getBoolean(false);
|
|
||||||
boolean velocityTunerEnabled = conveyorTuningTable.getEntry("conveyorVelocityEnable").getBoolean(false);
|
boolean velocityTunerEnabled = conveyorTuningTable.getEntry("conveyorVelocityEnable").getBoolean(false);
|
||||||
return (voltageTunerEnabled && voltageTunerRunning) || velocityTunerEnabled;
|
return velocityTunerEnabled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetbackboardencoder() {
|
public void resetbackboardencoder() {
|
||||||
@@ -490,9 +460,7 @@ public class ShooterSubsystem extends SubsystemBase {
|
|||||||
shooterNetworkTable.getEntry("flywheelAtVelocity").setBoolean(atVelocity());
|
shooterNetworkTable.getEntry("flywheelAtVelocity").setBoolean(atVelocity());
|
||||||
shooterNetworkTable.getEntry("flywheelVelocityTuningActive").setBoolean(flywheelVelocityTuningActive);
|
shooterNetworkTable.getEntry("flywheelVelocityTuningActive").setBoolean(flywheelVelocityTuningActive);
|
||||||
shooterNetworkTable.getEntry("flywheelFollowerOpposed").setBoolean(true);
|
shooterNetworkTable.getEntry("flywheelFollowerOpposed").setBoolean(true);
|
||||||
shooterNetworkTable.getEntry("flywheelTargetVoltage").setDouble(getTargetFlywheelVoltage());
|
|
||||||
shooterNetworkTable.getEntry("flywheelOutputVolts").setDouble(flywheelOutputVolts);
|
shooterNetworkTable.getEntry("flywheelOutputVolts").setDouble(flywheelOutputVolts);
|
||||||
shooterNetworkTable.getEntry("flywheelAtVoltage").setBoolean(atVoltage());
|
|
||||||
shooterNetworkTable.getEntry("leftFlywheelOutputVolts").setDouble(leftFlywheel.getMotorVoltage().getValueAsDouble());
|
shooterNetworkTable.getEntry("leftFlywheelOutputVolts").setDouble(leftFlywheel.getMotorVoltage().getValueAsDouble());
|
||||||
shooterNetworkTable.getEntry("rightFlywheelOutputVolts").setDouble(rightFlywheel.getMotorVoltage().getValueAsDouble());
|
shooterNetworkTable.getEntry("rightFlywheelOutputVolts").setDouble(rightFlywheel.getMotorVoltage().getValueAsDouble());
|
||||||
shooterNetworkTable.getEntry("leftFlywheelStatorCurrent").setDouble(leftFlywheel.getStatorCurrent().getValueAsDouble());
|
shooterNetworkTable.getEntry("leftFlywheelStatorCurrent").setDouble(leftFlywheel.getStatorCurrent().getValueAsDouble());
|
||||||
|
|||||||
@@ -396,7 +396,6 @@ public class Superstructure extends SubsystemBase {
|
|||||||
table.getEntry("timeInState").setDouble(timeInState());
|
table.getEntry("timeInState").setDouble(timeInState());
|
||||||
table.getEntry("canShoot").setBoolean(canShoot());
|
table.getEntry("canShoot").setBoolean(canShoot());
|
||||||
table.getEntry("shooterAtVelocity").setBoolean(shooter.atVelocity());
|
table.getEntry("shooterAtVelocity").setBoolean(shooter.atVelocity());
|
||||||
table.getEntry("shooterAtVoltage").setBoolean(shooter.atVoltage());
|
|
||||||
table.getEntry("driveAimed").setBoolean(drive.isAimed());
|
table.getEntry("driveAimed").setBoolean(drive.isAimed());
|
||||||
table.getEntry("driveHeadingError").setDouble(drive.getHeadingError());
|
table.getEntry("driveHeadingError").setDouble(drive.getHeadingError());
|
||||||
table.getEntry("driveStationary").setBoolean(isDriveStationary());
|
table.getEntry("driveStationary").setBoolean(isDriveStationary());
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ public class ConfigTalonFXMotorTuner {
|
|||||||
private final String motorName;
|
private final String motorName;
|
||||||
private final Slot0Configs motorSlot0Configs;
|
private final Slot0Configs motorSlot0Configs;
|
||||||
private final NetworkTable table;
|
private final NetworkTable table;
|
||||||
|
private final boolean voltageRunEnabled;
|
||||||
|
|
||||||
// ---- Subscribers:读取 Elastic 改过的新值 ----
|
// ---- Subscribers:读取 Elastic 改过的新值 ----
|
||||||
private final BooleanSubscriber enableSub;
|
private final BooleanSubscriber enableSub;
|
||||||
@@ -27,9 +28,19 @@ public class ConfigTalonFXMotorTuner {
|
|||||||
|
|
||||||
private final VoltageOut voltageRequest = new VoltageOut(0);
|
private final VoltageOut voltageRequest = new VoltageOut(0);
|
||||||
public ConfigTalonFXMotorTuner(TalonFX motor_, String motorName_, Slot0Configs motorSlot0Configs_) {
|
public ConfigTalonFXMotorTuner(TalonFX motor_, String motorName_, Slot0Configs motorSlot0Configs_) {
|
||||||
|
this(motor_, motorName_, motorSlot0Configs_, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConfigTalonFXMotorTuner(
|
||||||
|
TalonFX motor_,
|
||||||
|
String motorName_,
|
||||||
|
Slot0Configs motorSlot0Configs_,
|
||||||
|
boolean voltageRunEnabled_
|
||||||
|
) {
|
||||||
this.motor = motor_;
|
this.motor = motor_;
|
||||||
this.motorName = motorName_;
|
this.motorName = motorName_;
|
||||||
this.motorSlot0Configs = motorSlot0Configs_;
|
this.motorSlot0Configs = motorSlot0Configs_;
|
||||||
|
this.voltageRunEnabled = voltageRunEnabled_;
|
||||||
|
|
||||||
this.table = NetworkTableInstance.getDefault().getTable("Tuning/" + motorName);
|
this.table = NetworkTableInstance.getDefault().getTable("Tuning/" + motorName);
|
||||||
|
|
||||||
@@ -41,8 +52,10 @@ public class ConfigTalonFXMotorTuner {
|
|||||||
table.getDoubleTopic(motorName+"kA").publish().set(motorSlot0Configs.kA);
|
table.getDoubleTopic(motorName+"kA").publish().set(motorSlot0Configs.kA);
|
||||||
table.getDoubleTopic(motorName+"kS").publish().set(motorSlot0Configs.kS);
|
table.getDoubleTopic(motorName+"kS").publish().set(motorSlot0Configs.kS);
|
||||||
|
|
||||||
table.getBooleanTopic(motorName+"EnableRunning").publish().set(false);;
|
if (voltageRunEnabled) {
|
||||||
table.getDoubleTopic(motorName+"RunningVolts").publish().set(0);;
|
table.getBooleanTopic(motorName+"EnableRunning").publish().set(false);;
|
||||||
|
table.getDoubleTopic(motorName+"RunningVolts").publish().set(0);;
|
||||||
|
}
|
||||||
|
|
||||||
this.enableSub = table.getBooleanTopic(motorName+"Enable").subscribe(false);
|
this.enableSub = table.getBooleanTopic(motorName+"Enable").subscribe(false);
|
||||||
this.KpSub = table.getDoubleTopic(motorName+"kP").subscribe(motorSlot0Configs.kP);
|
this.KpSub = table.getDoubleTopic(motorName+"kP").subscribe(motorSlot0Configs.kP);
|
||||||
@@ -51,8 +64,12 @@ public class ConfigTalonFXMotorTuner {
|
|||||||
this.KvSub = table.getDoubleTopic(motorName+"kV").subscribe(motorSlot0Configs.kV);
|
this.KvSub = table.getDoubleTopic(motorName+"kV").subscribe(motorSlot0Configs.kV);
|
||||||
this.KaSub = table.getDoubleTopic(motorName+"kA").subscribe(motorSlot0Configs.kA);
|
this.KaSub = table.getDoubleTopic(motorName+"kA").subscribe(motorSlot0Configs.kA);
|
||||||
this.KsSub = table.getDoubleTopic(motorName+"kS").subscribe(motorSlot0Configs.kS);
|
this.KsSub = table.getDoubleTopic(motorName+"kS").subscribe(motorSlot0Configs.kS);
|
||||||
this.enableRuningSub = table.getBooleanTopic(motorName+"EnableRunning").subscribe(false);
|
this.enableRuningSub = voltageRunEnabled
|
||||||
this.runningVolts = table.getDoubleTopic(motorName+"RunningVolts").subscribe(0);
|
? table.getBooleanTopic(motorName+"EnableRunning").subscribe(false)
|
||||||
|
: null;
|
||||||
|
this.runningVolts = voltageRunEnabled
|
||||||
|
? table.getDoubleTopic(motorName+"RunningVolts").subscribe(0)
|
||||||
|
: null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void periodic(Runnable func) {
|
public void periodic(Runnable func) {
|
||||||
@@ -79,7 +96,7 @@ public class ConfigTalonFXMotorTuner {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (enableRuningSub.get()) {;
|
if (voltageRunEnabled && enableRuningSub.get()) {;
|
||||||
double volts = MathUtil.clamp(runningVolts.get(), -12.0, 12.0);
|
double volts = MathUtil.clamp(runningVolts.get(), -12.0, 12.0);
|
||||||
motor.setControl(voltageRequest.withOutput(volts));
|
motor.setControl(voltageRequest.withOutput(volts));
|
||||||
wasRunning = true;
|
wasRunning = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user