Skip to main content

PathFactory

Path factory handles building pathweaver controllers for swerve drive this makes command specific controller changes easier.

Creating new Instance

Here we are creating a new Path Factory instance passing it the required parameters like Kinematics, consumer to update the pod states and x,y and theta gains along with maxVelocityMetersPerSecond, maxAccelerationMetersPerSecond.

First let's start with the kinmatics parameter what we are passing is WPIlib's SwerveDriveKinematics class which is responsible for converting ChassisSpeeds class which store's velocity values in x, y and theta to a SwerveModuleState array.

PathFactory m_pathFactory = new PathFactory(m_kinmatics, 
(state) -> m_base.setStates(state), x_gains,
y_gains, theta_gains,
maxVelocityMetersPerSecond, maxAccelerationMetersPerSecond);