Closed arjunskumar closed 3 years ago
I really need to spend some time and fix the build system, using bazel was probably a mistake..
Anyways, building: You are going to want to spin up a python docker container (or use a system interpreter, if you want to try your luck) for whatever cpython version (must match both major and minor release) your project is using, in theory it should support python >=3.6
This container is going to need bazel
in it, because that was the build system I elected to use when i created this project.
Example dockerfile:
FROM python:3.6
RUN apt update && apt install -y sudo
RUN sudo apt install curl gnupg && \
curl -fsSL https://bazel.build/bazel-release.pub.gpg | gpg --dearmor > bazel.gpg && \
sudo mv bazel.gpg /etc/apt/trusted.gpg.d/ && \
echo "deb [arch=amd64] https://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
run sudo apt update
run sudo apt install bazel
run pip install poetry
run poetry config virtualenvs.create false
WORKDIR build
copy . .
CMD ["/bin/bash"]
from there,
bazel build //rplidar_python:build_wheel
and an installable wheel will be generated in bazel-bin/rplidar_python/rplidar_sdk-0.1.0-py3-none-any.whl
Things that could use improvement:
setuptools
Have the built wheel have the correct metadata
Once the wheel is installed,
from rplidar_sdk import rplidar_sdk
lidar = rplidar_sdk.Lidar()
lidar.connect()
info = lidar.get_device_info()
scan = lidar.read()
@theunkn0wn1 Thanks for the detailed steps. I was able to run the script but it is showing RuntimeError: scan failed!
Hrm, looks like the .connect
call failed, all subsequent calls will fail if the connection fails.
Unfortunately the raw error code doesn't mean anything to me (its an opaque value).
Things to check:
/dev/ttyUSB0
? (this is configurable)Aight so it does sound like something in this wrapper, which is odd.
This library is basically just:tm: a pybind11
wrapper around the underlying slam_tech/rplidar_sdk, so im not sure whats presently going wrong.
I don't happen to have a lidar on hand, though i should be getting access in the next few days so i can do some debugging. Will update once I have regained access to an applicable Lidar and done some debugging.
Ok. @arjunskumar My apologies for the delay.
Reacquired a Lidar (A2M8).
If your lidar is anything like what's on my desk: the default baud rate on .connect
isn't actually sane.
try explicitly passing a baud rate to the call.
In [3]: driver.connect("/dev/ttyUSB0", baud=115200)
Out[3]: 0
In [4]: driver.get_device_info()
Out[4]:
(0,
DeviceInfo(model=40, firmware_version=281, hardware_version=5, serialnum=195))
You may also want to try building off #4 , where I completely reworked the build system (so now it works with pip install .
)
@theunkn0wn1 Thanks, I dont have access to the Rplidar now, will reopen the issues if I didnt get the expected output
Could you give some hints to build and run this package?