EzDevInfo.com

cylon

JavaScript framework for robotics, physical computing, and the Internet of Things Cylon.js - JavaScript framework for robotics, physical computing, and the Internet of Things using Node.js

OS X disconnects from paired Sphero a few seconds after connecting

I'm trying to use Cylon.js to write scripts to control a Sphero 2.0 on OS X. I use the Bluetooth preferences menu to pair with and connect to the Sphero. But the connection does not seem persistent. It automatically disconnects after a few seconds and the Sphero goes to sleep after inactivity. This happens even when Cylon.js has a persistent connection with the Sphero, causing it to disconnect and throw an error.

Is it possible for me to force my Mac into maintaining a connection somehow?


Source: (StackOverflow)

Node dependencies not found when ran programatically

UPDATE: There seems to be an issue with the cylon.js library. https://github.com/hybridgroup/cylon/issues/277

I am working on my first Node project and have run into some small issues with dependencies.

If I execute my server.js using node server.js, everything works as expected, all my deps are in the correct place and read just fine.

However, if I attempt to use init.d scripts to call it, or attempt to call it from within a different node program, I get errors that some of my dependencies are not found. It suggests using npm to reinstall them, and I have added the npm install line to the script just to make sure, but that has not had any effect.

I, [2015-06-29T17:29:12.661Z] INFO -- : [ardrobot] - Initializing connections.

Cannot find the 'cylon-intel-iot' module. This problem might be fixed by installing it with 'npm install cylon-intel-iot' and trying again.

    'use strict';

    var wait = require('wait.for')
    var Cylon = require('cylon');
    var bleno = require('bleno');
    var ip = require('ip');

    require('wait.for/parallel-tests.js')

    Cylon.robot({
      name: 'ardrobot',

      connections: {
        edison: { adaptor: 'intel-iot' }
      },
      devices: {
        turnServo: { driver: 'servo', pin: 3, },
        driveServo: { driver: 'servo', pin: 5, }
      },

      //These correspond to the actual api endpoints
      commands: function() {
        return {
          //servo
          set_angle: this.setAngle,
          set_drive_speed: this.setSpeed,
          do_arm: this.arm
        };
      },

      setAngle: function(val) {
        if (val != null) {
          this.turnServo.angle(this.turnServo.safeAngle(+val));
        }
      },
      setSpeed: function(val) {
        if (val != null) {
          this.driveServo.angle(this.driveServo.safeAngle(+val));
        }
      },

      arm: function() {
        var my = this;

        function arm1(param, callback){
          console.log('Arming sequence 1');
          my.setSpeed(180);
          wait.miliseconds(5000);
        };

        function arm2(param, callback){
          console.log('Arming sequence 2');
          my.setSpeed(0);
          wait.miliseconds(5000);
        };
        function arm3(param, callback){
          console.log('Arming sequence 3');
          my.setSpeed(90);
        };
        function prepareArm(){
          console.log('Beginning arming sequence');
          wait.for(arm1);
          wait.for(arm2);
          wait.for(arm3);
          console.log('Finished arming sequence');
        };

        wait.launchFiber(prepareArm);
      },
      work: function(my) {
      }
    }).start();

  Cylon.api(
      'http',{
      host: ip.address(),
      ssl: false,
      port: '3000'
    });

Source: (StackOverflow)

Advertisements

Cylon.js and MiP

I'm trying to connect with a MiP robot using Cylon.js from three devices / environments, getting different type of problems in all of them.

Mac OS 10.9:

All the required node modules (cylon, cylon-mip and cylon-ble) are installed successfully.

Following the example provided on the documentation I can get the uuid of the robot by running sudo cylon-ble-scan. The problem comes when Node tries to connect with that uuid afterwards, as I always get the same error:

INFO -- : [Robot 1] - Starting connections.
noble: Could not start scanning, state is unknown (not poweredOn)

Despite of the message, the robot is powered on.

Raspbian (Raspberri Pi 2):

The cylon and cylon-ble modules are installed successfully. I can get the uuid of the robot as well. The problem is related to the installation of the cylon-mip module, as it throws an error by running sudo npm install cylon-mip:

...
gyp ERR! stack Error: 'make' failed with exit code: 2
...
npm ERR!     node-gyp rebuild
...
gyp ERR! command "node"
"/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js"
"rebuild"
...

I had a look to the node-gyp addon and apparently it's fitting with all the requirements that are explained in the documentation.

Windows 8.1:

This is the worst scenario possible, as apparently some of the required drivers are not even available for this OS. Again, I found problems trying to install cylon-mip, as the middleware is just compatible with darwin and linux.


I would like to establish communication with the robot by using any of the approaches explained about but unfortunately the documentation of the project is not that exhaustive enough according to my (very limited) knowledge about this topic.


Source: (StackOverflow)