public class BrickletLaserRangeFinder extends Device
Modifier and Type | Class and Description |
---|---|
class |
BrickletLaserRangeFinder.Configuration |
class |
BrickletLaserRangeFinder.DistanceCallbackThreshold |
static interface |
BrickletLaserRangeFinder.DistanceListener
This listener is triggered periodically with the period that is set by
setDistanceCallbackPeriod(long) . |
static interface |
BrickletLaserRangeFinder.DistanceReachedListener
This listener is triggered when the threshold as set by
setDistanceCallbackThreshold(char, int, int) is reached. |
class |
BrickletLaserRangeFinder.MovingAverage |
class |
BrickletLaserRangeFinder.VelocityCallbackThreshold |
static interface |
BrickletLaserRangeFinder.VelocityListener
This listener is triggered periodically with the period that is set by
setVelocityCallbackPeriod(long) . |
static interface |
BrickletLaserRangeFinder.VelocityReachedListener
This listener is triggered when the threshold as set by
setVelocityCallbackThreshold(char, short, short) is reached. |
Device.Identity
Constructor and Description |
---|
BrickletLaserRangeFinder(java.lang.String uid,
IPConnection ipcon)
Creates an object with the unique device ID \c uid.
|
Modifier and Type | Method and Description |
---|---|
void |
addDistanceListener(BrickletLaserRangeFinder.DistanceListener listener)
Adds a Distance listener.
|
void |
addDistanceReachedListener(BrickletLaserRangeFinder.DistanceReachedListener listener)
Adds a DistanceReached listener.
|
void |
addVelocityListener(BrickletLaserRangeFinder.VelocityListener listener)
Adds a Velocity listener.
|
void |
addVelocityReachedListener(BrickletLaserRangeFinder.VelocityReachedListener listener)
Adds a VelocityReached listener.
|
void |
disableLaser()
Deactivates the laser of the LIDAR.
|
void |
enableLaser()
Activates the laser of the LIDAR.
|
BrickletLaserRangeFinder.Configuration |
getConfiguration()
Returns the configuration as set by
setConfiguration(short, boolean, short, int) . |
long |
getDebouncePeriod()
Returns the debounce period as set by
setDebouncePeriod(long) . |
int |
getDistance()
Returns the measured distance.
|
long |
getDistanceCallbackPeriod()
Returns the period as set by
setDistanceCallbackPeriod(long) . |
BrickletLaserRangeFinder.DistanceCallbackThreshold |
getDistanceCallbackThreshold()
Returns the threshold as set by
setDistanceCallbackThreshold(char, int, int) . |
Device.Identity |
getIdentity()
Returns the UID, the UID where the Bricklet is connected to,
the position, the hardware and firmware version as well as the
device identifier.
|
short |
getMode()
Returns the mode as set by
setMode(short) . |
BrickletLaserRangeFinder.MovingAverage |
getMovingAverage()
Returns the length moving average as set by
setMovingAverage(short, short) . |
short |
getSensorHardwareVersion()
Returns the LIDAR-Lite hardware version.
|
short |
getVelocity()
Returns the measured velocity.
|
long |
getVelocityCallbackPeriod()
Returns the period as set by
setVelocityCallbackPeriod(long) . |
BrickletLaserRangeFinder.VelocityCallbackThreshold |
getVelocityCallbackThreshold()
Returns the threshold as set by
setVelocityCallbackThreshold(char, short, short) . |
boolean |
isLaserEnabled()
Returns *true* if the laser is enabled, *false* otherwise.
|
void |
removeDistanceListener(BrickletLaserRangeFinder.DistanceListener listener)
Removes a Distance listener.
|
void |
removeDistanceReachedListener(BrickletLaserRangeFinder.DistanceReachedListener listener)
Removes a DistanceReached listener.
|
void |
removeVelocityListener(BrickletLaserRangeFinder.VelocityListener listener)
Removes a Velocity listener.
|
void |
removeVelocityReachedListener(BrickletLaserRangeFinder.VelocityReachedListener listener)
Removes a VelocityReached listener.
|
void |
setConfiguration(short acquisitionCount,
boolean enableQuickTermination,
short thresholdValue,
int measurementFrequency)
\note
This function is only available if you have a LIDAR-Lite sensor with hardware
version 3.
|
void |
setDebouncePeriod(long debounce)
Sets the period with which the threshold listeners
*
BrickletLaserRangeFinder.DistanceReachedListener ,
* BrickletLaserRangeFinder.VelocityReachedListener ,
are triggered, if the thresholds
* setDistanceCallbackThreshold(char, int, int) ,
* setVelocityCallbackThreshold(char, short, short) ,
keep being reached. |
void |
setDistanceCallbackPeriod(long period)
Sets the period with which the
BrickletLaserRangeFinder.DistanceListener listener is triggered
periodically. |
void |
setDistanceCallbackThreshold(char option,
int min,
int max)
Sets the thresholds for the
BrickletLaserRangeFinder.DistanceReachedListener listener. |
void |
setMode(short mode)
\note
This function is only available if you have a LIDAR-Lite sensor with hardware
version 1.
|
void |
setMovingAverage(short distanceAverageLength,
short velocityAverageLength)
Sets the length of a `moving averaging <https://en.wikipedia.org/wiki/Moving_average>`__
for the distance and velocity.
|
void |
setVelocityCallbackPeriod(long period)
Sets the period with which the
BrickletLaserRangeFinder.VelocityListener listener is triggered
periodically. |
void |
setVelocityCallbackThreshold(char option,
short min,
short max)
Sets the thresholds for the
BrickletLaserRangeFinder.VelocityReachedListener listener. |
getAPIVersion, getResponseExpected, setResponseExpected, setResponseExpectedAll
public static final int DEVICE_IDENTIFIER
public static final java.lang.String DEVICE_DISPLAY_NAME
public static final byte FUNCTION_GET_DISTANCE
public static final byte FUNCTION_GET_VELOCITY
public static final byte FUNCTION_SET_DISTANCE_CALLBACK_PERIOD
public static final byte FUNCTION_GET_DISTANCE_CALLBACK_PERIOD
public static final byte FUNCTION_SET_VELOCITY_CALLBACK_PERIOD
public static final byte FUNCTION_GET_VELOCITY_CALLBACK_PERIOD
public static final byte FUNCTION_SET_DISTANCE_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_DISTANCE_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_VELOCITY_CALLBACK_THRESHOLD
public static final byte FUNCTION_GET_VELOCITY_CALLBACK_THRESHOLD
public static final byte FUNCTION_SET_DEBOUNCE_PERIOD
public static final byte FUNCTION_GET_DEBOUNCE_PERIOD
public static final byte FUNCTION_SET_MOVING_AVERAGE
public static final byte FUNCTION_GET_MOVING_AVERAGE
public static final byte FUNCTION_SET_MODE
public static final byte FUNCTION_GET_MODE
public static final byte FUNCTION_ENABLE_LASER
public static final byte FUNCTION_DISABLE_LASER
public static final byte FUNCTION_IS_LASER_ENABLED
public static final byte FUNCTION_GET_SENSOR_HARDWARE_VERSION
public static final byte FUNCTION_SET_CONFIGURATION
public static final byte FUNCTION_GET_CONFIGURATION
public static final byte FUNCTION_GET_IDENTITY
public static final char THRESHOLD_OPTION_OFF
public static final char THRESHOLD_OPTION_OUTSIDE
public static final char THRESHOLD_OPTION_INSIDE
public static final char THRESHOLD_OPTION_SMALLER
public static final char THRESHOLD_OPTION_GREATER
public static final short MODE_DISTANCE
public static final short MODE_VELOCITY_MAX_13MS
public static final short MODE_VELOCITY_MAX_32MS
public static final short MODE_VELOCITY_MAX_64MS
public static final short MODE_VELOCITY_MAX_127MS
public static final short VERSION_1
public static final short VERSION_3
public BrickletLaserRangeFinder(java.lang.String uid, IPConnection ipcon)
public int getDistance() throws TinkerforgeException
getSensorHardwareVersion()
) cannot
measure distance and velocity at the same time. Therefore, the distance mode
has to be enabled using setMode(short)
.
Sensor hardware version 3 can measure distance and velocity at the same
time. Also the laser has to be enabled, see enableLaser()
.
If you want to get the distance periodically, it is recommended to
use the BrickletLaserRangeFinder.DistanceListener
listener and set the period with
setDistanceCallbackPeriod(long)
.TinkerforgeException
public short getVelocity() throws TinkerforgeException
getSensorHardwareVersion()
) cannot
measure distance and velocity at the same time. Therefore, the velocity mode
has to be enabled using setMode(short)
.
Sensor hardware version 3 can measure distance and velocity at the same
time, but the velocity measurement only produces stables results if a fixed
measurement rate (see setConfiguration(short, boolean, short, int)
) is configured. Also the laser
has to be enabled, see enableLaser()
.
If you want to get the velocity periodically, it is recommended to
use the BrickletLaserRangeFinder.VelocityListener
listener and set the period with
setVelocityCallbackPeriod(long)
.TinkerforgeException
public void setDistanceCallbackPeriod(long period) throws TinkerforgeException
BrickletLaserRangeFinder.DistanceListener
listener is triggered
periodically. A value of 0 turns the listener off.
The BrickletLaserRangeFinder.DistanceListener
listener is only triggered if the distance value has
changed since the last triggering.TinkerforgeException
public long getDistanceCallbackPeriod() throws TinkerforgeException
setDistanceCallbackPeriod(long)
.TinkerforgeException
public void setVelocityCallbackPeriod(long period) throws TinkerforgeException
BrickletLaserRangeFinder.VelocityListener
listener is triggered
periodically. A value of 0 turns the listener off.
The BrickletLaserRangeFinder.VelocityListener
listener is only triggered if the velocity value has
changed since the last triggering.TinkerforgeException
public long getVelocityCallbackPeriod() throws TinkerforgeException
setVelocityCallbackPeriod(long)
.TinkerforgeException
public void setDistanceCallbackThreshold(char option, int min, int max) throws TinkerforgeException
BrickletLaserRangeFinder.DistanceReachedListener
listener.
The following options are possible:
\verbatim
"Option", "Description"
"'x'", "Listener is turned off"
"'o'", "Listener is triggered when the distance value is *outside* the min and max values"
"'i'", "Listener is triggered when the distance value is *inside* the min and max values"
"'<'", "Listener is triggered when the distance value is smaller than the min value (max is ignored)"
"'>'", "Listener is triggered when the distance value is greater than the min value (max is ignored)"
\endverbatimTinkerforgeException
public BrickletLaserRangeFinder.DistanceCallbackThreshold getDistanceCallbackThreshold() throws TinkerforgeException
setDistanceCallbackThreshold(char, int, int)
.TinkerforgeException
public void setVelocityCallbackThreshold(char option, short min, short max) throws TinkerforgeException
BrickletLaserRangeFinder.VelocityReachedListener
listener.
The following options are possible:
\verbatim
"Option", "Description"
"'x'", "Listener is turned off"
"'o'", "Listener is triggered when the velocity is *outside* the min and max values"
"'i'", "Listener is triggered when the velocity is *inside* the min and max values"
"'<'", "Listener is triggered when the velocity is smaller than the min value (max is ignored)"
"'>'", "Listener is triggered when the velocity is greater than the min value (max is ignored)"
\endverbatimTinkerforgeException
public BrickletLaserRangeFinder.VelocityCallbackThreshold getVelocityCallbackThreshold() throws TinkerforgeException
setVelocityCallbackThreshold(char, short, short)
.TinkerforgeException
public void setDebouncePeriod(long debounce) throws TinkerforgeException
BrickletLaserRangeFinder.DistanceReachedListener
,
* BrickletLaserRangeFinder.VelocityReachedListener
,
are triggered, if the thresholds
* setDistanceCallbackThreshold(char, int, int)
,
* setVelocityCallbackThreshold(char, short, short)
,
keep being reached.TinkerforgeException
public long getDebouncePeriod() throws TinkerforgeException
setDebouncePeriod(long)
.TinkerforgeException
public void setMovingAverage(short distanceAverageLength, short velocityAverageLength) throws TinkerforgeException
TinkerforgeException
public BrickletLaserRangeFinder.MovingAverage getMovingAverage() throws TinkerforgeException
setMovingAverage(short, short)
.TinkerforgeException
public void setMode(short mode) throws TinkerforgeException
setConfiguration(short, boolean, short, int)
for hardware version 3. You can check
the sensor hardware version using getSensorHardwareVersion()
.
The LIDAR-Lite sensor (hardware version 1) has five different modes. One mode is
for distance measurements and four modes are for velocity measurements with
different ranges.
The following modes are available:
* 0: Distance is measured with resolution 1.0 cm and range 0-4000 cm
* 1: Velocity is measured with resolution 0.1 m/s and range is 0-12.7 m/s
* 2: Velocity is measured with resolution 0.25 m/s and range is 0-31.75 m/s
* 3: Velocity is measured with resolution 0.5 m/s and range is 0-63.5 m/s
* 4: Velocity is measured with resolution 1.0 m/s and range is 0-127 m/sTinkerforgeException
public short getMode() throws TinkerforgeException
setMode(short)
.TinkerforgeException
public void enableLaser() throws TinkerforgeException
getDistance()
to ensure stable measurements.TinkerforgeException
public void disableLaser() throws TinkerforgeException
TinkerforgeException
public boolean isLaserEnabled() throws TinkerforgeException
TinkerforgeException
public short getSensorHardwareVersion() throws TinkerforgeException
TinkerforgeException
public void setConfiguration(short acquisitionCount, boolean enableQuickTermination, short thresholdValue, int measurementFrequency) throws TinkerforgeException
setMode(short)
for hardware version 1. You can check
the sensor hardware version using getSensorHardwareVersion()
.
The **Acquisition Count** defines the number of times the Laser Range Finder Bricklet
will integrate acquisitions to find a correlation record peak. With a higher count,
the Bricklet can measure longer distances. With a lower count, the rate increases. The
allowed values are 1-255.
If you set **Enable Quick Termination** to true, the distance measurement will be terminated
early if a high peak was already detected. This means that a higher measurement rate can be achieved
and long distances can be measured at the same time. However, the chance of false-positive
distance measurements increases.
Normally the distance is calculated with a detection algorithm that uses peak value,
signal strength and noise. You can however also define a fixed **Threshold Value**.
Set this to a low value if you want to measure the distance to something that has
very little reflection (e.g. glass) and set it to a high value if you want to measure
the distance to something with a very high reflection (e.g. mirror). Set this to 0 to
use the default algorithm. The other allowed values are 1-255.
Set the **Measurement Frequency** to force a fixed measurement rate. If set to 0,
the Laser Range Finder Bricklet will use the optimal frequency according to the other
configurations and the actual measured distance. Since the rate is not fixed in this case,
the velocity measurement is not stable. For a stable velocity measurement you should
set a fixed measurement frequency. The lower the frequency, the higher is the resolution
of the calculated velocity. The allowed values are 10Hz-500Hz (and 0 to turn the fixed
frequency off).
.. versionadded:: 2.0.3$nbsp;(Plugin)TinkerforgeException
public BrickletLaserRangeFinder.Configuration getConfiguration() throws TinkerforgeException
setConfiguration(short, boolean, short, int)
.
.. versionadded:: 2.0.3$nbsp;(Plugin)TinkerforgeException
public Device.Identity getIdentity() throws TinkerforgeException
getIdentity
in class Device
TinkerforgeException
public void addDistanceListener(BrickletLaserRangeFinder.DistanceListener listener)
public void removeDistanceListener(BrickletLaserRangeFinder.DistanceListener listener)
public void addVelocityListener(BrickletLaserRangeFinder.VelocityListener listener)
public void removeVelocityListener(BrickletLaserRangeFinder.VelocityListener listener)
public void addDistanceReachedListener(BrickletLaserRangeFinder.DistanceReachedListener listener)
public void removeDistanceReachedListener(BrickletLaserRangeFinder.DistanceReachedListener listener)
public void addVelocityReachedListener(BrickletLaserRangeFinder.VelocityReachedListener listener)
public void removeVelocityReachedListener(BrickletLaserRangeFinder.VelocityReachedListener listener)
Copyright © 2021 Tinkerforge GmbH. All rights reserved.