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 ModuleStateblOne of the internal module states.private ModuleStatebrOne of the internal module states.private ModuleStateflOne of the internal module states.private ModuleStatefrOne 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 ModuleStatebl()Get the back-left module state.doubleblPower()Get the back-left power value.ModuleStatebr()Get the back-right module state.doublebrPower()Get the back-right power value.ModuleStatefl()Get the front-left module state.doubleflPower()Get the front-left power value.ModuleStatefr()Get the front-right module state.doublefrPower()Get the front-right power value.doublemaxPower()Get the maximum power value in any of the module states.voidnormalize()Normalize each of the power values.voidnormalize(double max)Normalize the power values of each of the module states in this instance of meccanum states.voidnormalizeFromMaxUnderOne()Normalize the power values of the meccanum state by capping the state's maximum power value at one (or the regular maximum).voidnormalizeWithMax()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
fl
One of the internal module states. Not externally settable. -
fr
One of the internal module states. Not externally settable. -
bl
One of the internal module states. Not externally settable. -
br
One of the internal module states. Not externally settable.
-
-
Constructor Details
-
MeccanumState
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
Get the front-left module state.- Returns:
- the specified module state.
-
fr
Get the front-right module state.- Returns:
- the specified module state.
-
bl
Get the back-left module state.- Returns:
- the specified module state.
-
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.
-