Skip to content

YDLIDAR/etlidar_sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ETLIDAR SDK Build Status Build status codebeat badge

Introduction

ETLIDAR(https://www.ydlidar.com/) series is a set of high-performance and low-cost TOF LIDAR sensors, which is the perfect sensor of 2D SLAM, 3D reconstruction, multi-touch, and safety applications.

If you are using ROS (Robot Operating System), please use our open-source ROS Driver .

Release Notes

Title Version Data
SDK 1.0.2 2019-04-13

How to build ETLIDAR SDK samples

$ git clone https://github.com/ydlidar/etlidar_sdk

$ cd etlidar_sdk

$ git checkout master

$ cd ..

Linux:

$ mkdir build

$ cd build

$ cmake ../etlidar_sdk   ##windows: cmake -G "Visual Studio 14 2017 Win64" ../etlidar_sdk 

$ make

Windows: $ mkdir build

$ cd build

$ cmake -G "Visual Studio 14 2017 Win64" ../etlidar_sdk 

$ make

Compile wth Qt: 1). Qt configuration cmake 2). Open the CmakeLists.txt project file with Qt.

How to run ETLIDAR SDK samples

linux:

$ ./ydlidar_test
Please enter the lidar IP[192.168.0.11](yes):yse
[YDLidar]: SDK Version: 1.1
[YDLidar]: LIDAR Version: 1.1
[YDLidar]: Opening scan and checking whether Lidar is abnormal.........
[YDLidar]: [YDLIDAR INFO] Now YDLIDAR is scanning ......

windows:

$ ydlidar_test.exe
Please enter the lidar IP[192.168.0.11](yes):yse
[YDLidar]: SDK Version: 1.1
[YDLidar]: LIDAR Version: 1.1
[YDLidar]: Opening scan and checking whether Lidar is abnormal.........
[YDLidar]: [YDLIDAR INFO] Now YDLIDAR is scanning ......

Data structure

data structure:

typedef struct _lidarPot {
	/**
	* @brief range
	*/
	float range;
	/**
	* @brief angle
	*/
	float angle;
	/**
	* @brief intensity
	*/
	int   intensity;
 
}lidarPot;

typedef struct _lidarData {
	/**
	* @brief ranges.
	*/
	std::vector<lidarPot> data;

	/**
	* @brief headFrameFlag.
	*/
	int headFrameFlag;

	/**
	* @brief frame timestamp in nanoseconds.
	*/
	uint64_t self_timestamp;

	/**
	* @brief system time.
	*/
	uint64_t system_timestamp;
	/**
	* @brief scan_time
	*/
	uint64_t scan_time;
} lidarData;

example parsing:

for(size_t i =0; i < scan.data.size(); i++) {

  // current angle
  float angle = scan.data[i].angle ;// radian format

  //current distance
  float angle = scan.data[i].range ;//meters

  //current intensity
  int intensity = scan.data[i].intensity;

}

laser callback function code :

Quick Start

The best way to learn how to use sdk is to follow the tutorials in our sdk guide:

https://github.com/yangfuyuan/etlidar_sdk/Samples

If you want to learn from code examples, take a look at the examples in the Samples directory.

Include Header

#include "ETLidarDriver.h"
#include <config.h>
#define DEVICE_IP "192.168.0.11"

Simple Usage

int main(int argc, char **argv) {

    char* lidarIp = DEVICE_IP;
	if (argc > 1) {
        lidarIp = argv[1];
    }
    ydlidar::init(argc, argv);

     ydlidar::ETLidarDriver lidar;
     result_t ans = lidar.connect(lidarIp);
     if(!IS_OK(ans)) {
     	ydlidar::console.error("Failed to connecting lidar...");
     	return 0;
     }
     
     bool rs = lidar.turnOn();
     while (rs && ydlidar::ok()) {
    	lidarData scan;
    	ans = lidar.grabScanData(scan);
    	if(IS_OK(ans)) {
      		ydlidar::console.message("scan recevied[%llu]: %d ranges",scan.system_timestamp, scan.data.size());
    	} else {
      		ydlidar::console.warning("Failed to get scan data");
    	}
     }
    lidar.turnOff();
    lidar.disconnect();
    return 0;
    
}

Note: Use sdk to be a "try catch" syntax to do exception handling.

Contact EAI

If you have any extra questions, please feel free to contact us

About

2D TOF LIDAR SDK

Resources

License

Stars

Watchers

Forks

Packages

No packages published