Example Code

Using LabVIEW and the Hokuyo URG-04LX-UG01 Laser Range Finder

Products and Environment

This section reflects the products and operating system used to create the example.

To download NI software, including the products shown below, visit ni.com/downloads.

    Hardware

  • Instrument Control

    Software

  • LabVIEW

    Driver

  • NI VISA

Code and Documents

Attachment

Description

Overview

In this example, we show how LabVIEW can be used to interface with the Hokuyo URG-04LX-UG01 Laser Range Finder.

 

Description

The URG-04LX-UG01 is a small, low cost, bus powered LiDAR that can be easily used to acquire fast and accurate distance measurements across a 240° range. The attached code below can be used not only for visualising a simple algorithmic depiction of how a USB device can be controlled using the NI-VISA drivers, but also can be used as API to be integrated within larger application frameworks based upon acquiring distance measurements from the URG-04LX-UG01.

 

Requirement

  1. LabVIEW2013 (or compatible)

 

Steps to Implement or Execute Code

  1. Download the attached file URG-04LX-UG01 LabVIEW 2010.zip.
  2. Register your Hokuyo URG-04LX-UG01 within the NI-VISA using the NI-VISA Driver Wizard. This will not conflict with the driver software provided by Hokuyo.
  3. Open URG-04LX-UG01 Main.vi. Navigate to your connected device COM port through the VISA dropdown box, and notice the default Acquisition Parameters; these are configured for a full range scan.
  4. Hit the Run button. You should now start acquiring continuous distance measurements across the entire range of the scanner populate the Distance Measurements array. By default, we are scanning the full range of the URG-04LX-UG01, including the Dead Zone; distance measurements within this area will result in a constant value which must not be included in measurement processing.
  5. Hit the Stop button to end the VI.
  6. Hit Ctrl+E to jump to the Block Diagram and view the graphical code. Each SubVI contained within the accompanying LabVIEW Project 'Hokuyo URG-04LX-UG01 Getting Started' can be double clicked on and navigated. All code is fully documented and compliant with the SCIP specifications used to control the device.

Additional Information or References

NI Snippet

 

Main.png

 

It is recommended that when analyzing the LabVIEW code, you also have access to the accompanying datasheet for the URG-04LX-UG-01 which outlines the specifications of the SCIP 2.0 communications interface.

 

**This document has been updated to meet the current required format for the NI Code Exchange.**


Alex Thomas, University of Manchester School of EEE LabVIEW Ambassador (CLAD)

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Comments
harindervirk
Member
Member
on

Edit: I was getting error: Invalid buffer mask specified but I followed this white paper instead and it worked.