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 of 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).
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:
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
:
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:
Do Until LMS_TCPconnection.Available > 0
Loop
LMS_ReturnString = LMS_TCPconnection.Readavailable_string
After that, you can display the RAW string
in a textbox
(screenshot from the example):
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:
LMS_MEasurementStructure = LMS_DataProcessor.Process_SRA_LMDscandata(LMS_ReturnString)
Just check if there were any errors during the conversion:
If LMS_MEasurementStructure.Error_Occured = False Then
End If
and you are done, up to 5 echos of measurement data (still in radial format) in a nice and structured manner:
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