Skip to content

Pivot motor: add gravity compensation and auto-zero on enable#528

Open
phurley67 wants to merge 1 commit into
mainfrom
fix/pivot-gravity-comp
Open

Pivot motor: add gravity compensation and auto-zero on enable#528
phurley67 wants to merge 1 commit into
mainfrom
fix/pivot-gravity-comp

Conversation

@phurley67

@phurley67 phurley67 commented Apr 6, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add gravity compensation (kG = -0.15) to the collector pivot motor config. Previously kG was defined as 0 and never actually applied to the motor, so only the P-term fought gravity -- causing arm sag, excess current draw, and stalling near the target position.
  • Auto-zero the pivot on first enable by initializing pivotZeroed = false (was true) and stowZero = true (was false). The motor encoder reads 0 at power-on regardless of physical arm position, so skipping zeroing caused unpredictable behavior.

Test plan

  • Enable the robot and confirm the pivot runs its zeroing routine toward the stow hard stop on first enable
  • Deploy the collector pivot and verify it holds position without visible sag
  • Monitor pivot motor temperature over several minutes of use -- should run cooler than before
  • Tune PIVOT_KG value if needed: more negative if arm sags, less negative if arm drifts up
  • Verify that manually requesting zeroing via NetworkTables (deploy and stow) still works

🤖 Generated with Claude Code

Closes #527

kG was set to 0 and never applied to motor config, so only the P-term
fought gravity. Also start pivotZeroed=false so zeroing runs on first
enable, and default toward stow for safety.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copilot AI review requested due to automatic review settings April 6, 2026 01:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Updates the Collector pivot motor configuration and startup behavior to improve holding performance and ensure a deterministic encoder reference by applying gravity feedforward and forcing a zeroing routine on first enable.

Changes:

  • Add a non-zero kG (gravity compensation) constant and apply it to the pivot motor Slot0 configuration.
  • Change startup defaults so the pivot auto-zeros on first enable, zeroing toward the stow hard stop by default.

// Gravity compensation voltage. Negative = upward force (same convention
// as Hood kG). START LOW and increase until the arm holds position without
// sagging. If the arm drifts up, make the value less negative (closer to 0).
public static final double PIVOT_KG = RobotMap.IS_OASIS ? -0.15d : -0.15d; // tune me!

Copilot AI Apr 6, 2026

Copy link

Choose a reason for hiding this comment

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

The conditional on RobotMap.IS_OASIS is currently redundant because both branches use the same value (-0.15d). This adds noise and implies the constants may diverge when they don’t. Consider replacing with a single literal (or provide distinct tuned values per robot if that was the intent).

Suggested change
public static final double PIVOT_KG = RobotMap.IS_OASIS ? -0.15d : -0.15d; // tune me!
public static final double PIVOT_KG = -0.15d; // tune me!

Copilot uses AI. Check for mistakes.
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.

Pivot motor: add gravity compensation and auto-zero on enable

2 participants