Well, I have given up on my first chip the LD07 and may make a move for the fishfinder to UniTree lidar. I found this lidar on amazon and it looks great for my purpose, it does ros and scripting and has some major documentation i have read and compiled a python version of their program to look at till i buy....sooon....
unitreelidar.py
Code: Select all
import time
from unitree_lidar_sdk import *
lreader = createUnitreeLidarReader()
cloud_scan_num = 18
port_name = "/dev/ttyUSB0"
if lreader.initialize(cloud_scan_num, port_name):
print ("Unilidar initialization failed! Exit here!")
exit(-1)
else:
print ("Unilidar initialization succeed!")
print ("Set Lidar working mode to: STANDBY ...")
lreader.setLidarWorkingMode(STANDBY)
time.sleep(1)
print ("Set Lidar working mode to: NORMAL ...")
lreader.setLidarWorkingMode(NORMAL)
time.sleep(1)
print ()
while True:
if lreader.runParse() == VERSION:
print ("lidar firmware version =", lreader.getVersionOfFirmware())
break
time.sleep(0.5)
print ("lidar sdk version =", lreader.getVersionOfSDK())
time.sleep(2)
count_percentage = 0
while True:
if lreader.runParse() == AUXILIARY:
print ("Dirty Percentage =", lreader.getDirtyPercentage(), "%")
if count_percentage > 2:
break
if lreader.getDirtyPercentage() > 10:
print ("The protection cover is too dirty! Please clean it right now! Exit here ...")
exit(0)
count_percentage += 1
time.sleep(0.5)
print ()
time.sleep(2)
print ("Turn on all the LED lights ...")
led_table = [0xFF] * 45
lreader.setLEDDisplayMode(led_table)
time.sleep(2)
print ("Turn off all the LED lights ...")
led_table = [0x00] * 45
lreader.setLEDDisplayMode(led_table)
time.sleep(2)
print ("Set LED mode to: FORWARD_SLOW ...")
lreader.setLEDDisplayMode(FORWARD_SLOW)
time.sleep(2)
print ("Set LED mode to: REVERSE_SLOW ...")
lreader.setLEDDisplayMode(REVERSE_SLOW)
time.sleep(2)
print ("Set LED mode to: SIXSTAGE_BREATHING ...")
lreader.setLEDDisplayMode(SIXSTAGE_BREATHING)
print ()
time.sleep(2)
while True:
result = lreader.runParse()
if result == NONE:
continue
elif result == IMU:
print ("An IMU msg is parsed!")
imu = lreader.getIMU()
print ("\tstamp =", imu.stamp, "id =", imu.id)
print ("\tquaternion (x, y, z, w) =", imu.quaternion)
print ("\ttimedelay (us) =", lreader.getTimeDelay())
elif result == POINTCLOUD:
print ("A Cloud msg is parsed!")
cloud = lreader.getCloud()
print ("\tstamp =", cloud.stamp, "id =", cloud.id)
print ("\tcloud size =", len(cloud.points), "ringNum =", cloud.ringNum)
print ("\tfirst 10 points (x,y,z,intensity,time,ring) =")
for point in cloud.points[:10]:
print ("\t (", point.x, ",", point.y, ",", point.z, ",", point.intensity, ",", point.time, ",", point.ring, ")")
print ("\t ...")
print ("\ttimedelay (us) =", lreader.getTimeDelay())
else:
continue
the new python module i made that resides next to the main file in the run location as unitree_lidar_sdk.py
Code: Select all
import math
from typing import List
PI_UNITEE = 3.14159265358979323846
DEGREE_TO_RADIAN = PI_UNITEE / 180.0
RADIAN_TO_DEGREE = 180.0 / PI_UNITEE
def get_system_timestamp() -> float:
pass
class PointUnitree:
def __init__(self, x: float, y: float, z: float, intensity: float, time: float, ring: int):
self.x = x
self.y = y
self.z = z
self.intensity = intensity
self.time = time
self.ring = ring
class PointCloudUnitree:
def __init__(self, stamp: float, id: int, ringNum: int, points: List[PointUnitree]):
self.stamp = stamp
self.id = id
self.ringNum = ringNum
self.points = points
class ScanUnitree:
def __init__(self, stamp: float, id: int, validPointsNum: int, points: List[PointUnitree]):
self.stamp = stamp
self.id = id
self.validPointsNum = validPointsNum
self.points = points
class IMUUnitree:
def __init__(self, stamp: float, id: int, quaternion: List[float], angular_velocity: List[float], linear_acceleration: List[float]):
self.stamp = stamp
self.id = id
self.quaternion = quaternion
self.angular_velocity = angular_velocity
self.linear_acceleration = linear_acceleration
class MessageType:
NONE = 0
IMU = 1
POINTCLOUD = 2
RANGE = 3
AUXILIARY = 4
VERSION = 5
TIMESYNC = 6
class LidarWorkingMode:
NORMAL = 1
STANDBY = 2
class LEDDisplayMode:
FORWARD_SLOW = 2
FORWARD_FAST = 3
REVERSE_SLOW = 4
REVERSE_FAST = 5
TRIPLE_FLIP = 6
TRIPLE_BREATHING = 7
SIXSTAGE_BREATHING = 8
class UnitreeLidarReader:
def initialize(self, cloud_scan_num: int = 18, port: str = "/dev/ttyUSB0", baudrate: int = 2000000, rotate_yaw_bias: float = 0, range_scale: float = 0.001, range_bias: float = 0, range_max: float = 50, range_min: float = 0) -> int:
pass
def initializeUDP(self, cloud_scan_num: int = 18, lidar_port: int = 5001, lidar_ip: str = "10.10.10.10", local_port: int = 5000, local_ip: str = "10.10.10.100", rotate_yaw_bias: float = 0, range_scale: float = 0.001, range_bias: float = 0, range_max: float = 50, range_min: float = 0) -> int:
pass
def runParse(self) -> MessageType:
pass
def reset(self) -> None:
pass
def getCloud(self) -> PointCloudUnitree:
pass
def getIMU(self) -> IMUUnitree:
pass
def getVersionOfFirmware(self) -> str:
pass
def getVersionOfSDK(self) -> str:
pass
def getTimeDelay(self) -> int:
pass
def getDirtyPercentage(self) -> float:
pass
def setLidarWorkingMode(self, mode: LidarWorkingMode) -> None:
pass
def setLEDDisplayMode(self, led_table: List[int]) -> None:
pass
def setLEDDisplayMode(self, mode: LEDDisplayMode) -> None:
pass
def printConfig(self) -> None:
pass
def createUnitreeLidarReader() -> UnitreeLidarReader:
pass
If i cannot get this code to work i can use the ros or ros2 method to get a point cloud and compute a picture. since it is in their documentaion.
350 on amazon....yes.....Jay T
unitree.jpg
You do not have the required permissions to view the files attached to this post.