public class RpLidarLowLevelDriver
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
class |
RpLidarLowLevelDriver.ReadSerialThread
Thread which reads in coming serial data from the LIDAR
|
Modifier and Type | Field and Description |
---|---|
(package private) byte[] |
dataOut |
(package private) RpLidarDeviceInfo |
deviceInfo |
static byte |
FORCE_SCAN |
static byte |
GET_HEALTH |
static byte |
GET_INFO |
(package private) RpLidarHeath |
health |
(package private) java.io.InputStream |
in |
(package private) int |
lastReceived |
(package private) RpLidarListener |
listener |
(package private) RpLidarMeasurement |
measurement |
(package private) java.io.OutputStream |
out |
static byte |
RCV_HEALTH |
static byte |
RCV_INFO |
static byte |
RCV_SCAN |
private RpLidarLowLevelDriver.ReadSerialThread |
readThread |
static byte |
RESET |
static byte |
SCAN |
(package private) boolean |
scanning |
(package private) SerialPort |
serialPort |
private static byte |
START_MOTOR |
static byte |
STOP |
static byte |
SYNC_BYTE0 |
static byte |
SYNC_BYTE1 |
(package private) boolean |
verbose |
Constructor and Description |
---|
RpLidarLowLevelDriver(java.lang.String portName,
RpLidarListener listener)
Initializes serial connection
|
Modifier and Type | Method and Description |
---|---|
protected int |
parseData(byte[] data,
int length)
Searches for and parses all complete packets inside data
|
protected boolean |
parseDeviceInfo(byte[] data,
int offset,
int length) |
protected boolean |
parseHealth(byte[] data,
int offset,
int length) |
protected boolean |
parsePacket(byte[] data,
int offset,
int length,
byte type) |
protected boolean |
parseScan(byte[] data,
int offset,
int length) |
void |
pause(long milli)
Pauses for the specified number of milliseconds
|
protected boolean |
sendBlocking(byte command,
byte expected,
long timeout)
Low level blocking packet send routine
|
boolean |
sendGetHealth(long timeout)
Requests that a sensor health packet be sent
|
boolean |
sendGetInfo(long timeout)
Requests that a sensor info packet be sent
|
protected void |
sendNoPayLoad(byte command)
Sends a command with no data payload
|
protected void |
sendPayLoad(byte command,
byte[] payLoad)
Sends a command with data payload
|
protected void |
sendPayLoad(byte command,
int payLoadInt)
Sends a command with data payload - int
|
void |
sendReset()
Sends a reset packet which will put it into its initial state
|
boolean |
sendScan(long timeout)
Request that it enter scan mode
|
void |
sendStartMotor(int speed)
Sends a start motor command
|
void |
sendStop()
Sends a STOP packet
|
void |
sendStopMotor()
Sends a stop motor command
|
void |
setVerbose(boolean verbose) |
void |
shutdown()
Shuts down the serial connection and threads
|
public static final byte SYNC_BYTE0
public static final byte SYNC_BYTE1
public static final byte STOP
public static final byte RESET
public static final byte SCAN
public static final byte FORCE_SCAN
public static final byte GET_INFO
public static final byte GET_HEALTH
public static final byte RCV_INFO
public static final byte RCV_HEALTH
public static final byte RCV_SCAN
private static final byte START_MOTOR
SerialPort serialPort
java.io.InputStream in
java.io.OutputStream out
byte[] dataOut
boolean verbose
private RpLidarLowLevelDriver.ReadSerialThread readThread
RpLidarHeath health
RpLidarDeviceInfo deviceInfo
RpLidarMeasurement measurement
RpLidarListener listener
boolean scanning
volatile int lastReceived
public RpLidarLowLevelDriver(java.lang.String portName, RpLidarListener listener) throws java.lang.Exception
portName
- Path to serial portlistener
- Listener for in comming packetsjava.lang.Exception
public void pause(long milli)
public void shutdown()
public boolean sendScan(long timeout)
timeout
- Blocking time. Resends packet periodically. <= 0 means no blocking.public void sendStop()
public void sendReset()
public boolean sendGetInfo(long timeout)
timeout
- Blocking time. Resends packet periodically. <= 0 means no blocking.public boolean sendGetHealth(long timeout)
timeout
- Blocking time. Resends packet periodically. <= 0 means no blocking.protected boolean sendBlocking(byte command, byte expected, long timeout)
protected void sendNoPayLoad(byte command)
protected void sendPayLoad(byte command, byte[] payLoad)
protected void sendPayLoad(byte command, int payLoadInt)
public void sendStartMotor(int speed)
public void sendStopMotor()
protected int parseData(byte[] data, int length)
protected boolean parsePacket(byte[] data, int offset, int length, byte type)
protected boolean parseHealth(byte[] data, int offset, int length)
protected boolean parseDeviceInfo(byte[] data, int offset, int length)
protected boolean parseScan(byte[] data, int offset, int length)
public void setVerbose(boolean verbose)