Category Archives: Embedded Systems

Vector Returns!

Although it’s old news by this point, I had to talk about the return of the Vector robot. Ok, “return” is still a little premature, but ongoing support has happened.

A company called Digital Dream Labs purchased all of the rights to Vector (and, I believe, the rest of Anki’s products) and ran a Kickstarter to keep the little guy alive.

I backed this of course, because robots.

While they have yet to produce the final products that may of us paid for (which is software they are working on), they are moving things formward with minor updates and od course the important task of keeping his servers up.

What’s promised is a way for those of us who want to develop for Vector to do two main things. One is redirect him to a new server, including a self-hosted server. This is the safety net should DDL someday cease to exist.

The second is full access to programming Vector, not just being able to control him via an external Python program. This is the one I’m really excited about. I like robots that can access the network and leverage it to do things, but the ability to add intrinsic behaviors is really important.

So thanks to DDL for rescuing Vector, and fingers crossed that they find the success they deserve!

Sad News for Vector

Out of the blue, Anki, the makers of the Cozmo and Vector robots, shut down yesterday.

This is quite the shock. 😦

My heart goes out to all the employees who were blindsided by this, and are out of jobs through no fault of their own. (The shutdown of the Roambi team by my now former employeer SAP a month or so back makes me especially emphathetic.)

Vector is a nice progression from Cozmo and I am sad we won’t get to see where he would have gone, nor will we see the future generations.

I own both a Cozmo and a Vector. With my relatively ancient Pleo dinosaur robot, this is quite the trail of failed robot companies, sigh. At least I refrained from jumping on the Jibo train! (That product sounded interesting to be sure, but my concerns that they were over-promising turned out to be correct.)

There are a couple paths forward for Vector and/or those of us who have one.

  • Some company or group could acquire Anki or the assets and continue to sell and enhance Vector.
  • They could keep the servers alive via Patreon or a direct subscription of modest cost.
  • Anki could open-source Vector’s code. I’d love to be able to write truly native code for the little guy, versus the current from-the-desktop SDK.
  • They could at least open-source the backend code so we could set up our own servers.

The shutdown sounds abrupt, so I don’t know if any contingencies were in place or plans being made in the aftermath for any of the above options. Hopefully we will hear more in the next few weeks as the dust settles.

Good luck Vector team, and thanks for the cool toy!

Mindstorms EV3 Revisited

When I noticed that there was a new version of ev3dev available (ev3dev-jessie-ev3-generic-2017-02-11) I decided it was a good opportunity to re-do my system setup post.

This effort also included creating scripts that perform as many of the setup steps as possible.

This post updates and mostly replaces my previous ev3dev blog post.

The first steps are to download and install the latest version of ev3dev from the ev3dev website, and get the EV3 connected to the local wifi network.

Then check out the git repo containing the setup scripts here: https://github.com/donmeyer/ev3-setup

Run the Mac setup script  setupMac.sh.

Then ssh into the EV3 and run the setup script  setupEV3.sh.

You may want to edit that script to remove the Textmate ‘rmate’ setup step, although it’s harmless if you don’t use Textmate.

What do the setup scripts do?

setupMac.sh

  1. Copies the host RSA key to the EV3.
  2. Copies the setup files to the EV3.
  3. Copies a local ‘Scripts’ folder to the EV3. (If you don’t have one of these, comment out this line.)

setupEV3.sh

  1. Sets up the RSA key. This allows you to ssh to the EV3 without needing a password each time.
  2. Installs the Python FTP library.
  3. Installs a simple FTP server.
  4. Makes any Python scripts copied from the (optional) Scripts folder.

 

After running both scripts, reboot the EV3 and when it finishes booting you should be able to access the FTP server as well as ssh into the EV3 without needing to enter the password.

Lego Mindstorms EV3 and ev3dev

So recently my Lego infatuation led, as it inevitably would, to Lego Mindstorms.

