Package edu.wpi.first.wpilibj.simulation
Class AnalogGyroSim
- java.lang.Object
-
- edu.wpi.first.wpilibj.simulation.AnalogGyroSim
-
public class AnalogGyroSim extends Object
Class to control a simulated analog gyro.
-
-
Constructor Summary
Constructors Constructor Description AnalogGyroSim(int channel)
Constructs from an analog input channel number.AnalogGyroSim(AnalogGyro gyro)
Constructs from an AnalogGyro object.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description double
getAngle()
Get the current angle of the gyro.boolean
getInitialized()
Check if the gyro is initialized.double
getRate()
Get the rate of angle change on this gyro.CallbackStore
registerAngleCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on the angle.CallbackStore
registerInitializedCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on whether the gyro is initialized.CallbackStore
registerRateCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on the rate.void
resetData()
Reset all simulation data for this object.void
setAngle(double angle)
Change the angle measured by the gyro.void
setInitialized(boolean initialized)
Set whether this gyro is initialized.void
setRate(double rate)
Change the rate of the gyro.
-
-
-
Constructor Detail
-
AnalogGyroSim
public AnalogGyroSim(AnalogGyro gyro)
Constructs from an AnalogGyro object.- Parameters:
gyro
- AnalogGyro to simulate
-
AnalogGyroSim
public AnalogGyroSim(int channel)
Constructs from an analog input channel number.- Parameters:
channel
- Channel number
-
-
Method Detail
-
registerAngleCallback
public CallbackStore registerAngleCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on the angle.- Parameters:
callback
- the callback that will be called whenever the angle changesinitialNotify
- if true, the callback will be run on the initial value- Returns:
- the
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getAngle
public double getAngle()
Get the current angle of the gyro.- Returns:
- the angle measured by the gyro
-
setAngle
public void setAngle(double angle)
Change the angle measured by the gyro.- Parameters:
angle
- the new value
-
registerRateCallback
public CallbackStore registerRateCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on the rate.- Parameters:
callback
- the callback that will be called whenever the rate changesinitialNotify
- if true, the callback will be run on the initial value- Returns:
- the
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getRate
public double getRate()
Get the rate of angle change on this gyro.- Returns:
- the rate
-
setRate
public void setRate(double rate)
Change the rate of the gyro.- Parameters:
rate
- the new rate
-
registerInitializedCallback
public CallbackStore registerInitializedCallback(NotifyCallback callback, boolean initialNotify)
Register a callback on whether the gyro is initialized.- Parameters:
callback
- the callback that will be called whenever the gyro is initializedinitialNotify
- if true, the callback will be run on the initial value- Returns:
- the
CallbackStore
object associated with this callback. Save a reference to this object so GC doesn't cancel the callback.
-
getInitialized
public boolean getInitialized()
Check if the gyro is initialized.- Returns:
- true if initialized
-
setInitialized
public void setInitialized(boolean initialized)
Set whether this gyro is initialized.- Parameters:
initialized
- the new value
-
resetData
public void resetData()
Reset all simulation data for this object.
-
-