Click here to Skip to main content
15,885,096 members
Articles / Desktop Programming / Win32
Tip/Trick

Communication Library Files - LMS5lib | Connection and Structure

Rate me:
Please Sign up or sign in to vote.
5.00/5 (2 votes)
16 Apr 2015GPL34 min read 30.3K   788   4   21
Communication Library Files - LMS5lib | Connection and structure

Introduction

This example shows how to use the LMS5Lib part of the communication library that a colleague and myself made for demonstration purposes on SICK A.G. Lidar devices (F.i. LMS5xx). This example makes use of the TCP connection and SICK_Work structure as described in my other tips/tricks on the website. If you are not comfortable with the library, feel free to examine these other tips/tricks to help you out.

The total library itself enables the user to generate a 3D on screen Lidar image within 15 lines of code (without error handling, etc.)

Why am I posting this? My goal is to create an easy, open platform for Lidar devices as they are more commonly used. If you see anything that should be different, feel free to change the source code and post the result as comment.

Background

As mentioned, this tip only describes part of the total communication library (LMS5lib) which in its turn is part SICKlibof a bigger framework (all blocks together) of libraries I internally use to demonstrate Lidar devices. The library has been used for approximately 2 years now and works perfectly for our demos and field tests.

All the smaller individual parts can be used to convert SICK Lidar data into 3D pointclouds, LAS, CSV, bitmap or 3D pointclouds with the least amount of effort giving you the power to generate awesome pointclouddata, 3D representation or bitmaps out of these devices.

This example shows you how to connect to a LMS1xx, LMS5xx, TiM3xx or JeFxxx LIDAR device, retrieve measurement data and convert it to a useful .NET structure. This structure will be used later on in other functions (export, draw, etc.) and forms the base structure for the library.

The base/reference projects are posted here also as these parts of the library are mandatory for the example to work. As said; for use of the Communication library part, look at the other posts.

This code will only describe how to send commands to and retrieve data from the LMS LIDAR device. As of this example and the probability that you are owning a LMS LIDAR isn't that big, the other examples will show the handling of the telegrams based on pre-recorded data.

Using the Code

In the example, we are going to use the TCP client from the communication library to communicate with the LMS device, the LMS5lib is going to be used to convert the data and use the baseclass to show you a shortcut to device functions. Also, we are going to use the SICK_Work library (bunch of classes) to convert the RAW data string to a more useful structure (the string is just there to show/store you the RAW data from the device).

VB.NET
Public LMS_TCPconnection As New SICK_Communication.Ethernet.TCP_client
Public LMS_DataProcessor As New SICK_LMS5xx_PRO_Library.DataProcessing
Public LMS_ReturnString As String
Public LMS_MEasurementStructure As New SICK_Work.SICK_Laserdevices.Scandata

Connect to the device with its IP-address and use the default port 2111 using the TCP client from the communication library:

VB.NET
LMS_TCPconnection.Client_Connect(TextBox1.Text, 2111)

If the connection has been made, request a single measurement by using the shared function from the LMS5lib:

VB.NET
LMS_TCPconnection.SendString(SICK_LMS5xx_PRO_Library.DeviceFunctions.GetMeasurement,
   SICK_Communication.Ethernet.TCP_client.FramingTypes.Stx_Etx)

(The framing type enum will make sure the string is formatted correctly.)

After that, wait for the device to respond (To do this, just monitor the available property in the TCP client class) and retrieve the sensor data as ASCII text:

VB.NET
'Wait for the Device to respond
Do Until LMS_TCPconnection.Available > 0
Loop

' Read the string from the sensor
LMS_ReturnString = LMS_TCPconnection.Readavailable_string

After that, you can display the RAW string in a textbox (screenshot from the example):

Image 2

Now we have a bunch of semi HEX formatted ASCII text where all the measurements (in radial format), input, output and optionally encoder information is stored. Now the LMS5lib kicks in and lets you convert the data into a structure with the slightest bit of work:

VB.NET
'Convert to the SICK_Work structure
    LMS_MEasurementStructure = LMS_DataProcessor.Process_SRA_LMDscandata(LMS_ReturnString)

Just check if there were any errors during the conversion:

VB.NET
If LMS_MEasurementStructure.Error_Occured = False Then
    'The conversion has gone perfectly without any problems
