Get your Driver on github.com

We're chuffed (a rather English term that means 'rapt'; a rather Australian term that means 'pleased and excited') to see how many Ninjas out there are actively developing Drivers for the Ninja Platform.

The step from making a Driver work within your own development environment to making it work for anybody is a larger one than most would expect.  One crucial step in that respect is deploying your code somewhere that is publically accessible.  Git is not the only version control system out there, nor is github the only hosted repository, but it's the one we use, and as such will be the focus of this How-To.

 

Get an Account

If you're going to work with exclusively open source projects, then github.com is free to use.  Pick an ironic username (unlike my literal one- I'm @justy.  Should have made it 'bitblatter' or somesuch.) and sign up young (wo)man!

 

Get your SSH Keys sorted

One aspect of the process of deploying code to github that can be vexxing (and this can be a real dealbreaker for some) is that of generating SSH keys.  A guide https://help.github.com/articles/generating-ssh-keys is provided to help you through this.  Anybody can clone a public repository but if you're going to go into the publishing business, you have to have creds.  Credentials allow you to push your code changes back to the repo.  Without them, it's a one way street, and that's not very share-y.

 

Go Both Ways

As you'll read on github.com after you've created a new repository, you can approach things in one of two ways.  Either you're starting from scratch code-wise, and you want to start committing and pushing changes as you start, or else you've already written your shiny Driver, and you just want to get it onto github.  Put another way, either you have no repo yet, or you do.

Let's focus on the second option as it's the likely the most helpful to you.  Here's a step-by-step guide to doing exactly that.  The steps will include some best practices.

Remember it's entirely possible to create a git repo and work with it without it being hosted on github.  If you haven't initialised a git repository, cd  into the directory where your code is located and do a:

 

Step One

git init

(Don't do this if you have already- you'll lose your commit messages.)  Later in these steps we'll cover how to associate your repo with the one you create in github.

  

Step Two

Get a directory listing and if you don't see a README.anything (I use Markdown- README.md) then create one!  To quote the Governator, DO IT NOW!!  If you're going to share your code with other people (and that definition includes yourself six months from now) those people will be very thankful you gave them at least a clue of what your Driver does and how it should be installed, etc.  Conversely, those people will curse your name and there will be no stars or followers for you should you neglect to do so.

 

Make the README informative.  Here's a reasonable outline; let's assume your username is "wwisherjnr" and your driver is called "t1000".

t1000 - Ninja Blocks Driver for the Skynet T-1000 robot.

Requirements

This Driver is written to run either on the Ninja Block (Ubuntu) or on the client running on Mac OS X. Sorry, Windows isn't supported anymore after the blue screen of (literal) death unpleasantness of last time. (If anyone knows a good lawyer pls. message me). All T-1000 models are supported.

Installation

      1. Cd into your drivers directory (/opt/ninja/drivers on the block or client/drivers/ on Mac OS X) and type: git clone git://github.com/wwisherjnr/t1000.git
      2. After the clone finishes, cd into the t1000 directory and type: npm install to satisfy the dependencies for this driver
      3. Restart your block with: sudo restart

You should then see a series of new Widgets appear on your Dashboard

Usage

Widgets: The T-1000 controller widget gives you access to all of your robot's important statistics, including kill-count, current form and star sign. You may also control your robot using the simple on-screen directional joystick and action buttons. A pair of camera widgets will also appear, allowing you to see through the eyes of your robot as it performs its tasks, you sick so and so.

Rules: Actions work as you'd expect, allowing Rules of the form "When PIR motion detected, morph into target" and "Tweet kill-count".

Caveats/Issues

As mentioned, there's no Windows support at the moment. Under certain circumstances, (especially under low robot power) you may lose the feed to your T-1000's eye cameras. It's probably a good idea to issue a 'sleep' command if this happens.

 

 

 

Step Three

Commit your changes; in this case the README file.

git commit -a -m "Edit README"

 

Step Four

Associate your repo with the one you created on github

git remote add origin git@github.com:wwisherjnr/t1000.git

Then push to github.

git push -u origin master

 

Step Five

Pretend you're a new User and clone your own repo.  Go to another location on your hard drive and follow your own installation steps.  In the case of Ninja Block Drivers this will involve duplication of the client, so bear that in mind.  Clone the client and start from there so that you're reproducing as closely as possible the conditions your Users will have.

 

Step Six

Test, test, and test again.  Try and install your Driver in an entirely new environment, for example a friend's block.  If you've only tested your Driver on an actual Ninja Block, try it from a computer, for example on OS X and see what happens in that context.

 


Justin Clayden
Justin Clayden

Author