This post discusses a lot of the setup I’ve done to get the EV3 controller brick set up for development using a “normal” programming language instead of the visual one provided by Lego. That does look to be a nice way for a lot of people, especially kids, to learn to program robots. However, as a guy who has spent a very large number of years programming, visual languages like that are a bit confining. So imagine how happy I was to see that the ev3dev project has stepped in! (More about that later in this post)

So now I have a pretty functional development environment set up – time to work on some actual robotics!

Topics covered:

  1. Remote Editing
  2. RSA Key for SSH
  3. FTP Server
  4. Python 3

While some of these such as remote editing are Mac-specific, a lot of the content here is the same regardless of your host computer.

About Ev3dev

Ev3dev is an awesome replacement OS for the EV3 brick, available here: ev3edev.

I won’t duplicate a lot of detail that’s on their website, but in general, it provides an alternate OS that lets you write Mindstorms programs in a variety of languages. The one I’m using is Python. The entire project is really slick, and an impressive accomplishment.

The ev3dev build I’m using is Jessie 2015-12-30.

All of the steps here assume that it is installed and running, and a network connection has been established along with being SSHed into the brick. (All of that is covered on the ev3dev website.)

Disclaimer: I have not gone back to a clean install of ev3dev and run though the steps in this post, so while I believe I captured everything, it is certainly possible I missed something.


Enable remote editing with TextMate

This obviously assumes that you have the latest TextMate running on your Mac. Did I mention that this post is going to be Mac-centric in places?

On EV3:

$ sudo gem install rmate

On Mac:

Add this to your  ~/.ssh/config file:

Host *
RemoteForward 52698 localhost:52698

Or, when starting SSH, you can do this and not muck with the SSH config file:

$ ssh -R 52698:localhost:52698 robot@ev3dev.local


 Setup RSA key for SSH

By setting up the RSA key for my host computer, I can skip needing to enter a password every time I log in via SSH.

On the Mac:

$ scp ~/.ssh/id_rsa.pub robot@ev3dev.local:/tmp

This assumes that an RSA key has been previously generated! You can generate a key using the ssh-keygen command, which will create the private and public keys in (typically) the ~/.ssh directory. The file without the extension is the private key, and the one with the .pub extension is the public key.

This public key is the one transfered to the system you want to access, and append to its authorized_keys file.

On the EV3:

$ mkdir ~/.ssh
$ cat /tmp/id_rsa.pub >> ~/.ssh/authorized_keys

 


FTP Server

Even though I can edit files via rmate and sip them back and forth from the remote shell, it’s nice to be able to move batches of files etc. via FTP. And with something like the Transmit application as an FTP client it’s trivial to do a sync and essentially back up my EV3 home directory to my Mac.

I spent a stupid amount of time trying to get vsftpd installed and running (installation went smoothly, but running always failed with an error no matter what I tried. And I tried  a lot of things!)

So, since my goal is just to have simple FTP access,  on to plan B – use Python! I grabbed a very nice FTP package for Python here: https://pypi.python.org/pypi/pyftpdlib/

The following shows the steps I went through (you may want to update the wget line based on the current version of pyftplib). In a long-ago effort to install this library on a Beaglebone, the installer failed, so the steps below include just manually moving the library into place – didn’t want to invest a lot of time debugging that issue since manually moving it seemed to work just fine.

Install the FTP package

$ wget https://pypi.python.org/packages/source/p/pyftpdlib/pyftpdlib-1.5.0.tar.gz
$ gunzip pyftp*
$ tar -xf pyftp*.tar
$ sudo mv pyftpdlib /usr/lib/python2.7

Create the FTP Server Python program

I added a super-simple FTP server program to my home directory ~/robot.

#!/usr/bin/env python
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer
from pyftpdlib.handlers import FTPHandler
from pyftpdlib.servers import FTPServer

authorizer = UnixAuthorizer(rejected_users=["root"], require_valid_shell=True)

handler = FTPHandler
handler.authorizer = authorizer

handler.abstracted_fs = UnixFilesystem

