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.Accelerometer
accelerometer
protected edu.wpi.first.wpilibj.Encoder
backLeftEncoder
protected edu.wpi.first.wpilibj.Encoder
backRightEncoder
protected ChassisParameters
chassisParameters
protected long
dt
protected double
dtheta
protected double
dw
protected double
dx
protected double
dy
protected double
e1
protected double
e2
protected double
e3
protected edu.wpi.first.wpilibj.Encoder
frontLeftEncoder
protected edu.wpi.first.wpilibj.Encoder
frontRightEncoder
static double
GRAVITATIONAL_ACCELERATION
Acceleration due to gravity, in meters per second.protected edu.wpi.first.wpilibj.interfaces.Gyro
gyro
protected double
mudtheta
protected double
mudx
protected double
mudy
protected double
pAx
protected double
pAy
protected long
pt
protected double
ptheta
protected double
px
protected double
py
protected double
theta
protected double
theta0
protected long
time
protected double
vx
protected double
vy
protected double
w1
protected double
w2
protected double
w3
protected double
w4
protected double
x
protected double
y
-
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 void
defineResources()
Define the set of resourceLocks required for this Subsystem's task.Position
getEstimate()
Get the current estimate of the robot's on-field position.void
reset()
void
setInitialTheta(double theta0)
Set the initial rotation of the robot.void
task()
The background task to run.protected void
updateEstimate()
protected abstract void
updateSteerSpecificParameters()
protected void
updateTime()
-
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.Exception
The 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
-
-