Class ConstantEmulationParams
- java.lang.Object
-
- frc.robot.util.hyperdrive.emulation.ConstantEmulationParams
-
- All Implemented Interfaces:
IEmulateParams
public class ConstantEmulationParams extends java.lang.Object implements IEmulateParams
A set of parameters that Hyperdrive will use to drive the robot through a path. Default values can be accessed using#getDefaults(frc.robot.util.hyperdrive.util.Units.LENGTH)
If you wish to tune the parameters for your robot, use thePreferenceEmulationParams
class instead.
-
-
Constructor Summary
Constructors Constructor Description ConstantEmulationParams(double overturn, double minimumSpeed, double maximumSpeed, double positionalCorrectionInhibitor, double positionalCorrectionDistance, double coefficientOfStaticFriction, int pointSkipCount, int immediatePathSize, PIDFAConfig pidfaConfig)
Creates a new ConstantEmulationParams, describing the parameters that are to be followed as the robot emulates aPath
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getCoefficientOfStaticFriction()
Returns the approximate coefficient of static friction between the robot's wheels, and the surface that it is driving on.static ConstantEmulationParams
getDefaults(Units.LENGTH units, PIDFAConfig pidfaConfig)
Returns the default values for robots to use, in whatever unit is supplied.int
getImmediatePathSize()
Gets the number of points ahead of the robot (after the skipped points) that will be looked at to determine the robot's upcoming turns.double
getMaximumSpeed()
The maximum speed, in units PER SECOND that the robot can be going at any given time during the path emulation, and the speed that the robot will try to achieve during any straightaways.double
getMinimumSpeed()
The minimum speed, in units PER SECOND that the robot can be going at any given time during the path emulation.double
getOverturn()
Can also be called a turn inhibitor.PIDFAConfig
getPIDFAConfig()
Gets the robots PIDFA configuration, which contains the user-configurable kP, kI, kD, kF and acceleration values necessary to figure out what percent output to drive the motors at.int
getPointSkipCount()
Returns the number of points that are directly ahead of the robot that will be skipped by the path emulation algorithm.double
getPositionalCorrectionDistance()
Returns the minimum distance from the path that the robot must have in order to start correcting its position.double
getPositionalCorrectionInhibitor()
Returns the inhibitor for the robot's positional correction.
-
-
-
Constructor Detail
-
ConstantEmulationParams
public ConstantEmulationParams(double overturn, double minimumSpeed, double maximumSpeed, double positionalCorrectionInhibitor, double positionalCorrectionDistance, double coefficientOfStaticFriction, int pointSkipCount, int immediatePathSize, PIDFAConfig pidfaConfig)
Creates a new ConstantEmulationParams, describing the parameters that are to be followed as the robot emulates aPath
.- Parameters:
overturn
- Increases or decreases the magnitude of any future turn of thePath
by multiplying the turn by this amount.minimumSpeed
- The minimum speed of the robot at any time during thePath
maximumSpeed
- The maximum speed of the robot at any time during thePath
positionalCorrectionInhibitor
- Inhibits the robot from performing positional corrections during thePath
.positionalCorrectionDistance
- The minimuim distance off-course that the robot has to be to start correcting its position.coefficientOfStaticFriction
- The coefficient of static friction between the robot's wheels and the floor's surface. Lower values = slower turns.pointSkipCount
- The number of points ahead of the robot to ignore when making decisions about turns.immediatePathSize
- The number of points ahead of the robot (after pointSkipCount) to look at to make desicions about turns.pidfaConfig
- The PIDF and acceleration settings to use.
-
-
Method Detail
-
getOverturn
public double getOverturn()
Description copied from interface:IEmulateParams
Can also be called a turn inhibitor. The turn amount that the robot calculates will be multiplied by this value to get the final turn amount. If one finds that the robot consistently does not turn enough, this value should be increased.- Specified by:
getOverturn
in interfaceIEmulateParams
- Returns:
- The Path's "overturn" value. This value defaults to 1.2
-
getMinimumSpeed
public double getMinimumSpeed()
Description copied from interface:IEmulateParams
The minimum speed, in units PER SECOND that the robot can be going at any given time during the path emulation. No matter the tightness, the robot will always take any turn with at least this speed. This value is measured in units per second.- Specified by:
getMinimumSpeed
in interfaceIEmulateParams
- Returns:
- Minimum speed of the robot during emulation.
-
getMaximumSpeed
public double getMaximumSpeed()
Description copied from interface:IEmulateParams
The maximum speed, in units PER SECOND that the robot can be going at any given time during the path emulation, and the speed that the robot will try to achieve during any straightaways. This value must be greater than the minimum speed, and should be less than the robot's actual maximum speed.- Specified by:
getMaximumSpeed
in interfaceIEmulateParams
- Returns:
- Maximum speed of the robot during emulation.
-
getPositionalCorrectionInhibitor
public double getPositionalCorrectionInhibitor()
Description copied from interface:IEmulateParams
Returns the inhibitor for the robot's positional correction. The greater this value, the more the robot will try to remain exactly on the path that it is driving. Setting this value too high might result in the robot driving in a "wavy" pattern (turning left, then right, then left again, then right again, and so on). Setting this value too low might cause the robot to not correct itself enough when it veers off course. This value defaults to 0.025.- Specified by:
getPositionalCorrectionInhibitor
in interfaceIEmulateParams
- Returns:
- Positional correction inhbitor.
-
getPositionalCorrectionDistance
public double getPositionalCorrectionDistance()
Description copied from interface:IEmulateParams
Returns the minimum distance from the path that the robot must have in order to start correcting its position. This value is measured in the unit given to theHyperdrive
constructor.- Specified by:
getPositionalCorrectionDistance
in interfaceIEmulateParams
- Returns:
- Minimum distance in units for positional correction to activate.
-
getCoefficientOfStaticFriction
public double getCoefficientOfStaticFriction()
Description copied from interface:IEmulateParams
Returns the approximate coefficient of static friction between the robot's wheels, and the surface that it is driving on. This value can also be used to tune the speed that the robot takes its turns. The lower this value is, the slower it takes turns. The higher this value is, the faster it takes turns. This value defaults to 0.6.- Specified by:
getCoefficientOfStaticFriction
in interfaceIEmulateParams
- Returns:
- Coefficient of static friction between the robot's wheels and the floor's surface.
-
getPointSkipCount
public int getPointSkipCount()
Description copied from interface:IEmulateParams
Returns the number of points that are directly ahead of the robot that will be skipped by the path emulation algorithm. Some points ahead of the skipped points will then be used to determine how much the robot should turn. This ensures that the angle between the robot's trajectory and the point(s) ahead is true and not being made larger by a small distance from the robot to the point. This value defaults to 2, and likely will not need to be tuned.- Specified by:
getPointSkipCount
in interfaceIEmulateParams
- Returns:
- The number of points to skip emulating.
-
getImmediatePathSize
public int getImmediatePathSize()
Description copied from interface:IEmulateParams
Gets the number of points ahead of the robot (after the skipped points) that will be looked at to determine the robot's upcoming turns. A larger value will mean that the robot's path will be smoother than that of a path with a small value. A larger value will also cause the robot to start turning sooner than a path with a smaller value.- Specified by:
getImmediatePathSize
in interfaceIEmulateParams
- Returns:
- Number of points ahead of the robot to use to determine future turns.
-
getPIDFAConfig
public PIDFAConfig getPIDFAConfig()
Description copied from interface:IEmulateParams
Gets the robots PIDFA configuration, which contains the user-configurable kP, kI, kD, kF and acceleration values necessary to figure out what percent output to drive the motors at. If this method is being called from aPreferenceEmulationParams
, all of these values will be pulled from the Preferences table on the dashboard. If this method is being called from aConstantEmulationParams
, these values will be whatever they were initialized as.- Specified by:
getPIDFAConfig
in interfaceIEmulateParams
- Returns:
- PIDFA config.
-
getDefaults
public static ConstantEmulationParams getDefaults(Units.LENGTH units, PIDFAConfig pidfaConfig)
Returns the default values for robots to use, in whatever unit is supplied.- Parameters:
units
- The units of length that are being used.pidfaConfig
- The PIDFA config to use. There is no default value for this because defining default nonzero PID values could be dangerous.- Returns:
- A
ConstantEmulationParams
containing the default parameters for path driving.
-
-