|
22 | 22 | from wpimath.units import kilogram_square_meters |
23 | 23 |
|
24 | 24 | from components.chassis import SwerveModule |
| 25 | +from components.intake import IntakeComponent |
25 | 26 | from components.wrist import WristComponent |
26 | 27 | from utilities import game |
27 | 28 | from utilities.functions import constrain_angle |
@@ -139,6 +140,28 @@ def __init__(self, physics_controller: PhysicsInterface, robot: MyRobot): |
139 | 140 | ), |
140 | 141 | ] |
141 | 142 |
|
| 143 | + # Intake arm simulation |
| 144 | + intake_arm_gearbox = DCMotor.NEO(1) |
| 145 | + self.intake_arm_motor = rev.SparkMaxSim( |
| 146 | + robot.intake_component.arm_motor, intake_arm_gearbox |
| 147 | + ) |
| 148 | + self.intake_arm_encoder_sim = DutyCycleEncoderSim( |
| 149 | + robot.intake_component.encoder |
| 150 | + ) |
| 151 | + self.intake_arm = SparkArmSim( |
| 152 | + SingleJointedArmSim( |
| 153 | + intake_arm_gearbox, |
| 154 | + IntakeComponent.gear_ratio, |
| 155 | + moi=0.035579622, |
| 156 | + armLength=0.22, |
| 157 | + minAngle=IntakeComponent.DEPLOYED_ANGLE, |
| 158 | + maxAngle=IntakeComponent.RETRACTED_ANGLE, |
| 159 | + simulateGravity=True, |
| 160 | + startingAngle=IntakeComponent.RETRACTED_ANGLE, |
| 161 | + ), |
| 162 | + self.intake_arm_motor, |
| 163 | + ) |
| 164 | + |
142 | 165 | wrist_gearbox = DCMotor.NEO(1) |
143 | 166 | wrist_motor = rev.SparkMaxSim(robot.wrist.motor, wrist_gearbox) |
144 | 167 | self.wrist_encoder_sim = AnalogEncoderSim(robot.wrist.wrist_encoder) |
@@ -228,6 +251,10 @@ def update_sim(self, now: float, tm_diff: float) -> None: |
228 | 251 | self.vision_sim.update(self.physics_controller.get_pose()) |
229 | 252 | self.vision_sim_counter = 0 |
230 | 253 |
|
| 254 | + # Update intake arm simulation |
| 255 | + self.intake_arm.update(tm_diff) |
| 256 | + self.intake_arm_encoder_sim.set(self.intake_arm.mech_sim.getAngle()) |
| 257 | + |
231 | 258 | # Update wrist simulation |
232 | 259 | self.wrist.update(tm_diff) |
233 | 260 | self.wrist_encoder_sim.set( |
|
0 commit comments