address = ('', 21)
ftpd = FTPServer(address, handler)

ftpd.serve_forever()

This will allow you to log in using any account other than root. By default, the username of robot and the password maker.

Set up to start the FTP server at bootup

Add this script as /etc/init.d/ftpserver

#!/bin/sh
python /home/robot/ftpserver.py

Then make it executable and let the init system know to run it at boot up:

$ sudo chmod +x /etc/init.d/ftpserver
$ sudo update-rc.d ftpserver defaults

Python 3

Set up to use Python3 (this may not be needed with a future release of ev3dev?)

Note that Python 3 is pre-installed on the ev3dev distribution but some of the supporting libraries are not, which is what makes these steps necessary.

On EV3:

$ sudo apt-get update
$ sudo apt-get install python3-pil
$ sudo python3 -m easy_install python-ev3dev

Note that “apt-get update” may take a while…

Lua Web Server

One of my large and ever-unfinished projects is a Home Automation system. This is designed as multiple processes where most of them are Lua script engines along with several C++ processes as well that handle low-level interfacing and infrastructure for the system.

This is all running on a RaspberryPi.

As part of this effort, I wrote a simple Lua web server to allow access to the system from a browser or a custom iOS app. Since this Lua web server might be useful to others, I am making it available as a separate component.

It is quite simple, but for serving JSON and HTML, and responding to requests (JSON or otherwise) in a low-demand system like personal home automation, it should be just fine.

Note that this depends on the Lua socket library being present.

https://github.com/donmeyer/lua-web-server

1802 Emulator

In a previous post I talked about the 1802 Assembler I was playing with when I revisited an ancient 1802-based FIG-Forth implementation.

Since it was a pain to get that code running on real hardware, I also threw together an emulator. This was done in Objective-C for the Mac.

Note that the core emulation code is written in ‘C’ however, so it should be quite portable.

It is fairly quick, although I have not tried to quantify it’s equivalent speed.

It will build under recent Xcode versions such as Xcode 6 or Xcode 7.

Listing files can be loaded and executed. There is application-specific code to treat some of the IO ports as serial input/output to a simple terminal facility.

This is in no way a polished final product, but it is made available on the off chance that someone else might find the code useful or interesting.

https://github.com/donmeyer/cosmac-emulator-mac

Cosmac 1802 Assembler in Python

So back in the day, one of my Cosmac 1802 projects was getting FIG-Forth up and running on the 1802.

I laboriously converted the printed listings to a digital assembler source file. This file was then assembled with a cross-assembler that was written in BASIC.
As part of that effort I also modified the Forth system to run from EPROM.

Since I wanted to get Forth running on the 1802 Membership Card (see earlier blog post), I needed the ability to assemble that source, and do some updates etc.

In the same way it’s been a long time since I’ve had a computer with a parallel port, it’s been a long time since I’ve had a computer with a BASIC interpreter installed.

The obvious next step was to write an assembler in a more modern language. Again Python was my tool of choice.

This is a fairly simple assembler, just sufficient to assemble my ancient FIG-Forth listings. It is not a macro-assembler and I’m sure has other limitations relative to a “real” 1802 assembler.

The source is available here: https://github.com/donmeyer/cosmac-assembler

This plays nicely with my 1802 Membership Card Loader. The loader can invoke the assembler automatically when given a source file, allowing you to give one single simple command line that assembles the source and downloads it to the Membership Card.

1802 Membership Card Loader

So I built Lee Hart’s slick little 1802 Membership Card and its Front Panel card. Next I wanted to load some programs onto it! There was that nice DB-25 connector all ready to connect to my PC’s parallel port. However… I’ve got a Mac, and haven’t seen a computer parallel port in perhaps a decade.

My solution to this problem was to create my own interface hardware based on an Arduino. I considered using a Spark Core to allow doing things wirelessly via WiFi, but decided that for this purpose the Arduino was something more people were likely to have, and it was just a somewhat simpler solution.

