Class MeccanumState

java.lang.Object
me.wobblyyyy.pathfinder.kinematics.MeccanumState

public class MeccanumState
extends java.lang.Object
MeccanumState represents the state of a meccanum drivetrain, where each of the four wheels (colloquially internally referred to as "modules") contains a power value that should be applied to a physical drivetrain.

Some useful methods you might want to check out: normalize(double), normalize(), normalizeWithMax(), normalizeFromMaxUnderOne()

Since:
0.5.0
Author:
Colin Robertson
See Also:
MeccanumKinematics
  • Field Summary

    Fields
    Modifier and Type Field Description
    private ModuleState bl
    One of the internal module states.
    private ModuleState br
    One of the internal module states.
    private ModuleState fl
    One of the internal module states.
    private ModuleState fr
    One of the internal module states.
  • Constructor Summary

    Constructors
    Constructor Description
    MeccanumState​(double fl, double fr, double bl, double br)
    Create a new meccanum state.
    MeccanumState​(ModuleState fl, ModuleState fr, ModuleState bl, ModuleState br)
    Create a new meccanum state.
  • Method Summary

    Modifier and Type Method Description
    ModuleState bl()
    Get the back-left module state.
    double blPower()
    Get the back-left power value.
    ModuleState br()
    Get the back-right module state.
    double brPower()
    Get the back-right power value.
    ModuleState fl()
    Get the front-left module state.
    double flPower()
    Get the front-left power value.
    ModuleState fr()
    Get the front-right module state.
    double frPower()
    Get the front-right power value.
    double maxPower()
    Get the maximum power value in any of the module states.
    void normalize()
    Normalize each of the power values.
    void normalize​(double max)
    Normalize the power values of each of the module states in this instance of meccanum states.
    void normalizeFromMaxUnderOne()
    Normalize the power values of the meccanum state by capping the state's maximum power value at one (or the regular maximum).
    void normalizeWithMax()  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • fl

      private ModuleState fl
      One of the internal module states. Not externally settable.
    • fr

      private ModuleState fr
      One of the internal module states. Not externally settable.
    • bl

      private ModuleState bl
      One of the internal module states. Not externally settable.
    • br

      private ModuleState br
      One of the internal module states. Not externally settable.
  • Constructor Details

    • MeccanumState

      public MeccanumState​(ModuleState fl, ModuleState fr, ModuleState bl, ModuleState br)
      Create a new meccanum state.
      Parameters:
      fl - front-left power value.
      fr - front-right power value.
      bl - back-left power value.
      br - back-right power value.
    • MeccanumState

      public MeccanumState​(double fl, double fr, double bl, double br)
      Create a new meccanum state.
      Parameters:
      fl - front-left power value.
      fr - front-right power value.
      bl - back-left power value.
      br - back-right power value.
  • Method Details

    • flPower

      public double flPower()
      Get the front-left power value.
      Returns:
      the specified power value.
    • frPower

      public double frPower()
      Get the front-right power value.
      Returns:
      the specified power value.
    • blPower

      public double blPower()
      Get the back-left power value.
      Returns:
      the specified power value.
    • brPower

      public double brPower()
      Get the back-right power value.
      Returns:
      the specified power value.
    • fl

      public ModuleState fl()
      Get the front-left module state.
      Returns:
      the specified module state.
    • fr

      public ModuleState fr()
      Get the front-right module state.
      Returns:
      the specified module state.
    • bl

      public ModuleState bl()
      Get the back-left module state.
      Returns:
      the specified module state.
    • br

      public ModuleState br()
      Get the back-right module state.
      Returns:
      the specified module state.
    • maxPower

      public double maxPower()
      Get the maximum power value in any of the module states.
    • normalize

      public void normalize​(double max)
      Normalize the power values of each of the module states in this instance of meccanum states. This method works by ensuring that each of the power values are under the specified maximum. If they're not under the specified maximum, each of the power values will be scaled down so they remain proportional to eachother while fitting under the max.
      See Also:
      MeccanumStates#normalizeFromMaxUnderOne()
    • normalize

      public void normalize()
      Normalize each of the power values. This method calls another method - normalize(double) - with the default maximum of 1.0.
    • normalizeWithMax

      public void normalizeWithMax()
    • normalizeFromMaxUnderOne

      public void normalizeFromMaxUnderOne()
      Normalize the power values of the meccanum state by capping the state's maximum power value at one (or the regular maximum). This method will ensure that all of the power values fit within the range of (-1, 1), which is the range we most often want to use for controlling a drivetrain.