Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lidar.connect() does not clear DTR and motor will stop #10

Open
fdoljack opened this issue Aug 20, 2023 · 0 comments
Open

lidar.connect() does not clear DTR and motor will stop #10

fdoljack opened this issue Aug 20, 2023 · 0 comments

Comments

@fdoljack
Copy link

fdoljack commented Aug 20, 2023

Testing on the A1M8 which is not set up for variable motor speed using the Slamtec USB adapter board I found that this initiating command leaves the CTRL_MOT line low, after which the motor comes to a stop. This line is actually DTR on the UART. Most example code for scanning immediately implements "lidar.set_motor_pwm(500)", which in turn clears DTR and the motor continues to run. I found that sending other commands did not fix this and only the set_motor_pwm() command corrected the state of DTR. Failure to use the set_motor_pwm() command after the connect() command will cause scans to fail. The use of no other command fixes DTR and it remains low. In the Slamtec C++ SDK in net_serial.cpp these lines of code are found which addresses the point.

//Clear the DTR bit to let the motor spin
clearDTR();

To demonstrate the issue here one can use the following test code but with a time delay.

from pyrplidar import PyRPlidar
import time

lidar = PyRPlidar()
lidar.connect(port="/dev/ttyUSB0", baudrate=115200, timeout=3)

info = lidar.get_info()
print("info :", info)

health = lidar.get_health()
print("health :", health)

samplerate = lidar.get_samplerate()
print("samplerate :", samplerate)

scan_modes = lidar.get_scan_modes()
print("scan modes :")
for scan_mode in scan_modes:
print(scan_mode)

time.sleep(6.0)

#now watch the motor come to a stop
#after disconnect() the motor starts again

lidar.disconnect()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant