|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object lejos.nxt.I2CSensor lejos.nxt.addon.NXTLineLeader
public class NXTLineLeader
This class manages the sensor NXT Line Leader from Mindsensors. The sensor add a sensor row to detect black/white lines. This sensor is perfect to build a robot which has the mission to follow a line.
Nested Class Summary | |
---|---|
static class |
NXTLineLeader.Command
|
static class |
NXTLineLeader.LineColor
Color selector for white reading limit |
Field Summary |
---|
Fields inherited from class lejos.nxt.I2CSensor |
---|
address, DEFAULT_I2C_ADDRESS, port, REG_PRODUCT_ID, REG_VENDOR_ID, REG_VERSION |
Fields inherited from interface lejos.nxt.SensorConstants |
---|
BLACK, BLANK_INDEX, BLUE, BLUE_INDEX, GREEN, GREEN_INDEX, MAX_AD_RAW, MAX_TYPE, MIN_TYPE, MODE_ANGLESTEP, MODE_BOOLEAN, MODE_CELSIUS, MODE_FARENHEIT, MODE_PCTFULLSCALE, MODE_PERIODCOUNTER, MODE_RAW, MODE_TRANSITIONCNT, RED, RED_INDEX, TYPE_ANGLE, TYPE_COLORBLUE, TYPE_COLORFULL, TYPE_COLORGREEN, TYPE_COLORNONE, TYPE_COLORRED, TYPE_CUSTOM, TYPE_HISPEED, TYPE_LIGHT_ACTIVE, TYPE_LIGHT_INACTIVE, TYPE_LOWSPEED, TYPE_LOWSPEED_9V, TYPE_NO_SENSOR, TYPE_REFLECTION, TYPE_SOUND_DB, TYPE_SOUND_DBA, TYPE_SWITCH, TYPE_TEMPERATURE, WHITE, YELLOW |
Constructor Summary | |
---|---|
NXTLineLeader(I2CPort port)
Constructor |
|
NXTLineLeader(I2CPort port,
int address)
Constructor |
Method Summary | |
---|---|
void |
calibrate(NXTLineLeader.LineColor color)
Calibrate the white and black levels. |
int |
getAverage()
Get the average value |
int |
getCalibratedSensorReading(int index)
Get the calibrated reading of a given sensor |
int |
getCalibrationData(int index,
NXTLineLeader.LineColor color)
Get the calibration data for white and black colors for a given sensor |
int |
getKD()
Get KD value |
int |
getKDDivisor()
Get KD divisor |
int |
getKI()
Get KI value |
int |
getKIDivisor()
Get KI divisor |
int |
getKP()
Get KP value |
int |
getKPDivisor()
Get KP divisor |
int |
getReadingLimit(int index,
NXTLineLeader.LineColor color)
Get the calibration value for white and black colors for a given sensor |
int |
getResult()
Get result value |
int |
getSensorStatus(int index)
Deprecated. |
int |
getSetPoint()
Get the set point of the PID. |
int |
getSteering()
Get the steering value |
void |
sendCommand(char cmd)
Deprecated. use sendCommand(Command) instead |
void |
sendCommand(NXTLineLeader.Command cmd)
Send a single byte command represented by a letter |
void |
setKD(int KD)
Set KD value |
void |
setKDDivisor(int value)
Set the KD divisor |
void |
setKI(int KI)
Set KI value |
void |
setKIDivisor(int value)
Set the KI divisor |
void |
setKP(int KP)
Set KP value |
void |
setKPDivisor(int value)
Set the KP divisor |
void |
setSetPoint(int value)
Set the set point of the PID |
void |
sleep()
Sleep the sensor |
void |
wakeUp()
Wake up the sensor |
Methods inherited from class lejos.nxt.I2CSensor |
---|
fetchString, getAddress, getData, getData, getPort, getProductID, getVendorID, getVersion, sendData, sendData, sendData, setAddress |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public NXTLineLeader(I2CPort port, int address)
port
- address
- I2C address for the devicepublic NXTLineLeader(I2CPort port)
port
- Method Detail |
---|
public void sendCommand(NXTLineLeader.Command cmd)
cmd
- the command to be sent@Deprecated public void sendCommand(char cmd)
sendCommand(Command)
instead
This version has no checking of the validity of the passed command, so it
is advised to use sendCommand(Command)
instead.
cmd
- the character based commandpublic void sleep()
public void wakeUp()
public void calibrate(NXTLineLeader.LineColor color)
color
- color selectorpublic int getSteering()
Steering is a signed value in the range [-100,+100] representing the amount of power to be added/subtracted to motors power setting. In case we cannot read the sensor, Integer.MIN_VALUE is returned to notify the anomaly.
public int getAverage()
public int getResult()
public int getSetPoint()
public void setSetPoint(int value)
public int getKP()
public void setKP(int KP)
public int getKPDivisor()
public void setKPDivisor(int value)
public int getKI()
public void setKI(int KI)
public int getKIDivisor()
public void setKIDivisor(int value)
public int getKD()
public void setKD(int KD)
public int getKDDivisor()
public void setKDDivisor(int value)
@Deprecated public int getSensorStatus(int index)
public int getCalibratedSensorReading(int index)
index
- sensor index (must be in range [1..8])
IllegalArgumentException
- if index not in rangepublic int getReadingLimit(int index, NXTLineLeader.LineColor color)
index
- sensor index (must be in range [1..8])color
- color selector
IllegalArgumentException
- if index not in rangepublic int getCalibrationData(int index, NXTLineLeader.LineColor color)
index
- sensor index (must be in range [1..8])color
- color selector
IllegalArgumentException
- if index not in range
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |