Class AbstractPositionEstimator
- java.lang.Object
-
- ca.team3161.lib.robot.subsystem.AbstractSubsystem
-
- ca.team3161.lib.robot.subsystem.AbstractPooledSubsystem
-
- ca.team3161.lib.robot.subsystem.RepeatingPooledSubsystem
-
- ca.team3161.lib.robot.motion.tracking.AbstractPositionEstimator
-
- All Implemented Interfaces:
Subsystem
- Direct Known Subclasses:
MecanumPositionEstimator,SkidSteerPositionEstimator
public abstract class AbstractPositionEstimator extends RepeatingPooledSubsystem
Abstract parent for drivetrain-specific classes which integrate accelerometer, gyroscope, and encoder data in order to estimate total x, y distance travelled and degrees rotated by a robot.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class ca.team3161.lib.robot.subsystem.AbstractSubsystem
AbstractSubsystem.RunTask
-
-
Field Summary
Fields Modifier and Type Field Description protected edu.wpi.first.wpilibj.interfaces.Accelerometeraccelerometerprotected edu.wpi.first.wpilibj.EncoderbackLeftEncoderprotected edu.wpi.first.wpilibj.EncoderbackRightEncoderprotected ChassisParameterschassisParametersprotected longdtprotected doubledthetaprotected doubledwprotected doubledxprotected doubledyprotected doublee1protected doublee2protected doublee3protected edu.wpi.first.wpilibj.EncoderfrontLeftEncoderprotected edu.wpi.first.wpilibj.EncoderfrontRightEncoderstatic doubleGRAVITATIONAL_ACCELERATIONAcceleration due to gravity, in meters per second.protected edu.wpi.first.wpilibj.interfaces.Gyrogyroprotected doublemudthetaprotected doublemudxprotected doublemudyprotected doublepAxprotected doublepAyprotected longptprotected doublepthetaprotected doublepxprotected doublepyprotected doublethetaprotected doubletheta0protected longtimeprotected doublevxprotected doublevyprotected doublew1protected doublew2protected doublew3protected doublew4protected doublexprotected doubley-
Fields inherited from class ca.team3161.lib.robot.subsystem.AbstractSubsystem
job, resourceLocks, THREAD_PRIORITY
-
-
Constructor Summary
Constructors Constructor Description AbstractPositionEstimator(ChassisParameters chassisParameters, edu.wpi.first.wpilibj.interfaces.Accelerometer accelerometer, edu.wpi.first.wpilibj.interfaces.Gyro gyro, edu.wpi.first.wpilibj.Encoder frontLeftEncoder, edu.wpi.first.wpilibj.Encoder frontRightEncoder, edu.wpi.first.wpilibj.Encoder backLeftEncoder, edu.wpi.first.wpilibj.Encoder backRightEncoder)Construct a new PositionEstimator.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voiddefineResources()Define the set of resourceLocks required for this Subsystem's task.PositiongetEstimate()Get the current estimate of the robot's on-field position.voidreset()voidsetInitialTheta(double theta0)Set the initial rotation of the robot.voidtask()The background task to run.protected voidupdateEstimate()protected abstract voidupdateSteerSpecificParameters()protected voidupdateTime()-
Methods inherited from class ca.team3161.lib.robot.subsystem.RepeatingPooledSubsystem
isDone, start
-
Methods inherited from class ca.team3161.lib.robot.subsystem.AbstractPooledSubsystem
getExecutorService
-
Methods inherited from class ca.team3161.lib.robot.subsystem.AbstractSubsystem
acquireResources, cancel, getJob, isCancelled, isScheduled, isStarted, releaseResources, require
-
-
-
-
Field Detail
-
GRAVITATIONAL_ACCELERATION
public static final double GRAVITATIONAL_ACCELERATION
Acceleration due to gravity, in meters per second.- See Also:
- Constant Field Values
-
x
protected double x
-
y
protected double y
-
theta
protected double theta
-
theta0
protected double theta0
-
dx
protected double dx
-
dy
protected double dy
-
dtheta
protected double dtheta
-
px
protected double px
-
py
protected double py
-
ptheta
protected double ptheta
-
pAx
protected double pAx
-
pAy
protected double pAy
-
mudx
protected double mudx
-
mudy
protected double mudy
-
mudtheta
protected double mudtheta
-
time
protected long time
-
pt
protected long pt
-
dt
protected long dt
-
vx
protected double vx
-
vy
protected double vy
-
dw
protected double dw
-
e1
protected double e1
-
e2
protected double e2
-
e3
protected double e3
-
chassisParameters
protected final ChassisParameters chassisParameters
-
accelerometer
protected final edu.wpi.first.wpilibj.interfaces.Accelerometer accelerometer
-
gyro
protected final edu.wpi.first.wpilibj.interfaces.Gyro gyro
-
frontLeftEncoder
protected final edu.wpi.first.wpilibj.Encoder frontLeftEncoder
-
frontRightEncoder
protected final edu.wpi.first.wpilibj.Encoder frontRightEncoder
-
backLeftEncoder
protected final edu.wpi.first.wpilibj.Encoder backLeftEncoder
-
backRightEncoder
protected final edu.wpi.first.wpilibj.Encoder backRightEncoder
-
w1
protected double w1
-
w2
protected double w2
-
w3
protected double w3
-
w4
protected double w4
-
-
Constructor Detail
-
AbstractPositionEstimator
public AbstractPositionEstimator(ChassisParameters chassisParameters, edu.wpi.first.wpilibj.interfaces.Accelerometer accelerometer, edu.wpi.first.wpilibj.interfaces.Gyro gyro, edu.wpi.first.wpilibj.Encoder frontLeftEncoder, edu.wpi.first.wpilibj.Encoder frontRightEncoder, edu.wpi.first.wpilibj.Encoder backLeftEncoder, edu.wpi.first.wpilibj.Encoder backRightEncoder)
Construct a new PositionEstimator. Requires physical parameters of the robot and a collection of sensors from which to pull various data.- Parameters:
chassisParameters- physical parameters of the robotaccelerometer- an accelerometer to measure accelerationgyro- a gyroscope to measure rotationfrontLeftEncoder- an encoder to measure movement of the front left wheelfrontRightEncoder- an encoder to measure movement of the front right wheelbackLeftEncoder- an encoder to measure movement of the back left wheelbackRightEncoder- an encoder to measure movement of the back right wheel
-
-
Method Detail
-
setInitialTheta
public void setInitialTheta(double theta0)
Set the initial rotation of the robot. If the robot's initial heading is not to be interpreted as an angle of 0, use this method to set the correct offset (for example, if your robot begins matches rotated).- Parameters:
theta0- the initial angle
-
defineResources
public void defineResources()
Define the set of resourceLocks required for this Subsystem's task.- See Also:
AbstractSubsystem.require(Object)
-
task
public void task() throws java.lang.ExceptionThe background task to run.- Throws:
java.lang.Exception- in case the defined task throws any Exceptions
-
updateSteerSpecificParameters
protected abstract void updateSteerSpecificParameters()
-
updateTime
protected void updateTime()
-
updateEstimate
protected void updateEstimate()
-
reset
public void reset()
-
getEstimate
public Position getEstimate()
Get the current estimate of the robot's on-field position.- Returns:
- the position estimate
-
-