Setup Notepad++ to remotely edit GoPiGo2 files

The Dexter website has instructions on how to do this but I want to summarize it again here with some small changes. https://www.dexterindustries.com/BrickPi/brickpi-tutorials-documentation/program-it/hints-and-tricks/

1) Open Notepad++ and add NppFTP plugin if you don’t already have it.

  1. Plugins -> Plugin Manager -> Show Plugin Manager
  2. Find NppFTP and install it.

2) “Show NppFTP Window” in the Plugins dropdown.

3) Click the gear symbol and then “Profile settings”

4) Add a new profile. Call it “GoPiGo” or any other name and edit the following fields:

Hostname: dex.local
Connection type: SFTP
Port: 22
Username: pi
Password: robots1234  (or your new password)
Initial remote directory: /home/pi  (or your preferred directory)

5) Authorize remote editing on Raspberry Pi.

On Raspberry Pi, open a terminal and enter this:

sudo find /home/pi -type d -exec chmod 777 {} \;

This will make everything editable. If you only want to set specific files then replace “/home/pi” with another file or folder.

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()”.

Cython workflow

1)
cython_file.pyx
Create a *.pyx file containing Python or Cython code. The *.pyx file contains the code that will be compiled to C.

2)
cython_setup.py
The setup *.py file contains the code that runs the compile process.

The setup *.py file:

import numpy
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext

pyx_filename = "cython_file.pyx"
new_module_name = "cython_module"

ext_modules = [Extension(new_module_name,
                         [pyx_filename],
                         include_dirs=[numpy.get_include()]
                        )]
setup(
  cmdclass = {'build_ext': build_ext},
  ext_modules = ext_modules
)

Lines 1 and 11 are necessary if you are using NumPy in the pyx file, otherwise they can be commented out.

3)
C:\...>cython_setup.py build_ext --inplace
In the command prompt from the setup file directory execute the code above. This will create a cython_file.c, a build directory, and a cython_module.pyd file.

3b)
error: Unable to find vcvarsall.bat
If you get this error. If may be because you have Visual C++ 2010 installed instead of the 2008 that it looks for. In the command prompt enter: SET VS90COMNTOOLS=%VS100COMNTOOLS%
This will redirect the search to the 2010 version.

3c)
The build directory and *.c file are not necessary and can be deleted. The *.pyd file is what you keep and import into projects.

4)
import cython_module
In a new project the C code module can be imported like any other module. The methods can be individually imported or accessed by cython_module.method()

PyCUDA fail and Cython win

I tried yet again to get PyCUDA working and failed. Getting an error that says the _driver module in pycuda is not there. The tips on installing that I’ve seen failed to solve the problem, so I’ll put this off for another time.

I can get CUDA working in C++ but I’m not too familiar with C++ and seem to always hit a wall when trying to use it. Always some package or library not found.

I did get Cython and scipy.weave working. If I need a speedup I guess this is the way to go for now.

When compiling the cython *.pyx file I got a error: Unable to find vcvarsall.bat
Typing SET VS90COMNTOOLS=%VS100COMNTOOLS% fixed this problem. A tip I found on stackoverflow that guides cython to my Visual C++ 2010 install instead of looking for 2008. After doing this, I got a different error, error: command ‘mt.exe’ failed with exit status 31 but it completed building the *.pyd file and I was then able to import and use it.

It works just like the tutorial at http://docs.cython.org/src/quickstart/build.html says except for having to enter the SET command before building.

Google App Engine Installed

Installing the Google App Engine was pretty easy. And there are also tutorials on the website.

To get an account with Google App Engine, you need to be able to receive a phone text. I don’t have a cell phone number to give out so I used the web-based Pinger service. When I gave the number to Google App Engine registration to get the password, it said there was an error in sending the text, but it actually went through and I got the verification code off Pinger.

I want to note one thing that confused me about uploading apps. “Application ID” vs. “Application title”. In the Google App Engine Launcher, the name column is actually the App ID and is the same as the first line of the ‘app.yaml’, just called application: and should also be the same as the Application Identifier that you register on Google App Engine. The Application Title seems to do nothing but you can make it the same as the python application.

The bottom line of ‘app.yaml’ says script:, and this is where the name of the python module goes, except you replace the extension .py with .app.

To summarize, app.yaml has two important lines (for a beginner like me):

application: HelloWorld

this name after application in app.yaml must be the same as the registered name on the App Engine: HelloWorld.appspot.com. The name might be taken already so be prepared to change the application name in app.yaml.

  script: helloworld.app

calls the helloworld.py program that must(?) reside in the same folder as app.yaml.

Packages

Python XY with all packages installed

PyEphem

  • Ephemeris program for calculating planet and satellite positions
  • Written in C
  • “import ephem

Pydap

  • Tools for using OPeNDAP
  • “import pydap
  • Installed from the internet using the command prompt:
  1. “easy_install Paste”  (not sure if this is needed, but doesn’t take long)
  2. “easy_install Pydap”

Sync into the clouds

During the time I left my flashdrive in the computer lab and was not able to pick it up for a week, I decided to look for a good way to backup my files. Long story short: Skydrive – doesn’t sync >> Live Mesh –  syncs but hidden sync status >> Dropbox – much better! I’ve been using it for several days now. It is great. I really like having the little status icon on each file showing its sync status. It also saves old versions of all files which Live Mesh does not do. And if files were changed on different computers before syncing then it appears to create a separate file with an extended name showing the computer of origin.

The only advantage for Live Mesh that I can see so far (apart from having extra cloud space if you run out of Dropbox space) is that you can sync any folder. Dropbox creates a single folder where you throw everything you want synced into.

Right now, I’m using Live Mesh to sync the .spyder2 configuration folder with no problem so far. This might possibly be problematic if the configuration file is made for the particular computer it is on. I wanted to keep my template and workspace configurations the same on all three computers that I use for programming.  I use Dropbox for all my programs and everything else.

Live Mesh – sync any folder you can’t conveniently move to the Dropbox.

  • Program folders with configuration files (possibly may cause problems)
  • Sync any folder you want

Dropbox – sync all files you frequently work with on multiple computers.

  • Sync programming code and frequently used data
  • Quickly confirm sync status with file icon (or badge)
  • Stores old versions of all files for recovery