public class EV3IRSensor extends UARTSensor
Supported modes | |||
---|---|---|---|
Mode name | Description | unit(s) | Getter |
Distance | Measures the distance to an object in front of the sensor | Undefined | getDistanceMode() |
Seek | Locates up to four beacons | Undefined, undefined | getSeekMode() |
EV3 Infra Red sensor
The sensor can be used as a receiver for up to four Lego Ev3 IR remote controls using the getRemoteCommand(int)
and getRemoteCommands(byte[], int, int)
methods.
See Sensor Product page
See The
leJOS sensor framework
See leJOS conventions for
SampleProviders
Modifier and Type | Field and Description |
---|---|
static int |
IR_CHANNELS |
protected static int |
IR_PROX |
protected static int |
IR_REMOTE |
protected static int |
IR_SEEK |
protected byte[] |
remoteVals |
protected static int |
SWITCH_DELAY |
currentMode, port
modes
Constructor and Description |
---|
EV3IRSensor(Port port) |
EV3IRSensor(UARTPort port) |
Modifier and Type | Method and Description |
---|---|
SensorMode |
getDistanceMode()
EV3 Infra Red sensor, Distance mode
Measures the distance to an object in front of the sensor. |
int |
getRemoteCommand(int chan)
Return the current remote command from the specified channel.
|
void |
getRemoteCommands(byte[] cmds,
int offset,
int len)
Obtain the commands associated with one or more channels.
|
SensorMode |
getSeekMode()
EV3 Infra Red sensor, Seek mode
In seek mode the sensor locates up to four beacons and provides bearing and distance of each beacon. |
protected void |
init() |
switchMode
fetchSample, getAvailableModes, getCurrentMode, getMode, getMode, getModeCount, getName, sampleSize, setCurrentMode, setCurrentMode, setModes
close, releaseOnClose
protected static final int IR_PROX
protected static final int IR_SEEK
protected static final int IR_REMOTE
protected static final int SWITCH_DELAY
public static final int IR_CHANNELS
protected byte[] remoteVals
public EV3IRSensor(UARTPort port)
public EV3IRSensor(Port port)
protected void init()
public int getRemoteCommand(int chan)
chan
- channel to obtain the command forpublic void getRemoteCommands(byte[] cmds, int offset, int len)
cmds
- the array to store the commandsoffset
- the offset to start storinglen
- the number of commands to store.public SensorMode getDistanceMode()
Size and content of the sample
The sample contains one element giving the distance to an object in front of the sensor. The distance provided is very roughly equivalent to meters
but needs conversion to give better distance. See product page for details.
The effective range of the sensor in Distance mode is about 5 to 50 centimeters. Outside this range a zero is returned
for low values and positive infinity for high values.
leJOS conventions for
SampleProviders
See Sensor Product page public SensorMode getSeekMode()
Size and content of the sample
The sample contains four pairs of elements in a single sample. Each pair gives bearing of and distance to the beacon.
The first pair of elements is associated with a beacon transmitting on channel 0, the second pair with a beacon transmitting on channel 1 etc.
The bearing values range from -25 to +25 (with values increasing clockwise
when looking from behind the sensor). A bearing of 0 indicates the beacon is
directly in front of the sensor.
Distance values are not to scale. Al increasing values indicate increasing distance.
If no beacon is detected both bearing is set to zero, and distance to positive infinity.
leJOS conventions for
SampleProviders
See Sensor Product page