TankDrive

This class is the standard Tank drive class that controls two sets of parallel motors while integrating the RoadRunner v1.0 library in BunyipsLib.

Since

6.0.0

Constructors

Link copied to clipboard
constructor(@NonNull driveModel: DriveModel, @NonNull motionProfile: MotionProfile, @NonNull tankGains: TankGains, @NonNull leftMotors: List<DcMotor>, @NonNull rightMotors: List<DcMotor>, @NonNull lazyImu: LazyImu, @NonNull voltageSensorMapping: HardwareMap.DeviceMapping<VoltageSensor>, @NonNull startPose: Pose2d)
Create a new TankDrive.
constructor(@NonNull driveModel: DriveModel, @NonNull motionProfile: MotionProfile, @NonNull tankGains: TankGains, @NonNull leftMotors: List<DcMotor>, @NonNull rightMotors: List<DcMotor>, @NonNull lazyImu: LazyImu, @NonNull voltageSensorMapping: HardwareMap.DeviceMapping<VoltageSensor>)
Create a new TankDrive that will start at the last known pose.

Types

Link copied to clipboard
A task that will execute a RoadRunner trajectory on a Tank drive.
Link copied to clipboard
inner class TurnTask : Task
A task that will execute a motion-profiled turn on a Tank drive using RoadRunner.

Properties

Link copied to clipboard
Link copied to clipboard
Gains used for tank drive control.
Link copied to clipboard

Inherited properties

Link copied to clipboard
open var currentTask: Task
Link copied to clipboard
protected open var name: String
Reference to the unmodified name of this subsystem.
Link copied to clipboard
Get a reference to the currently running BunyipsOpMode.

Functions

Link copied to clipboard
The constants object represents all configuration options required for creating a RoadRunner trajectory.
Link copied to clipboard
Get the raw power for each side of the robot.
Link copied to clipboard
open fun getPose(): Pose2d
Calculate the accumulated pose from an internal localizer.
Link copied to clipboard
open fun getVelocity(): PoseVelocity2d
Calculate the first derivative of the accumulated pose from an internal localizer.
Link copied to clipboard
protected open fun onDisable()
User callback that runs once when this subsystem is disabled by a call to disable or by an assertion failure.
Link copied to clipboard
open fun periodic()
To be updated periodically on every hardware loop.
Link copied to clipboard
open fun setMotorPowers(leftPower: Double, rightPower: Double)
Set the raw power for each side of the robot.
Link copied to clipboard
open fun setPose(@NonNull newPose: Pose2d)
Reset the accumulated pose estimate to this pose.
Link copied to clipboard
open fun setPower(@NonNull target: PoseVelocity2d)
Set the current commanded state of the robot in the Robot Coordinate System.
Link copied to clipboard
Set the pose accumulator this drive instance should use.
Link copied to clipboard
Set the Localizer this drive instance should use.

Inherited functions

Link copied to clipboard
protected fun assertParamsNotNull(@NonNull parameters: Array<Any>): Boolean
Utility function to run NullSafety.assertComponentArgs() on the given parameters, usually on the motors/hardware/critical objects passed into the constructor.
Link copied to clipboard
Cancel the current task immediately and return to the default task, if available.
Link copied to clipboard
infix fun BunyipsSubsystem.default(defaultTask: Task)

Default task setter extension for BunyipsSubsystem to set the default task of a subsystem.

Link copied to clipboard
protected fun delegate(@NonNull child: BunyipsSubsystem)
Call to delegate the update of this subsystem, usually a component of another subsystem, to this subsystem.
Link copied to clipboard
fun disable()
Prevent a subsystem from running.
Link copied to clipboard
fun enable()
Re-enable a subsystem if it was previously disabled via a disable() call.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Determine if the subsystem is idle, meaning an IdleTask is running.
Link copied to clipboard
Begin building a RoadRunner trajectory from the last-known robot position when this method is called.
open fun makeTrajectory(@NonNull startPose: Pose2d): TaskBuilder
open fun makeTrajectory(@NonNull startPose: Pose2d, @NonNull poseMap: PoseMap): TaskBuilder
open fun makeTrajectory(@NonNull startVec: Vector2d, @NonNull distUnit: Distance, ang: Double, @NonNull angUnit: Angle): TaskBuilder
open fun makeTrajectory(@NonNull startVec: Vector2d, @NonNull distUnit: Distance, ang: Double, @NonNull angUnit: Angle, @NonNull poseMap: PoseMap): TaskBuilder
Begin building a RoadRunner trajectory from the supplied pose when this method is called.
open fun makeTrajectory(@NonNull poseMap: PoseMap): TaskBuilder
Begin building a RoadRunner trajectory from the inverse (PoseMap piped) last-known robot position when this method is called.
Link copied to clipboard
protected open fun onEnable()
User callback that runs once when this subsystem is enabled by a call to enable or the first active call to periodic.
Link copied to clipboard
protected fun opMode(@NonNull ifRunning: Consumer<BunyipsOpMode>)
Null check consumer for the opMode field which will no-op the given consumer if an active BunyipsOpMode is not present (i.e.
Link copied to clipboard
protected fun require(@Nullable nullableOpMode: BunyipsOpMode): BunyipsOpMode
Null assertion for the opMode field which throws a NullPointerException if an active BunyipsOpMode is not present (i.e.
Link copied to clipboard
open fun resetForOpMode()
Reset stored static instances of BunyipsSubsystem.
Link copied to clipboard
fun setDefaultTask(@NonNull defaultTask: Task)
Set the default task for this subsystem, which will be run when no other task is running.
Link copied to clipboard
Set the current task to the given task, overriding any current task.
Link copied to clipboard
open fun setPose(@NonNull vector: Vector2d, @NonNull vectorUnit: Distance, heading: Double, @NonNull headingUnit: Angle)
Reset the accumulated pose estimate to this pose.
Link copied to clipboard
fun startThread(@NonNull loopSleepDuration: Measure<Time>)
Call to delegate all updates of this subsystem to a thread that will begin execution on this method call.
Link copied to clipboard
Call to stop delegating updates of this subsystem to a thread.
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun update()
Update the subsystem and run the current task, if tasks are not set up this will just call periodic.
Link copied to clipboard
open fun updateAll()
Update all instances of BunyipsSubsystem that has been constructed since the last clearing.
Link copied to clipboard
fun <T : BunyipsSubsystem?> withName(@NonNull subsystemName: String): T
Set the name of this subsystem that will be used in telemetry and references.