public class UltrasonicSensor extends Sensor<ShefRobot.UltrasonicSensorAction>
UltrasonicSensor.Mode.DISTANCE and UltrasonicSensor.Mode.LISTEN
By default the sensor starts in UltrasonicSensor.Mode.DISTANCE mode.| Modifier and Type | Class and Description |
|---|---|
static class |
UltrasonicSensor.Mode
Modes that this sensor can be used in
|
Sensor.Port| Modifier and Type | Method and Description |
|---|---|
float |
getDistance()
Returns the distance detected by the sensor in metres
When in distance mode, the Ultrasonic sensors light will be solid and it will continuously emit pings
Values outside of the approximate range ~0.03-1.7m are returned as
Float.POSITIVE_INFINITY |
boolean |
listen()
When in Listen mode the Ultrasonic sensor will not emit ultrasound, it will only listen for other robots ultrasound.
|
void |
run()
This method is for internal use, it exists due to Sensors and Motors both extending runnable.
|
getRawSamplepublic float getDistance()
Float.POSITIVE_INFINITYpublic boolean listen()
listen() for the sensor to stop reading it's own pings