Package trclib.command
Class CmdPidDrive
java.lang.Object
trclib.command.CmdPidDrive
- All Implemented Interfaces:
TrcRobot.RobotCommand
This class implements a generic PID control drive command. It is agnostic to the PID controller sensors.
The caller provides the PID drive object that has all PID controllers which means the caller controls
what sensors are controlling the X, Y and turn PID controllers. For example, the caller can provide a PID
drive object that uses the encoders to control the X and Y PID controllers and a gyro for the turn PID
controller. The caller can also use the encoders to control the X and Y PID controllers but a camera to
control the turn PID controller.
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final TrcDashboardprivate doubleprivate final TrcDriveBaseprivate final TrcEventprivate final Stringprivate final doubleprivate final doubleprivate final doubleprivate intprivate TrcPose2D[]private final TrcPidDriveprivate TrcPidController.PidCoefficientsprivate Booleanprivate Booleanprivate final TrcStateMachine<CmdPidDrive.State>private final TrcTimerprivate final TrcDbgTraceprivate TrcPidControllerprivate final TrcPidControllerprivate final booleanprivate final TrcPidControllerprivate final TrcPidController -
Constructor Summary
ConstructorsConstructorDescriptionCmdPidDrive(TrcDriveBase driveBase, TrcPidDrive pidDrive) Constructor: Create an instance of the object.CmdPidDrive(TrcDriveBase driveBase, TrcPidDrive pidDrive, boolean useSensorOdometry) Constructor: Create an instance of the object. -
Method Summary
Modifier and TypeMethodDescriptionvoidcancel()This method cancels the command if it is active.booleancmdPeriodic(double elapsedTime) This method must be called periodically by the caller to drive the command sequence forward.booleanisActive()This method checks if the current RobotCommand is running.voidstart(double delay, double drivePowerLimit, TrcPidController.PidCoefficients tunePidCoeff, TrcPose2D... pathPoints) This method starts the specified PID drive run.
-
Field Details
-
moduleName
-
dashboard
-
tracer
-
driveBase
-
pidDrive
-
useSensorOdometry
private final boolean useSensorOdometry -
event
-
timer
-
sm
-
xPidCtrl
-
yPidCtrl
-
turnPidCtrl
-
oldXOutputLimit
private final double oldXOutputLimit -
oldYOutputLimit
private final double oldYOutputLimit -
oldTurnOutputLimit
private final double oldTurnOutputLimit -
delay
private double delay -
pathPoints
-
pathIndex
private int pathIndex -
tunePidCtrl
-
savedPidCoeffs
-
savedTargetIsAbsolute
-
savedWarpSpaceEnabled
-
-
Constructor Details
-
CmdPidDrive
Constructor: Create an instance of the object.- Parameters:
driveBase- specifies the drive base object.pidDrive- specifies the PID drive object to be used for PID controlled drive.useSensorOdometry- specifies true to use the sensor odometry, false to use drive base odometry.
-
CmdPidDrive
Constructor: Create an instance of the object.- Parameters:
driveBase- specifies the drive base object.pidDrive- specifies the PID drive object to be used for PID controlled drive.
-
-
Method Details
-
start
public void start(double delay, double drivePowerLimit, TrcPidController.PidCoefficients tunePidCoeff, TrcPose2D... pathPoints) This method starts the specified PID drive run.- Parameters:
delay- specifies delay in seconds before PID drive starts. 0 means no delay.drivePowerLimit- specifies the power limit to be applied for the PID controlled drive.tunePidCoeff- specifies PID coefficients for tuning PID controllers, can be null if not in tune mode.pathPoints- specifies one or more points on the path.
-
isActive
public boolean isActive()This method checks if the current RobotCommand is running.- Specified by:
isActivein interfaceTrcRobot.RobotCommand- Returns:
- true if the command is running, false otherwise.
-
cancel
public void cancel()This method cancels the command if it is active.- Specified by:
cancelin interfaceTrcRobot.RobotCommand
-
cmdPeriodic
public boolean cmdPeriodic(double elapsedTime) This method must be called periodically by the caller to drive the command sequence forward.- Specified by:
cmdPeriodicin interfaceTrcRobot.RobotCommand- Parameters:
elapsedTime- specifies the elapsed time in seconds since the start of the robot mode.- Returns:
- true if the command sequence is completed, false otherwise.
-