Scanse.io Sweep Lidar installation on GoPiGo2

I’m writing this the day after completing the setup so I may have forgotten some part of the process. I believe it went like this:

 Image

Clone the Sweep-SDK Repository

Log in to the Raspberry PI OS. Open a terminal and clone the sweep repo.

git clone https://github.com/scanse/sweep-sdk

Install CMAKE

Install CMAKE on Raspberry Pi in order to build `libsweep.so` in *sweep-sdk*.
Replace the version number with the latest, which in my case was 3.8.1 (https://cmake.org/download/).

INSTRUCTIONS FROM: http://osdevlab.blogspot.tw/2015/12/how-to-install-latest-cmake-for.html

1. Create a folder

pi@raspberrypi ~ $ mkdir Download
pi@raspberrypi ~ $ cd Download

2. Download the compressed file and extract it

pi@raspberrypi ~/Download $ wget https://cmake.org/files/v3.8/cmake-3.8.1.tar.gz
pi@raspberrypi ~/Download $ tar -xvzf cmake-3.8.1.tar.gz

3. Compile and install cmake. This will take several minutes.

pi@raspberrypi ~/Download $ cd cmake-3.4.1/
pi@raspberrypi ~/Download/cmake-3.4.1 $ sudo ./bootstrap
pi@raspberrypi ~/Download/cmake-3.4.1 $ sudo make
pi@raspberrypi ~/Download/cmake-3.4.1 $ sudo make install

Install libsweep

INSTRUCTIONS FROM: https://github.com/scanse/sweep-sdk/tree/master/libsweep

1. Enter the libsweep directory

cd sweep-sdk/libsweep

2. Create and enter a build directory

mkdir -p build
cd build

3. Build and install the libsweep library

cmake .. -DCMAKE_BUILD_TYPE=Release
cmake --build .
sudo cmake --build . --target install
sudo ldconfig

Install SweepPy

INSTRUCTIONS FROM: https://github.com/scanse/sweep-sdk/tree/master/sweeppy

1. Go to the `sweep-sdk/sweeppy` folder where `setup.py` is located.
2. Install sweep for python. (I don’t know if both versions is necessary but that’s what I did.)

python3 setup.py install --user
sudo python setup.py install --user

Run Sample Code

1. Connect Scanse Sweep to USB. I used the center top USB port for the Scanse lidar.

2. Run some code. (I skipped trying to add the `sweep` module globally and just wrote my test file inside the `sweeppy` folder.)

from sweeppy import Sweep

with Sweep('/dev/ttyUSB0') as sweep:
    print(sweep.get_motor_speed())
    print(sweep.get_sample_rate())
    sweep.start_scanning()

    for scan in sweep.get_scans():
        print('{}\n'.format(scan))

Note:

You cannot “get” or “set” while scanning. Do it before “start_scanning()” or after “stop_scanning()”.