Package com.pathplanner.lib.config
Class RobotConfig
java.lang.Object
com.pathplanner.lib.config.RobotConfig
Configuration class describing everything that needs to be known about the robot to generate
trajectories
-
Field Summary
Modifier and TypeFieldDescriptionfinal boolean
Is the robot holonomic?final double
The mass of the robot, including bumpers and battery, in KGfinal double
The maximum torque a drive module can apply without slipping the wheelsfinal ModuleConfig
The drive module configfinal Translation2d[]
Robot-relative locations of each drive module in metersfinal double[]
The distance from the robot center to each module in metersfinal double
The moment of inertia of the robot, in KG*M^2final int
Number of drive modulesfinal double
The force of static friction between the robot's drive wheels and the carpet, in Newtons -
Constructor Summary
ConstructorDescriptionRobotConfig
(double massKG, double MOI, ModuleConfig moduleConfig, double trackwidthMeters) Create a robot config object for a DIFFERENTIAL DRIVE robotRobotConfig
(double massKG, double MOI, ModuleConfig moduleConfig, double trackwidthMeters, double wheelbaseMeters) Create a robot config object for a HOLONOMIC DRIVE robotRobotConfig
(edu.wpi.first.units.measure.Mass mass, edu.wpi.first.units.measure.MomentOfInertia MOI, ModuleConfig moduleConfig, edu.wpi.first.units.measure.Distance trackwidthMeters) Create a robot config object for a DIFFERENTIAL DRIVE robotRobotConfig
(edu.wpi.first.units.measure.Mass mass, edu.wpi.first.units.measure.MomentOfInertia MOI, ModuleConfig moduleConfig, edu.wpi.first.units.measure.Distance trackwidthMeters, edu.wpi.first.units.measure.Distance wheelbaseMeters) Create a robot config object for a HOLONOMIC DRIVE robot -
Method Summary
Modifier and TypeMethodDescriptionchassisForcesToWheelForceVectors
(ChassisSpeeds chassisForces) Convert chassis forces (passed as ChassisSpeeds) to individual wheel force vectorsstatic RobotConfig
Load the robot config from the shared settings file created by the GUItoChassisSpeeds
(SwerveModuleState[] states) Convert an array of swerve module states to robot-relative chassis speeds.toSwerveModuleStates
(ChassisSpeeds speeds) Convert robot-relative chassis speeds to an array of swerve module states.
-
Field Details
-
massKG
public final double massKGThe mass of the robot, including bumpers and battery, in KG -
MOI
public final double MOIThe moment of inertia of the robot, in KG*M^2 -
moduleConfig
The drive module config -
moduleLocations
Robot-relative locations of each drive module in meters -
isHolonomic
public final boolean isHolonomicIs the robot holonomic? -
numModules
public final int numModulesNumber of drive modules -
modulePivotDistance
public final double[] modulePivotDistanceThe distance from the robot center to each module in meters -
wheelFrictionForce
public final double wheelFrictionForceThe force of static friction between the robot's drive wheels and the carpet, in Newtons -
maxTorqueFriction
public final double maxTorqueFrictionThe maximum torque a drive module can apply without slipping the wheels
-
-
Constructor Details
-
RobotConfig
public RobotConfig(double massKG, double MOI, ModuleConfig moduleConfig, double trackwidthMeters, double wheelbaseMeters) Create a robot config object for a HOLONOMIC DRIVE robot- Parameters:
massKG
- The mass of the robot, including bumpers and battery, in KGMOI
- The moment of inertia of the robot, in KG*M^2moduleConfig
- The drive module configtrackwidthMeters
- The distance between the left and right side of the drivetrain, in meterswheelbaseMeters
- The distance between the front and back side of the drivetrain, in meters
-
RobotConfig
public RobotConfig(edu.wpi.first.units.measure.Mass mass, edu.wpi.first.units.measure.MomentOfInertia MOI, ModuleConfig moduleConfig, edu.wpi.first.units.measure.Distance trackwidthMeters, edu.wpi.first.units.measure.Distance wheelbaseMeters) Create a robot config object for a HOLONOMIC DRIVE robot- Parameters:
mass
- The mass of the robot, including bumpers and batteryMOI
- The moment of inertia of the robotmoduleConfig
- The drive module configtrackwidthMeters
- The distance between the left and right side of the drivetrainwheelbaseMeters
- The distance between the front and back side of the drivetrain
-
RobotConfig
Create a robot config object for a DIFFERENTIAL DRIVE robot- Parameters:
massKG
- The mass of the robot, including bumpers and battery, in KGMOI
- The moment of inertia of the robot, in KG*M^2moduleConfig
- The drive module configtrackwidthMeters
- The distance between the left and right side of the drivetrain, in meters
-
RobotConfig
public RobotConfig(edu.wpi.first.units.measure.Mass mass, edu.wpi.first.units.measure.MomentOfInertia MOI, ModuleConfig moduleConfig, edu.wpi.first.units.measure.Distance trackwidthMeters) Create a robot config object for a DIFFERENTIAL DRIVE robot- Parameters:
mass
- The mass of the robot, including bumpers and batteryMOI
- The moment of inertia of the robotmoduleConfig
- The drive module configtrackwidthMeters
- The distance between the left and right side of the drivetrain
-
-
Method Details
-
toSwerveModuleStates
Convert robot-relative chassis speeds to an array of swerve module states. This will use differential kinematics for diff drive robots, then convert the wheel speeds to module states.- Parameters:
speeds
- Robot-relative chassis speeds- Returns:
- Array of swerve module states
-
toChassisSpeeds
Convert an array of swerve module states to robot-relative chassis speeds. This will use differential kinematics for diff drive robots.- Parameters:
states
- Array of swerve module states- Returns:
- Robot-relative chassis speeds
-
chassisForcesToWheelForceVectors
Convert chassis forces (passed as ChassisSpeeds) to individual wheel force vectors- Parameters:
chassisForces
- The linear X/Y force and torque acting on the whole robot- Returns:
- Array of individual wheel force vectors
-
fromGUISettings
public static RobotConfig fromGUISettings() throws IOException, org.json.simple.parser.ParseExceptionLoad the robot config from the shared settings file created by the GUI- Returns:
- RobotConfig matching the robot settings in the GUI
- Throws:
IOException
- if an I/O error occursorg.json.simple.parser.ParseException
- if a JSON parsing error occurs
-