Learning Python 3 with the Linkbot/Installation and Setup

From LinkbotLabs
Jump to: navigation, search

Installing Linkbot Labs

For Windows or Mac, you will need to install Linkbot Labs first. Linkbot Labs contains drivers and utility programs necessary for accessing and controlling Linkbots. You can download Linkbot Labs here.

If you are using a Raspberry Pi (Raspbian or Kano) or Ubuntu, just follow the appropriate instructions below and Linkbot Labs will be installed automatically.

Installing Python and the Linkbot Control Module (PyLinkbot)

For Python programming, you need a working Python installation and "PyLinkbot". PyLinkbot is a Python module that provides Python functions to control Linkbots.

Windows users

We recommend downloading and installing the "Anaconda" distribution of Python. Anaconda comes with many third-party mathematical and graphical plotting packages preinstalled.

Download the Python 3.5 Windows installer from https://www.continuum.io/downloads. Make sure you select Python 3.5 and not 2.7 as our software does not work with 2.7.

Once Anaconda Python is installed and the path is configured, open an "Anaconda Command Prompt" and type the following command to install the Linkbot control module:

pip install PyLinkbot3

Mac users

Starting from Mac OS X (Tiger), Python ships by default with the operating system, but you will need to update to Python 3 until OS X starts including Python 3 (check the version by starting python3 in a command line terminal). Also IDLE (the Python editor) might be missing in the standard installation.

As with Windows, we recommend installing the Anaconda distribution of Python, which may be obtained at https://www.continuum.io/downloads. Make sure you select the "Python 3.5" version.

Once Python3 is installed on your system, run the command

   sudo pip3 install PyLinkbot3

Ubuntu Linux Users

These instructions are tested on machines running Ubuntu 14.04LTS. Other versions of Ubuntu may or may not work. To install everything you need to run this curriculum, which includes Python 3, Python 3 setup tools, and the Barobo Python package, make sure you have an internet connection and run these commands in a terminal window. Note that in Ubuntu, you can highlight text and then middle click in a console window to paste the text into the console.

sudo apt-get install python3 python3-setuptools python3-pip python3-numpy idle3
wget http://repo.barobo.com/barobo.public.key -O - | sudo apt-key add -
sudo add-apt-repository "deb http://repo.barobo.com/ xenial main"
sudo apt-get update
sudo apt-get install liblinkbot
sudo pip3 install PyLinkbot3

The listed commands will install everything you need to run Python3 programs that control a Linkbot, as well as "Linkbot Labs". Linkbot Labs is an interactive graphical portal where you can access curriculum content and control robots. To start Linkbot Labs in Ubuntu, click on the "Home" button on the top left and search for "Linkbot Labs".

For other distributions of Linux, follow the instructions provided by either your distribution or on the Python website to get Anaconda and PyLinkbot installed.

Updating Linkbot Software for Ubuntu

To update your existing Linkbot software on your Ubuntu machine, type the commands:

sudo apt-get update
sudo apt-get install liblinkbot
sudo pip3 install --upgrade -PyLinkbot3

Raspberry Pi (Raspbian and Kano) Users

Raspbian and Kano come with Python 3 and numpy installed by default. To get the Raspberry Pi ready to control the Linkbot, make sure your Pi is connected to the internet and type or copy/paste the following commands. Note that on Raspbian and Kano, you can highlight text and then middle-click in a console to paste the text into the console.

Tip: For Kano users, the default user password is "kano". If you want to change your default password, type in the command "passwd" in a terminal and follow the instructions.

wget http://barobo.com:81/barobo.public.key -O - | sudo apt-key add -
echo 'deb http://barobo.com:81/ jessie main' | sudo tee --append /etc/apt/sources.list
sudo apt-get update
sudo apt-get install linkbotd
sudo apt-get install python3-setuptools
sudo pip3 install PyLinkbot3

You may need to restart your computer after installing these packages for all of the changes to take effect.

Updating Linkbot Software for Raspberry Pi

To update your existing Linkbot software on your Raspberry Pi to the latest version, type the commands:

sudo apt-get update
sudo apt-get install linkbotd
sudo easy_install3 --upgrade --index-url=http://barobo.com:8080/simple/ PyLinkbot

Updating your Linkbot's Firmware

If you have received new Linkbots from the factory, you may need to update the firmware on your Linkbots before they work properly with Linkbot Labs. This process only needs to be done once per Linkbot and does not need to be done again unless you upgrade Linkbot Labs or the Python Toolkit.

Windows, Mac, and Ubuntu

For Windows, Mac, or Ubuntu, you may update your Linkbot's firmware from Linkbot Labs. Open Linkbot Labs and make sure the robot manager on the left-hand side is expanded. At the bottom of the robot manager, you will see a button labeled "Start Firmware Updater". Click on this button and follow the instructions.

Raspberry Pi (Raspbian or Kano)

For Raspbian or Kano, you will have to download/install an additional tool to update the firmware on your robots. To install the tool, run the following commands inside of a command terminal.

sudo apt-get install python3-pyqt4
sudo pip3 install linkbot-firmware-updater

You will also need to be a member of the groups "dialout" and "gpio". To add yourself to these groups, use the commands:

sudo usermod -a -G dialout $USER
sudo usermod -a -G gpio $USER

You may have to log out and log in again for the group changes to take effect.

Once it is installed, you can start the updater by typing

linkbot-firmware-updater

on a command terminal. Follow the instructions to update the firmware on your Linkbots.

Install a Python Code Editor

While there is nothing special about the file format for Python source code files, using a Python code editor or Integrated Development Environment (IDE) can offer many benefits over using a plain text editor not designed for code editing, such as Notepad or Microsoft Word. In the following sections, we will list some commonly used editors for editing Python code. Each editor has its own features and drawbacks. Some which may offer a comprehensive list of features may be hard to install and set up, which may make them unsuitable for inexperienced programmers. Others are easy to install and use, but may not offer the advanced debugging features an expert needs to debug complex programs. Below, we present an abridged list of editors and IDEs which are suitable for editing Python code loosely ordered by ease-of-use. This is by no means a complete list, and the student is always welcome to use any editor that is not a member of the following list. If in doubt, we recommend the Spyder editor because it is free, it is fully featured, and it comes with the Anaconda distribution of Python.

Spyder

Spyder is the default Python editor that comes with Anaconda. It is free, fully featured, easy to use, and available for all major operating systems.

Installation instructions may be found at https://pythonhosted.org/spyder/. If you installed Anaconda, you probably already have Spyder.

IDLE

IDLE is the default editor that comes with Python. It is a simple editor that offers basic features like syntax highlighting, but that's about it.

Instructions for using IDLE to develop your Linkbot Python programs are available here.

TextWrangler (Mac OSX Only)

TextWrangler is a popular text editor on Mac OSX systems. It's feature-set and eas-of-use is similar to IDLE, but it supports a wide variety of languages other than Python.

Instructions for using TextWrangler are available here.

Ninja-IDE

Ninja-IDE is a simple yet powerful Python code editor. It presents a simple user interface and is easy to get started with, and also has advanced debugging features. However, the built-in Python Console currently does not work with the PyLinkbot Python module. Ninja will still work as an excellent code editor; just be aware that you won't be able to use Ninja's Python Console to interactively run Linkbot code.

Instructions for using Ninja-IDE are available here.

PyCharm

PyCharm is a professional Python development environment that is fairly easy to set up. PyCharm has all of the features necessary to develop large, complex Python applications.

Instructions for using PyCharm are available here.

Eclipse

Eclipse is an advanced, fully featured IDE that can be used to develop programs in virtually all popular programming languages, including Java, C, C++, and Python. It supports different languages by offering a flexible "plugin" system so that various third-party developers can write Eclipse plugins to support their particular language or hardware environment. Eclipse is also used as the preferred default editor in many large institutions. However, Eclipse can be tricky to set up and is not the most straightforward to use.

Instructions for installing and using Eclipse to develop and run Python programs are available here .

Learning Python 3 with the Linkbot
 ← Authors Installation and Setup Intro →