3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

YDLIDARのGS2をpythonで扱う

Last updated at Posted at 2023-02-04

背景

  • RCサイズのモビリティに適したLidarが欲しい
  • サンプリングレートが30Hz位は欲しい
  • 30cm位は検知範囲欲しい
  • ホビー用途でお財布にやさしい

➔YDLIDAR GS2

GS2image.png
https://www.ydlidar.com/products/view/11.html

価格は6000円位
https://ja.aliexpress.com/item/1005004291137996.html
複数利用のため、808nmと850nmの2つの帯域が有る。

Pythonで使いたい

DonkeycarやJetracerに簡単に組み込むため、pythonが良い

サンプルの場所とパラメータ設定に注意

lidar_tutorial.py
import os
import ydlidar

if __name__ == "__main__":
    ydlidar.os_init();
    laser = ydlidar.CYdLidar();
    ports = ydlidar.lidarPortList();
    port = "/dev/ydlidar";
    for key, value in ports.items():
        port = value;
    laser.setlidaropt(ydlidar.LidarPropSerialPort, port);
-    laser.setlidaropt(ydlidar.LidarPropSerialBaudrate, 512000);
+    laser.setlidaropt(ydlidar.LidarPropSerialBaudrate, 921600);
-    laser.setlidaropt(ydlidar.LidarPropLidarType, ydlidar.TYPE_TOF);
+    laser.setlidaropt(ydlidar.LidarPropLidarType, ydlidar.TYPE_GS);
    laser.setlidaropt(ydlidar.LidarPropDeviceType, ydlidar.YDLIDAR_TYPE_SERIAL);
    laser.setlidaropt(ydlidar.LidarPropScanFrequency, 10.0);
    laser.setlidaropt(ydlidar.LidarPropSampleRate, 20);
    laser.setlidaropt(ydlidar.LidarPropSingleChannel, False);

できた(jetsonnanoで実行)

shell
(env) jetson@jetson-desktop:~/YDLidar-SDK-master/ydlidar_tutorials-master/python_tutorials$ python lidar_tutorial/lidar_tutorial.py
YDLidar SDK initializing
YDLidar SDK has been initialized
[YDLIDAR]:SDK Version: 1.1.3
send: A5A5A5A500640000
send: 64
LiDAR successfully connected
send: A5A5A5A500640000
send: 64
[YDLIDAR]:Lidar running correctly ! The health status: good
send: A5A5A5A500620000
send: 62
[YDLIDAR] Connection established in [/dev/ttyUSB0][921600]:
Firmware version: 2.9
Hardware version: 0
Model: GS2
Serial: 2022090200140896
LiDAR init success, Elapsed time 129 ms
2
send: A5A5A5A500640000
send: 64
send: A5A5A5A500600000
send: 60
[YDLIDAR] GS Lidar count 1
send: A5A5A5A500610000
send: 61
send: A5A5A5A500630000
send: 63
[GS2Lidar] Create GS2 thread 0x931FB1F0
[CYdLidar] Successed to start scan mode, Elapsed time 99 ms
[YDLIDAR] Fixed Size: 506
[YDLIDAR] Sample Rate: 4K
[YDLIDAR INFO1] Current Sampling Rate : 4K
[YDLIDAR INFO] Now YDLIDAR is scanning ......
Scan received[ 1675496681637647000 ]: 160 ranges is [ 1257.86163533801 ]Hz
Scan received[ 1675496681767328000 ]: 160 ranges is [ 12048.192917021735 ]Hz

これからパラメータをいじって、モビリティの挙動の制御を進める。

3
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?