Skip to content

deployable intake sim#71

Open
rafzip wants to merge 7 commits intomainfrom
deployable-intake
Open

deployable intake sim#71
rafzip wants to merge 7 commits intomainfrom
deployable-intake

Conversation

@rafzip
Copy link
Collaborator

@rafzip rafzip commented Jan 30, 2026

Mass properties are from last yr

@rafzip rafzip requested a review from LucienMorey January 30, 2026 09:18
@rafzip
Copy link
Collaborator Author

rafzip commented Jan 30, 2026

i cant use my laptop and didn't configure ruff

@rafzip
Copy link
Collaborator Author

rafzip commented Jan 30, 2026

nvm it's a conflict

DEPLOYED_ANGLE_UPPER = 3.892366 - ARM_ENCODER_OFFSET
RETRACTED_ANGLE = 4.610450 - ARM_ENCODER_OFFSET
ARM_LENGTH = 0.22 # meters
ARM_MOI = 0.181717788
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you measured this from the CAD yet?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no because its not cadded yet

@rafzip rafzip force-pushed the deployable-intake branch 2 times, most recently from 4b16689 to 907b7ad Compare January 31, 2026 01:03
@rafzip rafzip force-pushed the deployable-intake branch 2 times, most recently from b2cb3ed to 96dc64d Compare February 8, 2026 00:31
@rafzip
Copy link
Collaborator Author

rafzip commented Feb 8, 2026

pre-commit.ci autofix

@rafzip rafzip force-pushed the deployable-intake branch 2 times, most recently from 9a00844 to c7f4077 Compare February 8, 2026 04:22
@rafzip
Copy link
Collaborator Author

rafzip commented Feb 9, 2026

@greptileai

@greptile-apps
Copy link

greptile-apps bot commented Feb 9, 2026

Greptile Overview

Greptile Summary

Added intake arm motor control and simulation support to make the intake deployable. Major changes include:

  • Added Spark MAX motor controller for intake arm with PID control and absolute encoder feedback
  • Configured arm physics simulation with gravity using SingleJointedArmSim
  • Added simulation constants (MOI, arm length, angle limits) from last year's robot
  • Created Mechanism2d visualization ligament for the intake
  • Removed unused A-Frame and Wrist mechanism roots from robot initialization

Confidence Score: 4/5

  • Safe to merge with minor improvements possible
  • Code structure is solid with proper motor controller configuration and physics simulation. Multiple TODOs indicate values need tuning/verification (encoder gearing, PID values, simulation constants from last year) but these will be caught during testing. The visualization ligament could be updated but this doesn't affect functionality.
  • Pay attention to components/intake.py which has several TODO comments for values that need tuning/verification

Important Files Changed

Filename Overview
components/intake.py Added intake arm motor with Spark MAX controller, absolute encoder, PID control, and simulation constants - includes visualization ligament that isn't updated
physics.py Added intake arm physics simulation using SingleJointedArmSim with gravity - converts radians to rotations for encoder

Sequence Diagram

sequenceDiagram
    participant Robot
    participant IntakeComponent
    participant SparkMax
    participant AbsoluteEncoder
    participant PhysicsEngine
    participant SingleJointedArmSim
    
    Robot->>IntakeComponent: __init__(intake_mech_root)
    IntakeComponent->>SparkMax: Create arm_motor (ID 12)
    IntakeComponent->>SparkMax: Configure PID (0.005, 0.0, 0.0)
    IntakeComponent->>AbsoluteEncoder: Configure conversion factor
    IntakeComponent->>IntakeComponent: Create intake_ligament visualization
    
    Robot->>PhysicsEngine: __init__(robot)
    PhysicsEngine->>SingleJointedArmSim: Create arm simulation
    Note over SingleJointedArmSim: gear_ratio=24, MOI=0.181717788<br/>length=0.22m, with gravity
    
    loop Every robot cycle
        Robot->>IntakeComponent: execute()
        IntakeComponent->>SparkMax: Apply motor commands
        
        alt In Simulation
            PhysicsEngine->>SingleJointedArmSim: update(dt)
            SingleJointedArmSim->>SingleJointedArmSim: Calculate physics with gravity
            SingleJointedArmSim-->>PhysicsEngine: arm angle (radians)
            PhysicsEngine->>PhysicsEngine: Convert radians to rotations
            PhysicsEngine->>SparkMax: setPosition(arm_angle_rot)
            SparkMax->>AbsoluteEncoder: Update encoder position
        end
    end
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile

Comment on lines +34 to +35
self.intake_ligament = intake_mech_root.appendLigament(
"intake", length=0.25, angle=90, color=wpilib.Color8Bit(wpilib.Color.kGreen)
)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

consider updating intake_ligament.setAngle() in execute() to reflect the actual arm position in the Mechanism2d visualization (similar to how turret updates its sim_pointer)

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

Prompt To Fix With AI
This is a comment left during a code review.
Path: components/intake.py
Line: 34:36

Comment:
consider updating `intake_ligament.setAngle()` in `execute()` to reflect the actual arm position in the Mechanism2d visualization (similar to how turret updates its sim_pointer)

<sub>Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!</sub>

How can I resolve this? If you propose a fix, please make it concise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants