Sphero Public SDK

Sphero Public SDK

  • Getting Started
  • How To
  • Documentation
  • Get the Code
  • Samples
  • Troubleshooting
  • FAQs

›Python SDK Setup

Starting with Raspberry Pi

  • Intro
  • Python SDK Setup

    • 1. Python SDK Setup (Quick Start)
    • 1.a. Python SDK Setup (Advanced)
    • 2. Setting Up Raspberry Pi OS
    • 3. Using the Terminal
    • 4. Using SSH
    • 5. Connecting to RVR+
    • 6. Test it!

    First Programs

    • Hello World - Starting Python
    • Hello RVR+ - LED Control
    • Go Driving

    Optional Steps

    • Choose Your Python Version
    • Using Pipenv

Additional Resources

  • Troubleshooting

1.a. Python SDK Setup (Advanced)

❗️
important

Did you get here from the Quick Start Instructions and already have the preconfigured micro SD card image installed? If so, skip ahead to Setting Up Raspberry Pi OS.

Before You Start

This guide assumes that you already have a Raspberry Pi with a Linux-based operating system and the following dependencies already installed:

  • Python 3.7
  • Git (recommended, but not required)

If you'd rather start with a pre-configured SD card image, head on over to our Quick Start instructions.

Note: We have tested on Raspberry Pi OS with desktop (formerly known as Raspbian). If you are working on a different Linux distribution, you may run into issues with missing dependencies. Let us know in the community forum or by filing an issue on GitHub so we can continue to improve our setup scripts to handle more OS variations.

Get Ready

Open the Raspberry Pi terminal, which you can get to by clicking the icon in the toolbar at the top of your screen: Raspberry Pi Terminal



If your Raspberry Pi isn't freshly set up, make sure your OS is up to date by running:

sudo apt update
sudo apt dist-upgrade
sudo apt clean
sudo reboot

Get the Code

We now must obtain the RVR+/RVR Raspberry Pi Python SDK code from GitHub by cloning the repo with git.

Using Git

Using Git to get the code onto your Raspberry Pi is a bit technical (and requires a free GitHub account), but it is much simpler to update your local code, on your Raspberry Pi, whenever we change it on GitHub.

To use Git to clone the repo to your computer, you'll again use the terminal on your Raspberry Pi. This time, we'll want to cd into the directory where you would like the RVR+/RVR Raspberry Pi code to live; for example, we want to just put our code in our home directory that the terminal starts us in, so we just need to do:

cd home

From there, you'll jump into your browser and head over to the (Python SDK GitHub page), where you'll navigate to the green "Code" button.

GUI Configuration Tool

Clicking on it will yield a menu similar to the one in the photo above where, in the lower right corner, you have the option to copy the url in the center of the menu. Once you've copied this, jump back over to your terminal and write:

git clone https://the-url-you-just-copied.com
cd ~/sphero-sdk-raspberrypi-python
ℹ️
note

pwd stands for "print working directory". This can be a useful command when you are trying to ensure you are in the correct file directory at any point in this process.



You may be prompted for your GitHub login information, so make sure you have that handy! It is normal for nothing to display as you type your password, to protect your information (safety 3rd!).

💡
tip

Now, any time you want to make sure that you have the most up-to-date version of our code on your Raspberry Pi, you simply need to go to the root directory of the RVR+/RVR code (if you put yours where we suggested, you should be in pi/raspberry-pi) and run:

git pull

Install The Dependencies and Configure the Serial Port

ℹ️
note

We have previously recommended using Pipenv to keep SDK projects and their dependencies isolated from the system Python installation. If you wish to do this, check out our pipenv instructions.

In order to install the required Python packages needed to run the SDK, all you have to do is run the first-time-setup.sh script by running the following command:

./first-time-setup.sh
ℹ️
note

This process may take a few minutes

When the installation completes, the script will ask whether you have already disabled serial shell access and enabled the serial port to communicate with RVR+/RVR. If so, then skip to the next section! If you choose to use raspi-config to change settings, you will need to restart your Pi afterward. If you opt to restart when prompted make sure everything you've been working on is saved! If you opt out at that moment, you will still need to restart your Pi at another point for the installation to take effect so that you can utilize your Pi with your RVR+/RVR.

If you chose not to use raspi-config to configure the serial port, you can also use the graphical Raspberry Pi Configuration tool, and make the selections highlighted below:

GUI Configuration Tool

Next, shut down your Pi from the Log Off menu, or using the terminal:

sudo shutdown now
❗️
important

You are now ready to connect to your RVR+/RVR!

Please use the link above to proceed, the button below will take you to setting up your OS and using Terminal, which you probably already know.

← 1. Python SDK Setup (Quick Start)2. Setting Up Raspberry Pi OS →
  • Before You Start
    • Get Ready
  • Get the Code
    • Using Git
  • Install The Dependencies and Configure the Serial Port
Sphero Public SDK

Wanna stay informed about Public SDK efforts and releases?

Sphero
Public SDK LicenseAbout Sphero Public SDKSphero.comSphero EDU
Community
Sphero CommunityThingiverseTwitterInstagramFacebook
More
RedditLinkedInGitHubStar
Copyright © 2022 Sphero