Demo: Lidar 360 distance measurements - Toby-eaaa/Mini_Pupper_eaaa GitHub Wiki
Here
Lidar demo:Here
OkdoLidar.py:Here
Setup the Lidar and serial communication:This demo will use okdoLidar.py (written by Jonas Wehding).
The demo will use the angle, distance, and confidence measured by the Lidar and processed in okdoLidar.py.
The data is 1 list consisting of 3 lists:
dat[0][x] is the angle
dat[1][x] is the distance
dat[2][x] is the confidende
Set the correct USB port here it’s ttyUSB0:
s = ser.Serial(port="/dev/ttyUSB0",baudrate=230400)
The program will first check if anything is less than 100mm to the pupper, and the confidence is more than 200
if (((dat[1][i]) < 100) & (dat[2][i][2] > 200)):
If so, different actions can be taken depending on the angle:
match dat:
case _ if((dat[0][i])> 90) & ((dat[0][i]) <= 250):
print("venstre")
msg['rx'] = -0.1
msg['ly'] = 0.0
case _ if((dat[0][i]) >= 290):
print("højre")
msg['rx'] = 0.1
msg['ly'] = 0.0
case _ if((dat[0][i])>250) & ((dat[0][i]) < 290):
print("RUN!")
msg['rx'] = 0.0
msg['ly'] = 0.0
case _ if((dat[0][i])>250) & ((dat[0][i]) < 290):
print("RUN!")
msg['rx'] = 0.0
msg['ly'] = 0.0
case _ if((dat[0][i])< 90) & ((dat[0][i]) >= 0):
print("højre")
msg['rx'] = 0.1
msg['ly'] = 0.0
The demo works as the sequencer. For inspiration for movements see the sequencer demo: