-
johnny-five is alive... yeah, original, I know
03/18/2017 at 05:48 • 0 commentsAfter installing the requisite packages on my Raspberry pi from the johnny-five.io website and reviewing examples, I realized one small oversight on my part. The "typical" use for johnny-five appears to be the ability to control a board (like an Arduino or Raspberry Pi) from a computer over a USB cable. You can install johnny-five on a Raspberry Pi itself, but then the use case is that the Rpi is the master and the board you connect (like an Arduino) is the slave. That's all well and good and part of what I wanted to do, but I *also* want to be able to control things *on* the Rpi at the same time.
I have googled all over and did not see examples of anyone saying that this could be done or had been done. Examples were either for the Rpi *or* the arduino. I find this shocking because it seems like the perfect robotic use case. Sure, there's piduino5, but again, that's just an Rpi controlling an Arduino without any specific control on the Rpi in addition.
I did find out how to set up multiple boards. With some digging I found out how to set up both types of boards and made adjustments for using the multi-board setup. I tinkered with the setup of LEDs and I found that I could blink LEDs on the Rpi AND the Arduino in the same script!
Below is my script. Very plain, it only tests with LEDs. I would consider this a "bilingual Hello World" for johnny-five. I hope this helps someone else scratching their head over the same dilemma,
/* ** Control Raspi AND Arduino ** (C) Dan Shaurette; licensed as CC-BY. ** http://creativecommons.org/licenses/by/4.0/ ** March 17, 2017 ** Using johnny-five.io */ var five = require("johnny-five"); var Raspi = require("raspi-io"); var ports = [ { id: "mega", port: "/dev/ttyACM0" }, { id: "rpi3", io: new Raspi() } ]; new five.Boards(ports).on("ready", function() { var aled = new five.Led({ pin: 13, board: this.byId("mega") }); var pled = new five.Led({ pin: "P1-13", board: this.byId("rpi3") }); aled.blink(); pled.blink(); this.on("exit", function() { aled.off(); pled.off(); }); });
-
Johnny-five/nodebots vs. ROS
03/15/2017 at 03:39 • 0 commentsTo celebrate #PiDay 2017, I decided it was time to investigate options for open-source robotics libraries and protocols that I could use with my Raspberry Pi 3 (and Arduino Mega). There's still a part of me that wants to just keep exploring and building Python scripts to find out just what I can accomplish with the Rpi and Arduino. There's also the part of me that wants to take full advantage of what others who've come before me have created that could move things along faster. The great thing about both approaches is that I can always scrap what I don't think is working and take another path.
So, what's out there? The one that is most mature and has many developers contributing to it is the Robot Operating System, aka ROS. As of the writing on this blog, Kinetic Kame is the most recent release, and on their wiki there are instructions on how to install it on the Raspberry Pi. To be blunt, it is not a simple process, but if everything installs without conflicts, it does seem straight-forward.
In fact, their upfront advice is to download an SD card image with Ubuntu and ROS installed. I agree, that would be a good idea, but I have invested quite a bit of time on my existing Raspbian (Debian Linux for Rpi) installation and I'm not going to scrap it. I may very well buy a new card and experiment with ROS in this way later.
Now, ROS itself is hefty. There are modules to build some amazing and sophisticated robots with many off the shelf parts and other popular libraries (like CV Computer Vision software). It also comes with 3D virtual prototyping environments so that you can design before you build with real parts. All of this is both a blessing and a curse. I'm sure there's a way to get only what you need, but in my admittedly cursory dive into their website, it feels like it might be too much overhead for what I want to build.
So for now, I'm setting ROS aside as a luxury item to find out more about later.
Another promising open-source project is Johnny-five.io, named after one of my favorite robots, from the movie "Short Circuit". This project uses the node.js Javascript environment on many platforms (Raspberry Pi included) to control an Arduino. You may have heard of nodebots, which are a type of robot built with Johnny-five.
What strikes me immediately is how lightweight, versatile, and easy-to-use this project is. I did have to do some digging into how to get node.js on my Rpi, but once that was done, the rest was trivial. Javascript is a language that many people can pick up quickly, so it was a wise choice by them, but admittedly not one that I would have expected. I mean, it's primarily for website design. I have never used node.js before but I have extensively used Javascript itself.
So, at least for now, I see more immediate value in Johnny-five, and if nothing else, I think it will be fun to experiment with. I will update later with my thoughts after I have a chance to play with it.
If YOU have used either ROS or Johnny-five and you have any advice, I would love to hear it.