Sphero Public SDK

Sphero Public SDK

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

›Additional Resources

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

Troubleshooting

Having trouble?

Let's get you rolling again. If you don't find your issue here, head over to our community forum for help from other users and Sphero engineers, or file an issue on Github.

ImportError: No module named functools_lru_cache

This error is usually the result of running pipenv in Python 2.7 without the backport of functools_lru_cache installed. There are two options to resolve this error:

1. Add the missing dependency to your system python 2.7 installation

 sudo apt install python-backports.functools-lru-cache

OR

2. Uninstall pipenv from your system python 2.7 installation, then reinstall pipenv in Python 3

 pip2 uninstall pipenv
 pip3 uninstall pipenv
 pip3 install pipenv

After either option 1 or 2, re-running the first time setup script from your SDK root directory (default ~/sphero-sdk-raspberrypi-python) is recommended:

 ./first-time-setup.sh

TimeoutError

The error message concurrent.futures._base.TimeoutError, typically means that the UART communication between RVR+/RVR and the Raspberry Pi is not working.

pi@raspberrypi:~/sphero-sdk-raspberrypi-python $ python3 getting_started/asyncio/leds/set_multiple_leds.py
Network available
Checking RVR firmware versions...
Traceback (most recent call last):
  File "getting_started/asyncio/leds/set_multiple_leds.py", line 16, in <module>
    loop
  File "/home/pi/sphero-sdk-raspberrypi-python/sphero_sdk/asyncio/client/toys/sphero_rvr_async.py", line 36, in __init__
    self._check_rvr_fw()
  File "/usr/lib/python3.7/asyncio/base_events.py", line 584, in run_until_complete
    return future.result()
  File "/home/pi/sphero-sdk-raspberrypi-python/sphero_sdk/asyncio/client/firmware/rvr_fw_check_async.py", line 30, in _check_rvr_fw
    rvr_nordic_version = await self.__rvr.get_main_application_version(target=SpheroRvrTargets.primary.value, timeout=3)
  File "/home/pi/sphero-sdk-raspberrypi-python/sphero_sdk/asyncio/client/toys/sphero_rvr_async.py", line 106, in get_main_application_version
    return await self._dal.send_command(**command_dict)
  File "/home/pi/sphero-sdk-raspberrypi-python/sphero_sdk/asyncio/client/dal/serial_async_dal.py", line 84, in send_command
    timeout=timeout
  File "/home/pi/sphero-sdk-raspberrypi-python/sphero_sdk/asyncio/server/handler/api_sphero_handler.py", line 191, in send_command
    await asyncio.shield(asyncio.wait_for(future, timeout=timeout))
  File "/usr/lib/python3.7/asyncio/tasks.py", line 423, in wait_for
    raise futures.TimeoutError()
concurrent.futures._base.TimeoutError
  • Make sure your RVR+/RVR is turned on.
  • Check your wiring. Review the hardware setup instructions for details. If you're sure you wired your Raspberry Pi to your RVR+/RVR correctly, try different jumper wires. A lot of jumper wires in the market are built to be inexpensive, and could be defective or get damaged during use.

Syntax Error (in a getting_started script or other known good script)

When you see a syntax error in a known good script, this could be a hint that you're using the wrong Python version. Python 2.x is commonly the default python on a Raspberry Pi, and is not compatible with our SDK (we require Python 3.5+).

# Using Python 2 by accident:
pi@raspberrypi:~/sphero-sdk-raspberrypi-python $ python3 getting_started/asyncio/leds/set_multiple_leds.py
  File "getting_started/asyncio/leds/set_multiple_leds.py", line 21
    async def main():
            ^
SyntaxError: invalid syntax

To make sure that you're using Python 3.x, call your scripts in the form

python3 <scriptname.py>
# Using Python 3 (script succeeded)
pi@raspberrypi:~/sphero-sdk-raspberrypi-python $ python3 getting_started/asyncio/leds/set_multiple_leds.py
Network available
Checking RVR firmware versions...
Checking CMS firmware versions...
Firmware check complete.

← Using Pipenv
  • ImportError: No module named functools_lru_cache
  • TimeoutError
  • Syntax Error (in a getting_started script or other known good script)
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