public class Ultrasonic extends SensorBase implements PIDSource, LiveWindowSendable
Modifier and Type | Class and Description |
---|---|
static class |
Ultrasonic.Unit
The units to return when PIDGet is called.
|
Modifier and Type | Field and Description |
---|---|
protected PIDSourceType |
m_pidSource |
kAnalogInputChannels, kAnalogOutputChannels, kDigitalChannels, kPCMModules, kPDPChannels, kPDPModules, kPwmChannels, kRelayChannels, kSolenoidChannels, kSystemClockTicksPerMicrosecond
Constructor and Description |
---|
Ultrasonic(DigitalOutput pingChannel,
DigitalInput echoChannel)
Create an instance of an Ultrasonic Sensor from a DigitalInput for the echo channel and a
DigitalOutput for the ping channel.
|
Ultrasonic(DigitalOutput pingChannel,
DigitalInput echoChannel,
Ultrasonic.Unit units)
Create an instance of an Ultrasonic Sensor from a DigitalInput for the echo channel and a
DigitalOutput for the ping channel.
|
Ultrasonic(int pingChannel,
int echoChannel)
Create an instance of the Ultrasonic Sensor.
|
Ultrasonic(int pingChannel,
int echoChannel,
Ultrasonic.Unit units)
Create an instance of the Ultrasonic Sensor.
|
Modifier and Type | Method and Description |
---|---|
void |
free()
Destructor for the ultrasonic sensor.
|
Ultrasonic.Unit |
getDistanceUnits()
Get the current DistanceUnit that is used for the PIDSource base object.
|
PIDSourceType |
getPIDSourceType()
Get which parameter of the device you are using as a process control variable.
|
double |
getRangeInches()
Get the range in inches from the ultrasonic sensor.
|
double |
getRangeMM()
Get the range in millimeters from the ultrasonic sensor.
|
java.lang.String |
getSmartDashboardType()
Live Window code, only does anything if live window is activated.
|
ITable |
getTable()
The table that is associated with this
Sendable . |
void |
initTable(ITable subtable)
Initializes a table for this
Sendable object. |
boolean |
isEnabled()
Is the ultrasonic enabled.
|
boolean |
isRangeValid()
Check if there is a valid range measurement.
|
double |
pidGet()
Get the range in the current DistanceUnit for the PIDSource base object.
|
void |
ping()
Single ping to ultrasonic sensor.
|
void |
setAutomaticMode(boolean enabling)
Turn Automatic mode on/off.
|
void |
setDistanceUnits(Ultrasonic.Unit units)
Set the current DistanceUnit that should be used for the PIDSource base object.
|
void |
setEnabled(boolean enable)
Set if the ultrasonic is enabled.
|
void |
setPIDSourceType(PIDSourceType pidSource)
Set which parameter of the device you are using as a process control variable.
|
void |
startLiveWindowMode()
Start having this sendable object automatically respond to value changes reflect the value on
the table.
|
void |
stopLiveWindowMode()
Stop having this sendable object automatically respond to value changes.
|
void |
updateTable()
Update the table for this sendable object with the latest values.
|
checkAnalogInputChannel, checkAnalogOutputChannel, checkDigitalChannel, checkPDPChannel, checkPDPModule, checkPWMChannel, checkRelayChannel, checkSolenoidChannel, checkSolenoidModule, getDefaultSolenoidModule, setDefaultSolenoidModule
protected PIDSourceType m_pidSource
public Ultrasonic(int pingChannel, int echoChannel, Ultrasonic.Unit units)
pingChannel
- The digital output channel that sends the pulse to initiate the sensor
sending the ping.echoChannel
- The digital input channel that receives the echo. The length of time that
the echo is high represents the round trip time of the ping, and the
distance.units
- The units returned in either kInches or kMilliMeterspublic Ultrasonic(int pingChannel, int echoChannel)
pingChannel
- The digital output channel that sends the pulse to initiate the sensor
sending the ping.echoChannel
- The digital input channel that receives the echo. The length of time that
the echo is high represents the round trip time of the ping, and the
distance.public Ultrasonic(DigitalOutput pingChannel, DigitalInput echoChannel, Ultrasonic.Unit units)
pingChannel
- The digital output object that starts the sensor doing a ping. Requires a
10uS pulse to start.echoChannel
- The digital input object that times the return pulse to determine the
range.units
- The units returned in either kInches or kMilliMeterspublic Ultrasonic(DigitalOutput pingChannel, DigitalInput echoChannel)
pingChannel
- The digital output object that starts the sensor doing a ping. Requires a
10uS pulse to start.echoChannel
- The digital input object that times the return pulse to determine the
range.public void free()
free
in class SensorBase
public void setAutomaticMode(boolean enabling)
enabling
- Set to true if round robin scheduling should start for all the ultrasonic
sensors. This scheduling method assures that the sensors are non-interfering
because no two sensors fire at the same time. If another scheduling algorithm
is preffered, it can be implemented by pinging the sensors manually and waiting
for the results to come back.public void ping()
public boolean isRangeValid()
public double getRangeInches()
public double getRangeMM()
public void setPIDSourceType(PIDSourceType pidSource)
PIDSource
setPIDSourceType
in interface PIDSource
pidSource
- An enum to select the parameter.public PIDSourceType getPIDSourceType()
PIDSource
getPIDSourceType
in interface PIDSource
public double pidGet()
public void setDistanceUnits(Ultrasonic.Unit units)
units
- The DistanceUnit that should be used.public Ultrasonic.Unit getDistanceUnits()
public boolean isEnabled()
public void setEnabled(boolean enable)
enable
- set to true to enable the ultrasonicpublic java.lang.String getSmartDashboardType()
getSmartDashboardType
in interface Sendable
Sendable
.public void initTable(ITable subtable)
Sendable
Sendable
object.public ITable getTable()
Sendable
Sendable
.public void updateTable()
LiveWindowSendable
updateTable
in interface LiveWindowSendable
public void startLiveWindowMode()
LiveWindowSendable
startLiveWindowMode
in interface LiveWindowSendable
public void stopLiveWindowMode()
LiveWindowSendable
stopLiveWindowMode
in interface LiveWindowSendable