The final design uses an Arduino, a 16-line I2C port expander chip, and some software. The software consists of the Arduino program and a Python program that runs on my Mac. Since it’s Python, it should also run on a Windows system, a Linux box, etc.
You can also forego the Python side of things and directly control the Arduino loader from a terminal, or from your own software if you prefer.

Why go to all this trouble? Just a fun little project!

It’s been a good mental exercise and a nice trip down memory lane.

Here is the Git repository with the source code and documentation:  https://github.com/donmeyer/membership-card

 

1802 Loader Documentation

Coming up next – an 1802 Emulator

Embedded Development – The Hobby Edition

Ok, so here are pictures of embedded controllers and such. Just a snapshot of my hobby embedded environment.

Not shown is my workbench, which gets set up and taken down on the kitchen table as needed. (apartment living!)
This includes soldering station, digital oscilloscope, and tools.

The table top near the desk:

Spark Core, RaspBerryPi, Arduino and so forth. Plus an old-time iPod!

The RaspberryPi runs the home automation system, and is connected to an XBee used for communication with various peripherals. The Arduino is one of those, in development. The Spark Core is my development core, with others already in use around the house.

IMG 6078

Drawer #1:

Arduino stuff, XBee modules, and various shields and parts from Adafruit.

IMG 6079

Drawer #2:

RaspberryPi and Spark Core. Power supplies, and a fairly ancient Radio Shack multimeter.

IMG 6080

Cross-Compiling for BeagleBone Using a Linux VM on the Mac

BeagleBone Cross Compiling using OSX on the Mac (using Linux)

Although it may seem more complicated, I decided the best way to cross-compile from my Mac would be to do it from a Linux system.

I would of course love to have my BeagleBone cross-development environment running directly on OSX, but that’s an effort for another day – my goal here was to be able to cross-compile for the BeagleBone.

Yes, in theory this should be possible on a Mac since it’s Unix-based, but it appears to me that may be more pain. More pain than just setting up an Ubuntu system using VMWare Fusion anyway. This is quite easy these days – both VMWare and Parallels make it almost effortless. There are many many resources on how to do this, so I’m not going to cover that here.

With Ubuntu 12.04 running happily in a VMWare VM on my MacBook Pro, away I went.

So to just cross-compile, it doesn’t appear that you really need the OpenEmbedded and Angstrom kernel stuff, so I went with just the Angstrom pre-built toolchain available at:
http://www.angstrom-distribution.org/toolchains/

I used angstrom-2011.03-i686-linux-armv7a-linux-gnueabi-toolchain.tar.bz2
This is the 32-bit version, which matches my Ubuntu VM setup. There is a 64-bit version there as well, if you are running a 64-bit version of Linux on your host system.

Step-by-Step

On the Cross-development Host

Extract the pre-built angstrom toolchain:

    $ cd /
    $ sudo tar -xf <path to the angstrom toolchain>

Which creates the new directories /usr/local/angstrom and /var/lib/opkg.

Run the environment setup script, which puts the new tools in the path as well as sets up several other environment variables:

    $ . /usr/local/angstrom/arm/environment-setup

Create a simple “Hello, world” program using whatever editor you prefer. I named mine “hello.c”.

    #include <stdio.h>

    int main()
    {
        printf( "Hello, worldn" );
    }

And finally, do a test build.

    $ arm-angstrom-linux-gnueabi-gcc hello.c -o hello

This should result in an executable file named hello. (This is a Csource file, so I used gcc, but you can also change the gcc at the end of the command to g++ to compile C++ source code.

On the BeagleBone

If you transfer the executable binary output file hello to your BeagleBone (e.g. via FTP), you should be able to run it and see the text “Hello, world” printed out in the BeagleBone terminal.

    $ ./hello
    Hello, world

Resources

This guide is based on bits of information gleaned from a variety of sources, including:

Linux To Go
electrons on radio
Trey Weaver’s Blog
gpio.kaltpost.de

Thanks to everyone who has blogged about their experiences with the BeagleBone!