edu.wpi.first.wpilibj.smartdashboard
Class SendableGyro

java.lang.Object
  extended by edu.wpi.first.wpilibj.SensorBase
      extended by edu.wpi.first.wpilibj.Gyro
          extended by edu.wpi.first.wpilibj.smartdashboard.SendableGyro
All Implemented Interfaces:
IDevice, ISensor, PIDSource, SmartDashboardData, FrcBotSimComponent

public class SendableGyro
extends Gyro
implements SmartDashboardData

The SendableGyro class behaves exactly the same as a Gyro except that it also implements SmartDashboardData so that it can be sent over to the SmartDashboard.

Author:
Joe Grinstead

Field Summary
 
Fields inherited from class edu.wpi.first.wpilibj.SensorBase
kAnalogChannels, kAnalogModules, kDigitalChannels, kPwmChannels, kRelayChannels, kSolenoidChannels, kSolenoidModules, kSystemClockTicksPerMicrosecond, n_simProperties
 
Constructor Summary
SendableGyro(AnalogChannel channel)
          Gyro constructor with a precreated analog channel object.
SendableGyro(int channel)
          Gyro constructor with only a channel.
SendableGyro(int moduleNumber, int channel)
          Gyro constructor given a module and a channel.
 
Method Summary
 double getAngle()
          Return the actual angle in degrees that the robot is currently facing.
 NetworkTable getTable()
          Returns the NetworkTable associated with the data.
 java.lang.String getType()
          Returns the type of the data.
 double getUpdatePeriod()
          Returns the period (in seconds) between updates to the SmartDashboard.
 void reset()
          Reset the gyro.
 void resetToAngle(double angle)
          Reset the gyro.
 void setUpdatePeriod(double period)
          Sets the time (in seconds) between updates to the SmartDashboard.
 
Methods inherited from class edu.wpi.first.wpilibj.Gyro
free, pidGet, setSensitivity
 
Methods inherited from class edu.wpi.first.wpilibj.SensorBase
checkAnalogChannel, checkAnalogModule, checkDigitalChannel, checkDigitalModule, checkPWMChannel, checkPWMModule, checkRelayChannel, checkRelayModule, checkSolenoidChannel, checkSolenoidModule, getDefaultAnalogModule, getDefaultDigitalModule, getDefaultSolenoidModule, getSimProperties, setDefaultAnalogModule, setDefaultDigitalModule, setDefaultSolenoidModule
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SendableGyro

public SendableGyro(int moduleNumber,
                    int channel)
Gyro constructor given a module and a channel. .

Parameters:
moduleNumber - The cRIO module number for the analog module the gyro is connected to.
channel - The analog channel the gyro is connected to.

SendableGyro

public SendableGyro(int channel)
Gyro constructor with only a channel. Use the default analog module.

Parameters:
channel - The analog channel the gyro is connected to.

SendableGyro

public SendableGyro(AnalogChannel channel)
Gyro constructor with a precreated analog channel object. Use this constructor when the analog channel needs to be shared. There is no reference counting when an AnalogChannel is passed to the gyro.

Parameters:
channel - The AnalogChannel object that the gyro is connected to.
Method Detail

getAngle

public double getAngle()
Description copied from class: Gyro
Return the actual angle in degrees that the robot is currently facing. 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 can go beyond 360 degrees. This make algorithms that wouldn't want to see a discontinuity in the gyro output as it sweeps past 0 on the second time around.

Overrides:
getAngle in class Gyro
Returns:
the current heading of the robot in degrees. This heading is based on integration of the returned rate from the gyro.

reset

public void reset()
Description copied from class: Gyro
Reset the gyro. Resets the gyro to a heading of zero. This can be used if there is significant drift in the gyro and it needs to be recalibrated after it has been running.

Overrides:
reset in class Gyro

setUpdatePeriod

public void setUpdatePeriod(double period)
Sets the time (in seconds) between updates to the SmartDashboard. The default is 0.2 seconds.

Parameters:
period - the new time between updates
Throws:
java.lang.IllegalArgumentException - if given a period that is less than or equal to 0

getUpdatePeriod

public double getUpdatePeriod()
Returns the period (in seconds) between updates to the SmartDashboard. This value is independent of whether or not this SendableGyro is connected to the SmartDashboard. The default value is 0.2 seconds.

Returns:
the period (in seconds)

resetToAngle

public void resetToAngle(double angle)
Reset the gyro. Resets the gyro to the given heading. This can be used if there is significant drift in the gyro and it needs to be recalibrated after it has been running.

Parameters:
angle - the angle the gyro should believe it is pointing

getType

public java.lang.String getType()
Description copied from interface: SmartDashboardData
Returns the type of the data. This is used by the SmartDashboard on the desktop to determine what to do with the table returned by getTable().

For instance, if the type was "Button", then the SmartDashboard would show the data as a button on the desktop and would know to look at and modify the "pressed" field in the NetworkTable returned by getTable().

Specified by:
getType in interface SmartDashboardData
Returns:
the type of the data

getTable

public NetworkTable getTable()
Description copied from interface: SmartDashboardData
Returns the NetworkTable associated with the data. The table should contain all the information the desktop version of SmartDashboard needs to interact with the object. The data should both keep the table up-to-date and also react to changes that the SmartDashboard might make.

For instance, the SendablePIDController will put its p, i and d values into its table and will change them if the table receives new values.

This method should return the same table between calls

Specified by:
getTable in interface SmartDashboardData
Returns:
the table that represents this data