generated from Frc5572/Java-Template
-
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.
- Loading branch information
1 parent
b8f3689
commit 39ada7d
Showing
2 changed files
with
54 additions
and
1 deletion.
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
37 changes: 37 additions & 0 deletions
37
src/main/java/frc/robot/subsystems/elevator_wrist/ElevatorWristIOSim.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 |
---|---|---|
@@ -1,5 +1,42 @@ | ||
package frc.robot.subsystems.elevator_wrist; | ||
|
||
import org.littletonrobotics.junction.LoggedRobot; | ||
import edu.wpi.first.math.system.plant.DCMotor; | ||
import edu.wpi.first.math.util.Units; | ||
import edu.wpi.first.wpilibj.Encoder; | ||
import edu.wpi.first.wpilibj.simulation.EncoderSim; | ||
import edu.wpi.first.wpilibj.simulation.SingleJointedArmSim; | ||
import frc.robot.Constants; | ||
import frc.robot.RobotContainer; | ||
|
||
public class ElevatorWristIOSim implements ElevatorWristIO { | ||
Check warning on line 12 in src/main/java/frc/robot/subsystems/elevator_wrist/ElevatorWristIOSim.java GitHub Actions / Linting
|
||
|
||
private final DCMotor wrist = DCMotor.getNEO(1); | ||
private final Encoder m_encoder = new Encoder(0, 1); | ||
// Simulation classes help us simulate what's going on, including gravity. | ||
// This arm sim represents an arm that can travel from -75 degrees (rotated down front) | ||
// to 255 degrees (rotated down in the back). | ||
private final SingleJointedArmSim m_armSim = new SingleJointedArmSim(wrist, 60.0, | ||
SingleJointedArmSim.estimateMOI(Units.inchesToMeters(12), 8.0), Units.inchesToMeters(12), | ||
Constants.ElevatorWristConstants.SetPoints.MIN_ANGLE.getRadians(), | ||
Constants.ElevatorWristConstants.SetPoints.MAX_ANGLE.getRadians(), true, 0.0); | ||
private final EncoderSim m_encoderSim = new EncoderSim(m_encoder); | ||
|
||
public ElevatorWristIOSim() { | ||
|
||
} | ||
|
||
@Override | ||
public void updateInputs(ElevatorWristInputs inputs) { | ||
m_armSim.update(LoggedRobot.defaultPeriodSecs); | ||
m_encoderSim.setDistance(m_armSim.getAngleRads()); | ||
RobotContainer.m_wrist.setAngle(Units.radiansToDegrees(m_armSim.getAngleRads())); | ||
inputs.wristAbsoluteEncRawValue = Units.radiansToRotations(m_encoderSim.getDistance()); | ||
} | ||
|
||
@Override | ||
public void setWristVoltage(double v) { | ||
m_armSim.setInputVoltage(v); | ||
} | ||
|
||
} |