End If

and you are done, up to 5 echos of measurement data (still in radial format) in a nice and structured manner:

Image 3

The conversion of this data to 2D or 3D pointclouds, 2D drawing and 3D calibration (with Euler angles) will be done in the other tips/tricks later.

Points of Interest

The Process_SRA_LMDscandata will always return a structure even if you put in nothing or wrong data. Checking for correct conversion is almost mandatory.

The reference files are added as a pre-build set of the library required to build the sample. Remember to share!!

History

The program itself is licensed as GPL software. Some examples were picked from the internet. If I accidentally used anything without permission or overlooked anything, please let me know and I'll correct my errors.

So far, this is the latest adaptation to the library by myself and my colleague referred to as the V4-library. Improvements are always welcome, hope you enjoy using it.

Other Tips

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Help desk / Support
Netherlands Netherlands
Working at a help desk for more then 10 years now, last few years being more into programming examples for industrial sensors and camera's. Expertise Vision sensors and camera's, last two years trying to explore the possibilities of laser scanning devices in industrial applications.

Comments and Discussions

 
QuestionConvert LMs511 raw data to distance Pin
Member 1223796322-Sep-18 10:39
Member 1223796322-Sep-18 10:39 
AnswerRe: Convert LMs511 raw data to distance Pin
Member 1587513525-Dec-22 4:37
Member 1587513525-Dec-22 4:37 
GeneralRe: Convert LMs511 raw data to distance Pin
OriginalGriff25-Dec-22 4:38
mveOriginalGriff25-Dec-22 4:38 
GeneralRe: Convert LMs511 raw data to distance Pin
Chris Jorna25-Dec-22 5:09
Chris Jorna25-Dec-22 5:09 
GeneralRe: Convert LMs511 raw data to distance Pin
OriginalGriff25-Dec-22 5:42
mveOriginalGriff25-Dec-22 5:42 
GeneralRe: Convert LMs511 raw data to distance Pin
Chris Jorna25-Dec-22 11:23
Chris Jorna25-Dec-22 11:23 
GeneralRe: Convert LMs511 raw data to distance Pin
Member 1587513526-Dec-22 3:00
Member 1587513526-Dec-22 3:00 
GeneralRe: Convert LMs511 raw data to distance Pin
Chris Jorna26-Dec-22 4:06
Chris Jorna26-Dec-22 4:06 
GeneralRe: Convert LMs511 raw data to distance Pin
Member 1587513526-Dec-22 6:27
Member 1587513526-Dec-22 6:27 
QuestionMRS1000 Pin
Member 148737219-Nov-17 23:21
Member 148737219-Nov-17 23:21 
QuestionLMS400? Pin
Member 1332536224-Jul-17 11:04
Member 1332536224-Jul-17 11:04 
QuestionThanks Pin
weymar.lara29-May-17 3:29
weymar.lara29-May-17 3:29 
QuestionSICK_Communication Source Code? Pin
Roland Painter29-Nov-16 16:26
Roland Painter29-Nov-16 16:26 
QuestionOpen source gateway for interfacing with LMS500 Pin
Member 864828025-Nov-15 19:57
Member 864828025-Nov-15 19:57 
QuestionNeed LMS511-20100 Pro SDK Pin
Muhammad Farooq18-Jun-15 1:34
Muhammad Farooq18-Jun-15 1:34 
AnswerRe: Need LMS511-20100 Pro SDK Pin
Chris Jorna18-Jun-15 10:44
Chris Jorna18-Jun-15 10:44 
GeneralRe: Need LMS511-20100 Pro SDK Pin
Muhammad Farooq18-Jun-15 20:42
Muhammad Farooq18-Jun-15 20:42 
QuestionSICK_LMS5xx_PRO_Library Missing...? Pin
Jyri Peltola20-Apr-15 0:34
Jyri Peltola20-Apr-15 0:34 
AnswerRe: SICK_LMS5xx_PRO_Library Missing...? Pin
Chris Jorna27-Apr-15 8:44
Chris Jorna27-Apr-15 8:44 
QuestionThanks Pin
Ameer Sameer Hamood - IT19-Apr-15 23:07
Ameer Sameer Hamood - IT19-Apr-15 23:07 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.