2016 will likely be the year of IoT and after Christmas the new cool kid in town is definitely the Sphero BB8 bluetooth controlled Droid! So walking in Kean's footsteps who controls that robot from AutoCAD, I decided to have a play with it and integrate it with our View & Data API.
Being not much of a designer, I picked a free BB8 model on our Fusion gallery, credits and to thanks Farhan Suhaime. As Fusion model, this translate pretty good material-wise in View & Data API, see translated model.
For a first experiment, I kept things pretty simple, the idea is to control the droid through bluetooth connected to a local computer which runs a node local server. Two SDKs are available to do so from node: the official Orbotix JavaScript SDK module and the cylon.js package which exposes supports for many more devices. In the case of Sphero driver, Cylon is actually a very thin wrapper around the Sphero SDK, which has more samples by the way, so I would recommend installing both to take a look at useful examples.
What took me the most time to implement in that first version is the UI for the panel in the web page in order to control the droid. The virtual joystick allows to send 2d movements commands at specified speed and heading. The LED light can be set to any color and programmatically blinked:
This allows a user to interact with a REST API that controls the actual droid. The implementation is very basic at the moment:
The full sample is available from that github repository. Below is a quick video that demo the sample in action, it illustrates controlling the LED light and movement of the droid.The interest as far as View & Data is concerned is limited at the moment: the 3D model is translated but doesn't get any feedback from the real droid. It however sets the ground for more advanced usage. Having our droids represented in the viewer could allow the user to easily select one and let it perform actions in case we are dealing with more units and more complex environments. The droid can also stream to the controller information about velocity, so it could potentially update the UI by providing feedback.
In the next chapter I will implement a more useful approach where the droid can be controlled remotely from a cloud hosted application. A local node client will connect to that server and send commands to the droid. I'm also thinking taking advantage of the collision detection feature and implement some basic AI to handle obstacles and move around. Stay tuned...
This is a great project with great potential. I tried out your script but I've experienced problems connecting to the BB8, similar to the connection problems I've experienced using Cylon and the Javascript API. How did you deal with the connection to Bluetooth LE?
Posted by: Drillep | 04/19/2016 at 06:13 PM
Thanks. The BLE is definitely clunky... what I noticed is that if fails to connect, I use the App from my phone to connect to BB8, then try again with the API and it works fine.
I wrote a 2nd part to that tutorial that you may want to check:
http://adndevblog.typepad.com/cloud_and_mobile/2016/02/integrating-sphero-bb8-droid-with-view-data-api-part-ii.html
Hope that helps,
Philippe.
Posted by: Philippe Leefsma | 04/19/2016 at 07:15 PM