added code for new drum shooter prototype#114
Conversation
| intakeExtension = new IntakeExtension(new IntakeExtensionIOSim()); | ||
| intakeRoller = new IntakeRoller(new IntakeRollerIOSim()); | ||
|
|
||
| // todo fix sim code |
There was a problem hiding this comment.
This comment is a bit vague. Could you improve the comment to say more?
There was a problem hiding this comment.
Thanks for all the comments, I updated to add sim code for shooter and kicker
spderman3333
left a comment
There was a problem hiding this comment.
This seems alright for now, though the names of the motors should be more descriptive, else it will be impossible to tweak individual motors.
| public AngularVelocity motorRotationalVelocity = RotationsPerSecond.of(0); | ||
| public Current motorStatorCurrent = Amps.of(0); | ||
| public Current motorSupplyCurrent = Amps.of(0); | ||
| public Voltage motor1Voltage = Volts.of(0); |
There was a problem hiding this comment.
Please name the motors based on their position (when looking at the robot from behind it). I.e: upperLeftMotor, lowerRightMotor, etc.
|
|
||
| public class KickerIOReal implements KickerIO { | ||
| private final TalonFX motor; | ||
| private final TalonFX motor1; |
There was a problem hiding this comment.
Please rename these motors so they are more descriptive, and also append kicker to the front. (So it becomes uppperKickerMotor, and lowerKickerMotor.)
| private final FlywheelSim flywheelSim; | ||
| private final TalonFX motor; | ||
|
|
||
| public KickerIOSim() { | ||
| motor = new TalonFX(Constants.KICKER_MOTOR_ID); | ||
| flywheelSim = | ||
| new FlywheelSim( | ||
| LinearSystemId.createFlywheelSystem( | ||
| DCMotor.getKrakenX60(1), | ||
| KickerConstants.KICKER_SIM_MOI.in( | ||
| KilogramSquareMeters), // "Moment of Inertia" taken from OnShape. | ||
| KickerConstants.KICKER_MOTOR_TO_FLYWHEEL_GEARING), | ||
| DCMotor.getKrakenX60(1)); | ||
| } | ||
|
|
||
| @Override | ||
| public void setMotorVoltage(Voltage kickerMotorVoltage) { | ||
| double volts = kickerMotorVoltage.in(Volts); | ||
| motor.setVoltage(volts); | ||
| flywheelSim.setInputVoltage(volts); | ||
| } | ||
|
|
||
| @Override | ||
| public void updateState(KickerIOInputs inputs) { | ||
| updateSimulation(); | ||
|
|
||
| inputs.motorVoltage = motor.getMotorVoltage().getValue(); | ||
| inputs.motorRotationalVelocity = motor.getVelocity().getValue(); | ||
| inputs.motorStatorCurrent = motor.getStatorCurrent().getValue(); | ||
| inputs.motorSupplyCurrent = motor.getSupplyCurrent().getValue(); | ||
| } | ||
|
|
||
| private void updateSimulation() { | ||
| flywheelSim.update(Constants.SIM_TIME_PERIOD); | ||
|
|
||
| TalonFXSimState simState = motor.getSimState(); | ||
| simState.setRotorAcceleration(flywheelSim.getAngularAcceleration()); | ||
| simState.setRotorVelocity(flywheelSim.getAngularVelocity()); | ||
| simState.setSupplyVoltage(Volts.of(12)); | ||
| } | ||
|
|
||
| @Override | ||
| public void close() { | ||
| motor.close(); |
There was a problem hiding this comment.
Please dont delete the sim code.
| @@ -15,6 +15,12 @@ class KickerConstants { | |||
| static final String RESIST_FUEL_PREFERENCE_NT = "Kicker/RESIST_FUEL_VOLTAGE"; | |||
|
|
|||
| static final TalonFXConfiguration KICKER_MOTOR_CONFIG = | |||
There was a problem hiding this comment.
More descriptive name here (i.e. UPPER_KICKER_MOTOR_CONFIG).
| new MotorOutputConfigs().withInverted(InvertedValue.CounterClockwise_Positive)) | ||
| .withCurrentLimits(new CurrentLimitsConfigs().withStatorCurrentLimit(Amps.of(35))); | ||
|
|
||
| static final TalonFXConfiguration KICKER_MOTOR_2_CONFIG = |
| inputs.motor1Current = motor1.getStatorCurrent().getValue(); | ||
|
|
||
| inputs.motor2Voltage = motor2.getMotorVoltage().getValue(); | ||
| inputs.motor2RotationalVelocity = motor2.getVelocity().getValue(); |
There was a problem hiding this comment.
Make sure to update the motor names here too.
| @@ -59,7 +69,17 @@ public class ShooterConstants { | |||
| .withStatorCurrentLimit(Amps.of(70)) | |||
| .withSupplyCurrentLimit(50)); | |||
|
|
|||
| public static final TalonFXConfiguration FOLLOWER_SHOOTER_MOTOR_CONFIG = | |||
| public static final TalonFXConfiguration SHOOTER_MOTOR_3_CONFIG = | |||
| new TalonFXConfiguration() | |||
| .withMotorOutput(new MotorOutputConfigs().withInverted(InvertedValue.CounterClockwise_Positive)) | |||
| .withSlot0( | |||
| new Slot0Configs().withKS(0.099892).withKV(0.115).withKA(0.0020241).withKP(0.026743)) | |||
| .withCurrentLimits( | |||
| new CurrentLimitsConfigs() | |||
| .withStatorCurrentLimit(Amps.of(70)) | |||
| .withSupplyCurrentLimit(50)); | |||
|
|
|||
| public static final TalonFXConfiguration SHOOTER_MOTOR_4_CONFIG = | |||
There was a problem hiding this comment.
Please rename the configs so they are descriptive.
| public double shooterMotor1VoltageVolts = 0; | ||
| public double shooterMotor1AngleRotations = 0; | ||
| public double shooterMotor1RotPerSec = 0; | ||
| public double shooterMotor1CurrentAmps = 0; | ||
| public double shooter1SetpointRotsPerSec = 0; | ||
|
|
||
| public double shooterMotor2VoltageVolts = 0; | ||
| public double shooterMotor2AngleRotations = 0; | ||
| public double shooterMotor2RotPerSec = 0; | ||
| public double shooterMotor2CurrentAmps = 0; | ||
| public double shooter2SetpointRotsPerSec = 0; | ||
|
|
||
| public double shooterMotor3VoltageVolts = 0; | ||
| public double shooterMotor3AngleRotations = 0; | ||
| public double shooterMotor3RotPerSec = 0; | ||
| public double shooterMotor3CurrentAmps = 0; | ||
| public double shooter3SetpointRotsPerSec = 0; | ||
|
|
||
| public double shooterMotor4VoltageVolts = 0; | ||
| public double shooterMotor4AngleRotations = 0; | ||
| public double shooterMotor4RotPerSec = 0; | ||
| public double shooterMotor4CurrentAmps = 0; | ||
| public double shooter4SetpointRotsPerSec = 0; |
There was a problem hiding this comment.
More descriptive names here too please.
There was a problem hiding this comment.
I think you get the point, (more descriptive names).
Prototype code for drum shooter don't merge main