Teaching how to connect to Sphero2 and Parrot Drones with ACCS

This section shows you how to use the Sphero 2 JS APIs to connect and interact with it.

For more information refer to: https://github.com/orbotix

Install NodeJS

This section assumes that you are using the Xubuntu development environment that was built in this document. If using other environment, you will have to adapt the commands/paths accordingly.

  • Run the following commands:

sudo apt-get install curl -y

sudo curl -sL https://deb.nodesource.com/setup_4.x |
sudo -E bash

sudo
apt-get
install -y nodejs

Note: for Enterprise Linux and Fedora Linux distributions (OEL, RH, etc.)

sudo su –

curl –silent –location https://rpm.nodesource.com/setup_4.x |
bash

sudo yum -y install nodejs

  • Confirm Node is installed by typing node –version

For more information refer to https://nodejs.org/en/download/package-manager/

Installation for Sphero 1.0/2.0 & SPRK

The Sphero 1.0/2.0 and the SPRK use a Bluetooth Classic interface, also known as “Bluetooth 2.0/3.0”.

Run the following command:

# Create a folder where you want to download the NPM nodules

mkdir robot && cd robot

npm install sphero serialport

Connect to Sphero.js

On Linux (Ubuntu) to connect to your Sphero 1.0/2.0 or SPRK, you first need to pair it. To make things easy:

  • Install Blueman Bluetooth Manager. In Ubuntu this is pretty easy, just open the Ubuntu Software Centre, type the program name and install it from there.

  • When the installation is complete, open the program and search for devices. Make sure the Sphero is flashing its color code. Once the Sphero appears in the list of devices, select it, click on setup and follow the instructions.

Note: If Bluetooth is disabled follow the next steps:

sudo apt-get install gksu -y

gksudo gedit /etc/rc.local

The rc.local fill will open up, although it might ask you to enter the root’s password. Add the following line before the exit 0:

rfkill unblock bluetooth

Now enter the following line in a terminal:

sudo reboot

Or simply restart the Bluetooth service:

sudo /etc/init.d/bluetooth restart

  • You can connect and disconnect the Sphero from a serialport interface by right clicking on it inside the Blueman list of devices and selecting RN-SPP or disconnect, respectively (after it has been setup and added permanently to the list). Make sure to notice the serialport address Blueman displays after the Sphero connects, as this will be the one used in your code. The serialport address displayed for the Sphero should look something like this:

/dev/rfcomm0

  • You need to add a udev rule in order to properly set permissions for your program to be able to access the Bluetooth interface. For example:

    sudo vi /etc/udev/rules.d/55-rfcomm.rules

    Then enter the following line:

    KERNEL==”rfcomm[0-9]*”, NAME=”%k”, GROUP=”citurria”

    à Modify “citurria” by your group name id

    The udev rule above will allow any user who is a member of the “citurria” group to access any port that is added by connecting by running the rfcomm command.

Installation for Parrot Mini-drone

The Parrot mini-drone main documentation can be found at https://github.com/voodootikigod/node-rolling-spider

I followed the next command to set it up:

  • Create a project directory by running the following command:

# Create a folder where you want to download the Rolling-spider NPM nodules

mkdir s2v-iia-nodejs-parrot-apis && cd s2v-iia-nodejs-parrot-apis

sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev build-essential g++

  • Install the Rolling-Spider node module

npm install rolling-spider

If this completes successfully, continue with the supporting modules below:

npm install temporal express

At the end of this step, you should have 3 modules installed:

Note: If you find any missing libraries while installing the previous modules, then go to number 4. Otherwise jump to number 5.

  • I don’t think the following is required, but I had to do it as part of debugging the previous error. Please try not to run these commands and go directly to (3) – If you see any trouble, then come back and install these modules.

sudo npm install -g node-gyp

sudo apt-get install nodejs-legacy

sudo apt-get install bluez-hcidump

sudo hcidump -t -x

this.ble.stopScanning();

under

this.peripheral = peripheral;

Installation for AR Drone 2 Parrot Mini-drone

The AR Drone 2 Parrot mini-drone main documentation can be found at

https://github.com/felixge/node-ar-drone

I followed the next command to set it up:

  • Create a project directory by running the following command:

# Create a folder where you want to download the Rolling-spider NPM nodules

mkdir s2v-iia-nodejs-ardrone2-apis && cd s2v-iia-nodejs-ardrone2-apis

sudo apt-get install bluetooth bluez libbluetooth-dev libudev-dev build-essential g++

  • Install the Rolling-Spider node module

npm install ar-drone

If this completes successfully, continue with the supporting modules below:

npm install temporal express http

At the end of this step, you should have 3 modules installed (i.e. ar-drone, express, temporal) – Make a ls -l node-modules, to confirm…

That’s it, congratulations, you can start using the examples provided within the ar-drone module.

Note: If you find any missing libraries while installing the previous modules:

I don’t think the following is required, but I had to do it as part of debugging the previous error. Please try not to run these commands and go directly to (3) – If you see any trouble, then come back and install these modules.

sudo npm install -g node-gyp

sudo apt-get install nodejs-legacy

sudo apt-get install bluez-hcidump

sudo hcidump -t -x

Advertisement

Author: Carlos Rodriguez Iturria

I am extremely passionate about people, technology and the most effective ways to connect the two by sharing my knowledge and experience. Working collaboratively with customers and partners inspires and excites me, especially when the outcome is noticeable valuable to a business and results in true innovation. I enjoy learning and teaching, as I recognise that this is a critical aspect of remaining at the forefront of technology in the modern era. Over the past 10+ years, I have developed and defined solutions that are reliable, secure and scalable, working closely with a diverse range of stakeholders. I enjoy leading engagements and am very active in the technical communities – both internal and external. I have stood out as a noticeable mentor running technology events across major cities in Australia and New Zealand, including various technology areas such as, Enterprise Integrations, API Management, Cloud Integration, IaaS and PaaS adoption, DevOps, Continuous Integration, Continuous Automation among others. In recent years, I have shaped my role and directed my capabilities towards educating and architecting benefits for customers using Oracle and AWS Cloud technologies. I get especially excited when I am able to position both as a way to exceed my customers’ expectations. I hold a bachelor degree in Computer Science and certifications in Oracle and AWS Solutions Architecture.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: