public class AnalogGyro extends GyroBase implements Gyro, PIDSource, LiveWindowSendable
This class is for gyro sensors that connect to an analog input.
Modifier and Type | Field and Description |
---|---|
protected AnalogInput |
m_analog |
kAnalogInputChannels, kAnalogOutputChannels, kDigitalChannels, kPCMModules, kPDPChannels, kPDPModules, kPwmChannels, kRelayChannels, kSolenoidChannels, kSystemClockTicksPerMicrosecond
Constructor and Description |
---|
AnalogGyro(AnalogInput channel)
Gyro constructor with a precreated analog channel object.
|
AnalogGyro(AnalogInput channel,
int center,
double offset)
Gyro constructor with a precreated analog channel object along with parameters for presetting
the center and offset values.
|
AnalogGyro(int channel)
Gyro constructor using the channel number
|
AnalogGyro(int channel,
int center,
double offset)
Gyro constructor using the channel number along with parameters for presetting the center and
offset values.
|
Modifier and Type | Method and Description |
---|---|
void |
calibrate()
Calibrate the gyro by running for a number of samples and computing the center value.
|
void |
free()
Delete (free) the accumulator and the analog components used for the gyro.
|
double |
getAngle()
Return the actual angle in degrees that the robot is currently facing.
|
int |
getCenter()
Return the gyro center value set during calibration to use as a future preset.
|
double |
getOffset()
Return the gyro offset value set during calibration to use as a future preset.
|
double |
getRate()
Return the rate of rotation of the gyro.
|
void |
initGyro()
Initialize the gyro.
|
void |
reset()
Reset the gyro.
|
void |
setSensitivity(double voltsPerDegreePerSecond)
Set the gyro sensitivity.
|
getPIDSourceType, getSmartDashboardType, getTable, initTable, pidGet, setPIDSourceType, startLiveWindowMode, stopLiveWindowMode, updateTable
checkAnalogInputChannel, checkAnalogOutputChannel, checkDigitalChannel, checkPDPChannel, checkPDPModule, checkPWMChannel, checkRelayChannel, checkSolenoidChannel, checkSolenoidModule, getDefaultSolenoidModule, setDefaultSolenoidModule
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getPIDSourceType, pidGet, setPIDSourceType
startLiveWindowMode, stopLiveWindowMode, updateTable
getSmartDashboardType, getTable, initTable
protected AnalogInput m_analog
public AnalogGyro(int channel)
channel
- The analog channel the gyro is connected to. Gyros can only be used on on-board
channels 0-1.public AnalogGyro(AnalogInput channel)
channel
- The AnalogInput object that the gyro is connected to. Gyros can only be used on
on-board channels 0-1.public AnalogGyro(int channel, int center, double offset)
channel
- The analog channel the gyro is connected to. Gyros can only be used on on-board
channels 0-1.center
- Preset uncalibrated value to use as the accumulator center value.offset
- Preset uncalibrated value to use as the gyro offset.public AnalogGyro(AnalogInput channel, int center, double offset)
channel
- The analog channel the gyro is connected to. Gyros can only be used on on-board
channels 0-1.center
- Preset uncalibrated value to use as the accumulator center value.offset
- Preset uncalibrated value to use as the gyro offset.public void initGyro()
public void calibrate()
Gyro
public void reset()
Gyro
public void free()
free
in interface Gyro
free
in class SensorBase
public double getAngle()
Gyro
The angle is based on the current accumulator value corrected by the oversampling rate, the gyro type and the A/D calibration values. The angle is continuous, that is it will continue from 360 to 361 degrees. This allows algorithms that wouldn't want to see a discontinuity in the gyro output as it sweeps past from 360 to 0 on the second time around.
This heading is based on integration of the returned rate from the gyro.
public double getRate()
Gyro
The rate is based on the most recent reading of the gyro analog value
public double getOffset()
public int getCenter()
public void setSensitivity(double voltsPerDegreePerSecond)
voltsPerDegreePerSecond
- The sensitivity in Volts/degree/second.