Hello,
I have a python code that i get information that i need from rplidar a1m8.
the data i need is angle and distance.
I need a help to get this data on arduino and use it.
Python code:
import sys
import time
from rplidar import RPLidar
import serial
import struct
arduino = serial.Serial('com6', 115200)
angleoffset = 0
PORT_NAME = 'COM5' # this is for the Lidar
def run():
'''Main function'''
lidar = RPLidar(PORT_NAME)
lidar.start_motor()
time.sleep(1)
info = lidar.get_info()
print(info)
try:
print('Recording measurments... Press Crl+C to stop.')
try:
for measurment in lidar.iter_measurments():
if (measurment[2] > 0 and measurment[2] < 360):
if (measurment[3] < 2000 and measurment[3] > 100):
angle = measurment[2]
distance = measurment[3]
print("Angle: ", angle - angleoffset)
print("Distance: ", distance)
except KeyboardInterrupt:
print('Stopping.')
except KeyboardInterrupt:
print('Stopping.')
lidar.stop()
lidar.stop_motor()
lidar.disconnect()
if name == 'main':
run()