Class PathfinderConfig
- Direct Known Subclasses:
SimpleConfig
public class PathfinderConfig
extends java.lang.Object
All of these settings are incredibly important to how the pathfinder actually functions. If you're confused about why something isn't working, you should read through this file and make sure that you're aware of everything you're doing.
Hey! You! Yes, you. If you're reading this, trying to figure out what the hell is going wrong, you can feel free to shoot me an email on what's missing documentation. This project is designed to help people, not fry their brain.
- Since:
- 0.1.0
- Author:
- Colin Robertson
-
Field Summary
Fields Modifier and Type Field Description private boolean
driveInvertX
Should the X values be inverted?private boolean
driveInvertY
Should the Y values be inverted?private boolean
driveSwapXY
Should the pathfinder swap X and Y pairs?private int
fieldHeight
The height of the field.private int
fieldWidth
The height of the field.private Followers
follower
What type of follower does the pathfinder use?private double
gapX
The X distance, measured in inches, between the FR-FL pair of swerve modules.private double
gapY
The X distance, measured in inches, between the FR-BR pair of swerve modules.private Map
map
The field's map.private boolean
odometryInvertX
Should X values be inverted?private boolean
odometryInvertY
Should Y values be inverted?private boolean
odometrySwapXY
Should the pathfinder swap X and Y pairs?private RobotProfile
profile
The robot's motion file, used in motion profiling and planning.private Drive
rawDrive
The robot's drivetrain.private Odometry
rawOdometry
The rawOdometry subsystem that the robot uses.private double
robotX
The robot's X dimension.private double
robotY
The robot's Y dimension.private int
specificity
The field's "specificity" factor, which determines how double to integer conversions are handled.private double
speed
The speed that certain types of linear followers should run at.private boolean
usesFast
Should the pathfinder use the fast finder, or skip it entirely?private boolean
usesLightning
Should the pathfinder use the lightning finder, or skip it entirely?private boolean
usesThetaStar
Should the pathfinder use a theta star pathfinding algorithm?private Drive
wrappedDrive
Wrapper surrounding the robot's drive interface.private OdometryWrapper
wrappedOdometry
A wrapper that surrounds the inputted rawOdometry system. -
Constructor Summary
Constructors Constructor Description PathfinderConfig()
Create a newPathfinderConfig
without any configuration elements set.PathfinderConfig(Odometry rawOdometry, int fieldWidth, int fieldHeight, int specificity, double robotX, double robotY, double gapX, double gapY, RobotProfile profile, Drive rawDrive, Map map, Followers follower, double speed, boolean usesLightning, boolean usesFast, boolean usesThetaStar)
Create a new PathfinderConfig to be fed to a Pathfinder. -
Method Summary
Modifier and Type Method Description boolean
doesUseFast()
Does the pathfinder utilize fast finding?boolean
doesUseLightning()
Does the pathfinder utilize lightning finding?boolean
doesUseThetaStar()
Does the pathfinder utilize ThetaStar finding?boolean
driveInvertX()
Is the X coordinate inverted?void
driveInvertX(boolean invert)
Set the X coordinates to be inverted or not.boolean
driveInvertY()
Is the Y coordinate inverted?void
driveInvertY(boolean invert)
Set the Y coordinates to be inverted or not.boolean
driveSwapXY()
Are the X and Y coordinates swapped?void
driveSwapXY(boolean xy)
Swap the X and Y coordinate inputs.Drive
getDrive()
Get the robot's drivetrain.int
getFieldHeight()
Get the fieldHeight of the field.int
getFieldWidth()
Get the fieldWidth of the field.Followers
getFollowerType()
Get what type of follower the pathfinder uses.double
getGapX()
The robot's X gap.double
getGapY()
The robot's Y gap.Map
getMap()
Get the field's map.Odometry
getOdometry()
Get the rawOdometry system.RobotProfile
getProfile()
Get the robot's motion profile.Drive
getRawDrive()
Get the robot's raw drivetrain.Odometry
getRawOdometry()
double
getRobotX()
Get the robot's X value.double
getRobotY()
Get the robot's Y value.int
getSpecificity()
Get the field's specificity.double
getSpeed()
Get the speed that linear followers should run at.boolean
odometryInvertX()
Is the X coordinate inverted?void
odometryInvertX(boolean invert)
Set the X coordinates to be inverted or not.boolean
odometryInvertY()
Is the Y coordinate inverted?void
odometryInvertY(boolean invert)
Set the Y coordinates to be inverted or not.boolean
odometrySwapXY()
Are the X and Y coordinates swapped?void
odometrySwapXY(boolean xy)
Swap the X and Y coordinate inputs.void
setDrive(Drive drive)
PathfinderConfig
setFieldHeight(int fieldHeight)
PathfinderConfig
setFieldWidth(int fieldWidth)
PathfinderConfig
setFollower(Followers follower)
PathfinderConfig
setGapX(double gapX)
PathfinderConfig
setGapY(double gapY)
PathfinderConfig
setMap(Map map)
PathfinderConfig
setProfile(RobotProfile profile)
PathfinderConfig
setRawOdometry(Odometry rawOdometry)
PathfinderConfig
setRobotX(double robotX)
PathfinderConfig
setRobotY(double robotY)
PathfinderConfig
setSpecificity(int specificity)
void
setSpeed(double speed)
Set the speed that linear followers will be executed at.PathfinderConfig
setUsesFast(boolean usesFast)
PathfinderConfig
setUsesLightning(boolean usesLightning)
PathfinderConfig
setUsesThetaStar(boolean usesThetaStar)
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
rawOdometry
The rawOdometry subsystem that the robot uses.Obviously, this is pretty necessary for a pathfinder. If you don't have any rawOdometry, you can't keep track of where the robot is. And if you can't keep track of where the robot is, then how are you supposed to actually navigate anywhere?
-
wrappedOdometry
A wrapper that surrounds the inputted rawOdometry system. This field is automatically created on initialization of a configuration class and you don't have to worry about it. -
fieldHeight
private int fieldHeightThe height of the field.Ultimately, you're free to do whatever the hell you'd like - I could care less. However, for the sake of consistency, I'd suggest that all units of measurement be in inches unless otherwise specified.
- FRC Field Width: 323.25 inches
- FRC Field Height: 629.25 inches
- FTC Field Width: 144 inches
- FTC Field Height: 144 inches
-
fieldWidth
private int fieldWidthThe height of the field.Ultimately, you're free to do whatever the hell you'd like - I could care less. However, for the sake of consistency, I'd suggest that all units of measurement be in inches unless otherwise specified.
- FRC Field Width: 323.25 inches
- FRC Field Height: 629.25 inches
- FTC Field Width: 144 inches
- FTC Field Height: 144 inches
-
specificity
private int specificityThe field's "specificity" factor, which determines how double to integer conversions are handled.There aren't many rules for what this number can be - however, it has to be non-zero and greater than 0.
Higher specificity values provide more accuracy at the price of more expensive calculation operations. Lower specificity values provide less accuracy at the price of much faster calculations. Although I've yet to do any performance profiling on it...
-
Low width, low height, low specificity.
- Width: 128
- Height: 128
- Execution time: 113ms
-
High width, high height, low specificity.
- Width: 1024
- Height: 1024
- Execution time: 622ms
-
High width, high height, high specificity.
- Width: 2048
- Width: 2048
- Execution time: OutOfMemory exception...
My point is, choose a specificity value that doesn't hinder your performance all that much. For FTC, I use a specificity of 6. For FRC, I use a specificity of 2, because the field is so fucking big.
-
Low width, low height, low specificity.
-
robotX
private double robotXThe robot's X dimension.robotX and robotY are interchangeable - ultimately, the radius of the robot's "hit circle" is dependent on the hypotenuse of the X and Y values, so it doesn't really matter which is which.
Ultimately, you're free to do whatever the hell you'd like - I could care less. However, for the sake of consistency, I'd suggest that all units of measurement be in inches unless otherwise specified.
-
robotY
private double robotYThe robot's Y dimension.robotX and robotY are interchangeable - ultimately, the radius of the robot's "hit circle" is dependent on the hypotenuse of the X and Y values, so it doesn't really matter which is which.
Ultimately, you're free to do whatever the hell you'd like - I could care less. However, for the sake of consistency, I'd suggest that all units of measurement be in inches unless otherwise specified.
-
gapX
private double gapXThe X distance, measured in inches, between the FR-FL pair of swerve modules. This distance should be measured from the very center of the swerve module's rotational radius. -
gapY
private double gapYThe X distance, measured in inches, between the FR-BR pair of swerve modules. This distance should be measured from the very center of the swerve module's rotational radius. -
profile
The robot's motion file, used in motion profiling and planning.Out-of-the-box, Pathfinder is tuned to use a proportional integral derivative controller follower to follow a predefined path. In order to effectively optimize this follower, there are some coefficients that need to be known.
For more information regarding robot profiling, go click on the RobotProfile class. Here. A link, because I'm just so kind, right?
RobotProfile
-
rawDrive
The robot's drivetrain.Now, obviously, we both know that a wheeled robot needs to have wheels to move, right? In order to make the pathfinder able to control the robot and its movement, we have to give the pathfinder some interface to control the motors. This is that interface.
-
wrappedDrive
Wrapper surrounding the robot's drive interface. -
map
The field's map.Go read these JavaDocs if you're confused about what a map is.
Map
-
follower
What type of follower does the pathfinder use?All of the types of followers and information about them can be found right here. Or here. Or, actually, here. Just kidding, it's right here:
Followers
-
usesLightning
private boolean usesLightningShould the pathfinder use the lightning finder, or skip it entirely?Generally, using the lighting and fast followers is optimal, as the amount of time required to generate a path is reduced by quite a fair bit. However, if you'd prefer to not use the lightning generator, fear not - you don't have to.
-
usesFast
private boolean usesFastShould the pathfinder use the fast finder, or skip it entirely?Generally, using the lighting and fast followers is optimal, as the amount of time required to generate a path is reduced by quite a fair bit. However, if you'd prefer to not use the lightning generator, fear not - you don't have to.
-
usesThetaStar
private boolean usesThetaStarShould the pathfinder use a theta star pathfinding algorithm?If lighting and fast followers don't generate a path, this one is the fall-back. This pathfinder is slower, but will actually find a path, rather than just running quick potential collision detection.
-
speed
private double speedThe speed that certain types of linear followers should run at. -
odometrySwapXY
private boolean odometrySwapXYShould the pathfinder swap X and Y pairs? -
odometryInvertX
private boolean odometryInvertXShould X values be inverted? -
odometryInvertY
private boolean odometryInvertYShould Y values be inverted? -
driveSwapXY
private boolean driveSwapXYShould the pathfinder swap X and Y pairs? -
driveInvertX
private boolean driveInvertXShould the X values be inverted? -
driveInvertY
private boolean driveInvertYShould the Y values be inverted?
-
-
Constructor Details
-
PathfinderConfig
public PathfinderConfig()Create a newPathfinderConfig
without any configuration elements set. -
PathfinderConfig
public PathfinderConfig(Odometry rawOdometry, int fieldWidth, int fieldHeight, int specificity, double robotX, double robotY, double gapX, double gapY, RobotProfile profile, Drive rawDrive, Map map, Followers follower, double speed, boolean usesLightning, boolean usesFast, boolean usesThetaStar)Create a new PathfinderConfig to be fed to a Pathfinder.For your own sake - please go read the field descriptions in this Java file if you're confused about what any of these means. I've written out nice and long descriptions for everything, so there shouldn't be all that much confusion about what's going on.
- Parameters:
rawOdometry
- the rawOdometry subsystem that's used by the pathfinder in determining the robot's position. This rawOdometry system should be as accurate as possible and maintain contact with the ground at all times.fieldWidth
- the fieldWidth of the field, in whatever units you'd like. Although the units don't matter much, you need to be sure to keep the units consistent.fieldHeight
- the fieldHeight of the field, in whatever units you'd like. Although the units don't matter much, you need to be sure to keep the units consistent.specificity
- the field's specificity factor. Low specificity means lower precision. High specificity means higher precision. The higher the specificity value is, the longer paths will take to find and the more resources are needed on the host computer.robotX
- the robot's X dimension. X/Y are the same thing here. That's not to say that you shouldn't measure X and Y values - accuracy is still just as important as ever.robotY
- the robot's Y dimension. X/Y are the same thing here. That's not to say that you shouldn't measure X and Y values - accuracy is still just as important as ever.gapX
- the distance (in inches) between the pair of front right and front left wheel centers.gapY
- the distance (in inches) between the pair of front right and back right wheel centers.profile
- the robot's motion profiling profile. This profile should provide (at least somewhat accurate) info on the robot's motion in real life.rawDrive
- the robot's drivetrain. The drivetrain is (rather obviously) used to actually rawDrive the robot.map
- a virtual map of something. In most cases, this is a game field with all your different obstacles and what not.follower
- what type of follower the pathfinder uses.speed
- the speed that linear followers should run at.usesLightning
- see:usesLightning
usesFast
- see:usesFast
usesThetaStar
- see:usesThetaStar
-
-
Method Details
-
setFollower
-
setUsesLightning
-
setUsesFast
-
setUsesThetaStar
-
getFieldHeight
public int getFieldHeight()Get the fieldHeight of the field.- Returns:
- the field's fieldHeight.
-
setFieldHeight
-
getFieldWidth
public int getFieldWidth()Get the fieldWidth of the field.- Returns:
- the field's fieldWidth.
-
setFieldWidth
-
getSpecificity
public int getSpecificity()Get the field's specificity.- Returns:
- the field's specificity.
-
setSpecificity
-
getRobotX
public double getRobotX()Get the robot's X value.- Returns:
- the robot's X value.
-
setRobotX
-
getRobotY
public double getRobotY()Get the robot's Y value.- Returns:
- the robot's Y value.
-
setRobotY
-
getGapX
public double getGapX()The robot's X gap.- Returns:
- the robot's X gap.
-
setGapX
-
getGapY
public double getGapY()The robot's Y gap.- Returns:
- the robot's Y gap.
-
setGapY
-
getRawOdometry
-
getOdometry
Get the rawOdometry system.- Returns:
- the rawOdometry system.
-
setRawOdometry
-
getProfile
Get the robot's motion profile.- Returns:
- the robot's motion profile.
-
setProfile
-
getRawDrive
Get the robot's raw drivetrain.- Returns:
- the robot's raw drivetrain.
-
getDrive
Get the robot's drivetrain.- Returns:
- the robot's drivetrain.
-
setDrive
-
getMap
Get the field's map.- Returns:
- the field's map.
-
setMap
-
getFollowerType
Get what type of follower the pathfinder uses.- Returns:
- the pathfinder's follower type.
-
setSpeed
public void setSpeed(double speed)Set the speed that linear followers will be executed at.- Parameters:
speed
- the speed that linear followers will be executed at.
-
getSpeed
public double getSpeed()Get the speed that linear followers should run at.- Returns:
- the speed linear followers should run at.
-
doesUseLightning
public boolean doesUseLightning()Does the pathfinder utilize lightning finding?- Returns:
- whether or not the pathfinder utilizes x type of finding.
-
doesUseFast
public boolean doesUseFast()Does the pathfinder utilize fast finding?- Returns:
- whether or not the pathfinder utilizes x type of finding.
-
doesUseThetaStar
public boolean doesUseThetaStar()Does the pathfinder utilize ThetaStar finding?- Returns:
- whether or not the pathfinder utilizes x type of finding.
-
odometrySwapXY
public void odometrySwapXY(boolean xy)Swap the X and Y coordinate inputs. -
odometryInvertX
public void odometryInvertX(boolean invert)Set the X coordinates to be inverted or not. True = inverted, false = normal. -
odometryInvertY
public void odometryInvertY(boolean invert)Set the Y coordinates to be inverted or not. True = inverted, false = normal. -
odometrySwapXY
public boolean odometrySwapXY()Are the X and Y coordinates swapped? -
odometryInvertX
public boolean odometryInvertX()Is the X coordinate inverted? -
odometryInvertY
public boolean odometryInvertY()Is the Y coordinate inverted? -
driveSwapXY
public void driveSwapXY(boolean xy)Swap the X and Y coordinate inputs. -
driveInvertX
public void driveInvertX(boolean invert)Set the X coordinates to be inverted or not. True = inverted, false = normal. -
driveInvertY
public void driveInvertY(boolean invert)Set the Y coordinates to be inverted or not. True = inverted, false = normal. -
driveSwapXY
public boolean driveSwapXY()Are the X and Y coordinates swapped? -
driveInvertX
public boolean driveInvertX()Is the X coordinate inverted? -
driveInvertY
public boolean driveInvertY()Is the Y coordinate inverted?
-