SkoltechRobotics / rplidar

Python module for RPLidar A1 and A2 rangefinder scanners
MIT License
187 stars 126 forks source link

rplidar.stop() and rplidar.stop_motor() don't do anything #33

Closed RyanMieras closed 4 years ago

RyanMieras commented 4 years ago

I am running an RPLidar A1M8 R5 model through the usb2serial board, into usb on a rasp pi 3b+. I have yet to be able to get any combination of commands involving stop() and stop_motor() to actually get the motor to stop sending/receiving, return to the "zero" point, and stop spinning. Has anyone else been successful in this?

The "get_info()" and "get_health()" functions work just fine. But the lidar scanner does not respond at all to the following stop commands....BUT, it DOES disconnect...

from rplidar import RPLidar

lidar = RPLidar('/dev/ttyUSB0')

lidar.stop() lidar.stop_motor() lidar.disconnect()

RyanMieras commented 4 years ago

Okay, so turns out a pause is required after the "stop_motor()" function, in order to actually stop the motor from spinning. Otherwise, it doesn't have time to "stop" before going back into "waiting for you to talk to me again" mode.

For example:

import time 
from rplidar import RPLidar

lidar = RPLidar('/dev/ttyUSB0')

lidar.stop_motor()
time.sleep(5) # to sleep 5 seconds

However, after 5 seconds, it will start spinning again. And i presume the "stop()" function simply stops the laser from scanning/pinging. according to the sdk manual.