Main Content

Get Started with Lidar Toolbox Support Package for Hokuyo Lidar Sensors

Since R2024a

The Lidar Toolbox™ Support Package for Hokuyo™ Lidar Sensors enables you to stream data from Hokuyo 2-D lidar sensors into MATLAB® by using the hokuyolidar2d object. You can preview and read lidar scan data from the supported sensors. The support package supports only those sensors that are compatible with sensor communication interface protocol (SCIP) 2.x.

Before you start using the support package, you must first connect the sensor to your computer and test that the sensor is working properly.

Connect Hokuyo Lidar Sensor

By default, the Hokuyo 2-D lidar sensor has an IP address of 192.168.0.10. To connect a Hokuyo 2-D lidar sensor to your computer (host machine) or network using Ethernet, you must set a unique IP address on your computer or network and ensure that the sensor and host machine are in the same subnet. For more information on how to connect your sensor, see Connect Lidar Sensor to Your PC.

Run Hardware Outside MATLAB

Before using functionality from the Lidar Toolbox Support Package for Hokuyo Lidar Sensors, verify that your Hokuyo lidar sensor runs properly by displaying data from the sensor by using the URG Benri software provided by Hokuyo. For more information, see Display Waveforms with URG Benri Software.

Stream Data from Hokuyo Sensor

After you successfully connect the sensor and test that it works, you can stream the sensor data into MATLAB by using a hokuyolidar2d object. First, create the object, and then preview and read lidar scan data from the sensor.

Note

Before you create a hokuyolidar2d object in MATLAB, you must close any other software that is using the Hokuyo sensor.

Create hokuyolidar2d Object

Create a hokuyolidar2d object.

hokuyoObj = hokuyolidar2d
hokuyoObj = 

    hokuyolidar2d object with properties:

                   DeviceAddress: "localhost"
                            Port: 19040
                           Model: "UST - 10LX"
                    SerialNumber: "H1880720"
                 ScanRangeLimits: [0.0200 30]
                 ScanAngleLimits: [0 270]
             ScanAngleResolution: 0.2500
               IsConnectionValid: 1
                        Firmware: "3.00.0000"
                        Protocol: "SCIP 2.2"
                  FrontAxisAngle: 135
              StandardMotorSpeed: 2400
                         Timeout: 10

The properties of the object are read-only, meaning you cannot modify them after you create the object. However, you can specify the DeviceAddress, Port, and Timeout properties when you create the object by using name-value arguments. For example, hokuyoObj = hokuyolidar2d(Timeout=15) sets the time out value to 15 seconds. This value specifies the maximum amount of time MATLAB waits for a response from the Hokuyo 2-D lidar sensor. For more information on the object and its properties, see hokuyolidar2d.

Preview Lidar Scan Data

Preview the 2-D lidar scan data by using the preview function. The preview window opens. Note that you must close the preview window to run any other MATLAB commands.

preview(hokuyoObj)

Read Lidar Scan Data

After you preview the data and close the preview window, read the latest 2-D lidar scan by using the read function. The function returns a lidarScan object, which stores the read data. Display the lidar scan data using the plot function.

scan = read(hokuyoObj);
plot(scan)

You can also specify the number of lidar scans to read from the object by using the numScans input argument. For example, scan = read(hokuyoObj,10) reads the 10 latest lidar scans from the sensor.

Get Status of Sensor Parameters

You can also get the status of different sensor parameters, such as current motor speed, laser illumination state, measurement mode, and sensor diagnostics, by using the getStatus function. For example, status = getStatus(hokuyoObj,"CurrentMotorSpeed") returns the current motor speed of the sensor.

See Also

| | |

Related Topics

External Websites