Class Jointmodule

java.lang.Object
org.penguinempire.modules.Jointmodule

public class Jointmodule extends Object
Controls a robotic joint using a SparkMax motor controller with closed-loop position control.

The Jointmodule class provides functionality to control joint positions using both PID feedback and ArmFeedforward for gravity compensation. It's designed for robotic arm joints or similar rotational mechanisms that require precise position control.

Features:

  • Closed-loop position control using a SparkMax controller
  • Absolute encoder position feedback
  • Position wrapping for continuous rotation joints (0 to 2π radians)
  • ArmFeedforward integration for gravity compensation
  • SmartDashboard integration for live tuning of control parameters
  • Manual control capabilities for testing and calibration

The controller uses both PID for position error correction and feedforward to counteract predictable forces like gravity. Control parameters can be adjusted at runtime through SmartDashboard.

See Also:
  • ArmFeedforward
  • SparkMax
  • Constructor Details

    • Jointmodule

      public Jointmodule(String name, int motorID)
  • Method Details

    • setPosition

      public void setPosition(double position)
      Sets the target position for the joint.
      Parameters:
      position -
    • manualMove

      public void manualMove(double speed)
    • stopMotor

      public void stopMotor()
      Stops the motor immediately.
    • getPosition

      public double getPosition()
      Gets the current position of the joint.
      Returns:
    • hasReachedTarget

      public boolean hasReachedTarget(double tolerance)
      Checks if the joint has reached the target position within a specified tolerance.
      Parameters:
      tolerance -
      Returns:
    • WrapAngle

      public static double WrapAngle(double _angle)
      Wraps an angle to always be within [0, 2π] radians.
    • periodic

      public void periodic()