Control Robots From Your Phone Using Commander - The Hybrid Group

Control Robots From Your Phone Using Commander

Robots

With the ongoing evolution of the Internet of Things, your phone will become your primary source of control for the world around you. We would like to present to you our solution Commander (http://commander.io), a mobile app to trigger commands and receive events from robots and devices.

Cylon.js PhoneGap Spark Commander list layout Commander connection

You can have different types of user interfaces for the various interactions with your devices, depending on your needs. We currently support the following controls:

  • D-pad
  • Command list
  • Joystick

How It Works

Commander uses the Common Protocol for Programming Physical I/O to establish communication with the Cylon.js, Gobot or Artoo APIs.

It works based on layouts that can be customized to trigger custom actions for your own programs. You can easily create your own command sets that match your own robotic applications.

We have developed Commander as open source, using the fantastic PhoneGap and Ionic Framework. Checkout our site at commander.io for more information, or to checkout the source code.

Control a Sphero Using a D-pad Layout and Cylon.js

To show how Commander works, we'll show how to control a Sphero robot from your phone using Commander.

First we'll create a Cylon program to listen for commands and control the Sphero:

var Cylon = require('cylon');

Cylon.config({
  api: {
    ssl: false,
    port: '8080',
    host: '0.0.0.0',
  }
});

Cylon.api();

Cylon.robot({
  name: 'sphero-dpad',
  connection: { name: 'sphero', adaptor: 'sphero', port: '/dev/tty.Sphero-YBW-RN-SPP' },
  device: { name: 'sphero', driver: 'sphero' },

  move: function(direction) {
    var my = this;

    switch (direction) {
      case "up":
        my.sphero.roll(100, 0);
        break;
      case "down":
        my.sphero.roll(100, 180);
        break;
      case "left":
        my.sphero.roll(100, 270);
        break;
      case "right":
        my.sphero.roll(100, 90);
    }

    setTimeout(function() {
      my.sphero.stop();
    }, 2000);

    return "ok";
  },
  commands: function() {
    return {
      move: this.move
    };
  }
}).start();

Then we'll install Commander from either the Google Play store, or the iTunes App store.

Commander connection Commander connection

After you open the app, go to the menu option 'Connection' and set the api host for your cylon program.

http://(your-computer's-IP):8080

Commander connection

Next open 'Command sets' menu option and paste this URL:

https://raw.githubusercontent.com/hybridgroup/commander/master/examples/sphero-dpad/sphero-dpad.json

Commander command set

Now click on 'Load' and after command set is loaded click on 'Use' to open it

Cylon.js PhoneGap Spark

Now you can use the D-pad controls to move the Sphero around.

Have fun!

What's next?

comments powered by Disqus