Skip to content
Andrew Webster edited this page Aug 27, 2019 · 23 revisions

MaslowCNC Wiki: Electronics | Firmware | Mechanics | Software | Community Garden

How to run Ground Control on a Raspberry Pi (see Below for 3B+ with Pi Touch Screen)

These instructions were written using a Raspberry Pi 3, (and has been tested on a 2b) but the instructions should be similar for other operating systems.

Step 0: For Rasberry Pi 3B+ please go to step 8, for other builds please see Step 1.

Step 1: Download KivyPie

Download the latest KivyPie image from http://kivypie.mitako.eu/kivy-download.html

Step 2: Burn KivyPie to an SD Card

Burn the KivyPie to an SD card. There are many guides about how to do this on the internet, the official one is here.

Step 3: Login

Boot the Raspberry Pi and log in using the default user name and password: Login: sysop Password: posys

Note both the login and password are lower-case

Step 4: Connect to the internet

Connect your Pi to the internet by plugging in an Ethernet port or by following these instructions to connect to wifi from the command line.

If you have an issue, try a hint from the KivyFAQ (also see Section 7 below), and to set the SSID and password,

sudo pipaos-setwifi SSID PASSWORD then reboot.

Step 3: Install Kivy

As of this writing the current version of KivyPi does not actually come with Kivy installed for python 2 which seems like an oversight. Install Kivy with the commands:

sudo apt-get update   
sudo apt-get install python2-kivypie  
sudo ln -sf /usr/bin/python2 /usr/bin/kivy  

Step 3a: Configure Kivy (correct double inputs)

To remedy double-typing of characters and double-clicking of buttons when using a USB HID input device (keyboard/mouse) edit the Kivy ini file with the following command:

sudo nano ~/.kivy/config.ini

Which will open the ini file in a text editor. Comment the line that reads

%(name)s=probesysfs,provider=hidinput

so it will now read

#%(name)s=probesysfs,provider=hidinput

Save the file by pressing Ctrl+x then y then press enter.

Repeat the process for root.

sudo nano /root/.kivy/config.ini

Step 4: Install PySerial

Install PySerial with the command sudo apt-get install python-serial

Update PySerial with the command sudo pip install --upgrade pyserial

Step 5: Download Ground Control

Download Ground Control with the command git clone https://www.github.com/MaslowCNC/GroundControl.git

Step 5a: Configure Kivy theme to correct mouse click position

Backup the existing theme file with the command

sudo mv /usr/local/lib/python2.7/dist-packages/kivy/data/images/defaulttheme-0.png /usr/local/lib/python2.7/dist-packages/kivy/data/images/defaulttheme-0.old.png

Copy one of two theme files from Ground Control.

For the Maslow Theme, use the command

sudo cp ~/GroundControl/Images/MaslowTheme.png /usr/local/lib/python2.7/dist-packages/kivy/data/images/defaulttheme-0.png

For the standard Kivy Theme (with a replacement cursor), use the command

sudo cp ~/GroundControl/Images/ArrowTheme.png /usr/local/lib/python2.7/dist-packages/kivy/data/images/defaulttheme-0.png

Step 6: Launch Ground Control

Launch Ground Control with the command

cd /home/sysop/GroundControl/  
sudo python main.py   

NOTE: To not run with sudo, try adding the user to the dialout and input groups

$ sudo usermod -a -G input,dialout myuser

where myuser is the userID you use to run GroundControl. myuser would be sysop if running as user sysop.

Step 7: More

See the KivyPie FAQ for more information about how to do things like make Ground Control launch on startup turning your Raspberry Pi into a touch screen controller, or how to VNC into your Raspberry Pi.

One option to run GroundControl can be to define a small script in our home directory, (for example: gc)

cd /home/sysop/GroundControl  
python main.py  
cd  

If you want it to run with sudo, use 'sudo python main.py' instead of the above 'python main.py'

To update GroundControl to the latest version, you can use a similar script, gc-update which contains

rm -rf GroundControl.old  
mv GroundControl GroundControl.old  
git clone https://www.github.com/MaslowCNC/GroundControl.git  

For example, to get a new updated GroundControl, from the home directory of sysop issue: $ sh gc-update

The directory GroundControl.old is there for a temporary safeguard. If it fails, delete the partially installed Ground Control and put the old one back into place.

rm -rf GroundControl  
mv GroundControl.old GroundControl  

To start GroundControl using the gc script, from the sysop home directory command line, issue:

$ sh gc

Step 8: Installing Ground Control on a Rasberry Pi 3B+ with Touch Screen.

Step 8.1: Install Rasbian Strech,

I am using the current Rasbian Strech with Desktop from :https://www.raspberrypi.org/downloads/raspbian/ after install of the OS,

Step 8.2: Flip the screen

So rasberry pi offical screen is upside down, to flip the screen:

In Terminal, type: sudo nano /boot/config.txt

Add the line: lcd_rotate=2 to the top of the file.

Press: CTRL+X. Then Y. Then Enter. And reboot

Step 8.3: install dependencies

The following dependencies must be installed. (just copy and paste, Nice part about having the desktop version ;) )

sudo apt-get update
sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-mixer-dev libsdl2-ttf-dev \
    pkg-config libgl1-mesa-dev libgles2-mesa-dev \
    python-setuptools libgstreamer1.0-dev git-core \
    gstreamer1.0-plugins-{bad,base,good,ugly} \
    gstreamer1.0-{omx,alsa} python-dev libmtdev-dev \
    xclip xsel

Step 8.4: Install and force update PySerial (MUST DO)

sudo apt-get install python-serial
sudo pip install --upgrade pyserial

Step 8.5:Cython Pygments docutils

sudo pip install cython pygments docutils

Step 8.6: Installing Kivy (setup can take a while since you are building the program from source, so just a FYI)

git clone https://github.com/kivy/kivy
cd kivy
python setup.py build
sudo python setup.py install

Step 8.7: Enabling the touch screen

To enable touch, you'll need to make a modification to the default Kivy configuration file. To create that file, first run an example:

python ~/kivy/examples/demo/pictures/main.py

(If this gives you a segmentation fault you need to remove and downgrade your libsdl2 version and re-build kivy)

Quit the example with Ctrl+C and then open the newly-created config.ini file in your /.kivy/ folder in your home folder (FYI this will be hidden, so you can right click and "show hidden" if you are going through the file explorer instead of terminal) for editing:

nano ~/.kivy/config.ini

Go into the [input] section, remove the following sections of lines (there will be a mouse line and another line under it) replace those 2 lines with the following:

mouse = mouse
mtdev_%(name)s = probesysfs,provider=mtdev
hid_%(name)s = probesysfs,provider=hidinput

Launch the multi touch pictures demo again. this time verify that the Tap, drag, pinch, and rotate are working:

python ~/kivy/examples/demo/pictures/main.py

Type Control+C to exit the pictures demo.

8.8: installing Ground Control:

see steps 5 and 6 above, then you are all complete.

*NOTE the mouse does not currently work with the 3b+, feel free to update this if someone can figure it out!

Special thanks to #mrichardson23 and his Git Hub help on how to enable touch pad with Python.

Clone this wiki locally