#kalx15: Back to Basics

This weekend a couple of friends stopped by the house at around 5:45 on Saturday morning. Normally, this would not be welcomed, but it was time for our annual road trip out to attend the Kalamazoo X conference. This year marked my third year of attending this fantastic one-day, single-track, soft-skills conference. Though often referred to as a non-tech conference for techies, Kalamazoo X is a really accessible event and as such, this was the second year that my wife, Chrissy, also joined us.

This year's conference was held at Loft 310. I found the new venue — with attendees sat around tables similar to how people would be seated at a wedding or party — to be an improvement over last year. Though fantastic, last year's academic venue, larger attendance, and expanded speaker schedule lost much of the intimacy and community that made my first year at KalX a memorable and somewhat life adjusting event. This year was a return to that more intimate experience of two years ago, feeling much more like a gathering of friends and family than a conference of professionals.

The speaker schedule was also condensed this year and all the better for it. The roster included a welcome return of some KalX veterans like Jeff Blankenburg (@jeffblankenburg), H. Alan Stevens (@alanstevens), Jim Holmes (@aJimHolmes), and Elizabeth Naramore (@ElizabethN), as well as some newcomers like Jay Harris (@jayharris), Cori Drew (@coridrew), and Dawn Kuczwara (@digitaldawn). Though each topic was different, they were bound by the common year-on-year KalX themes of learning, mentoring, and growing.

Upon reflection, the talks that I remember most vividly were those where the speaker opened up, let down barriers, and gave honestly to the audience. Alan Stevens was, as always, a joyous speaker to experience — his command of space and time when delivering a talk is really exemplary, yet it was his candidness in discussing his struggle with depression with which I connected. While Cory House (@housecor) spoke on breaking the monotony in life and stepping outside of our comfort zones, it was when he opened up about his social anxieties and personal journey to overcome them that I took notice. And though Jay Harris delivered as polished a presentation as he ever has, it was his willingness to share his broken dreams of baseball and airplanes, open up about personal challenges, and be as raw with the attendees as he is with his friends that took his talk from good to great.

Though I enjoyed all the talks, it was Jay's talk, #conviction, that stood out most for me. Jay's message felt like the third part to a trilogy that started with Jeff Blankenburg's talk, "Be A Beginner", and was fleshed out by Alan Stevens' talk on "Values Driven Development". Jay judiciously spent every second of his time with a well thought out rebuttal to the too often repeated adages "follow your passion" and "hard work pays off". It is easy to ignore the privileges we have that we more commonly refer to as "talents", to let humility lessen their importance, but it is talent coupled with conviction that leads to success1.

Of course, it was not just about the guys. There was not only a more diverse audience than one might expect, but three of the eight speakers were women2. A favourite talk of the day for me was "Give Up!" from KalX newcomer, Dawn Kuczwara. Through personal anecdotes and a wonderful, personable delivery, Dawn explained the importance of letting go of control, of allowing people the opportunity to fail and learn, and of making sure not to stifle the growth of yourself or your team by micromanaging and "helping". To me, this talk was the second part to another trilogy that was started by Cori Drew and her impassioned (though perhaps a tad too long) talk that related her experiences mentoring her daughter from curious kid to seasoned speaker (at age 11), and closed with Elizabeth Naramore explaining why it is always OK to follow your passions in your leisure time, regardless of talent.

Though it was a long, tiring day (I drove, drank far too much caffeine, and stayed up way too late), Kalamazoo X was a day well spent. I am grateful to Michael Eaton (@mjeaton), Matt Davis (@mattsonlyattack), and all their minions, speakers, and tolerant friends and family for the time and patience spent in organising and delivering a terrific conference. Once more, after CodeMash had refreshed my curiosity, Kalamazoo X reset my spirit.

 

  1. having a passion for singing does not mean you can sing and no amount of hard work will change that []
  2. This shouldn't be a point of note, but in an industry traditionally dominated by men, it is []

Controlling a bot using node.js and express

Last week was our work hackathon. During these events we get to spend a day hacking around with something fun, whether it is work related or not. Thanks to my friend and colleague, Brian Genisio, this time around we got to tinker with hardware and build some bots.

Using node.js, johnny-five, an Arduino Uno board and a bunch of additional components, teams created their own sumo bots. At the end of the day, we competed to see who had the best bot. Ours was the only bot that walked instead of using wheels and we were confident our design could have won. Unfortunately,  we faced some technical difficulties and a couple of design issues that prevented us from achieving our full potential. You can see our bot (it's the large gold one that lumbers in from the bottom) take on all the others in this video and slowly start pushing them all out of the way.

http://youtu.be/pW6t5qfsc4g

As I am sure you can tell from the audio, this was a thoroughly enjoyable and highly competitive hackathon. There were a variety of problems to address as we developed our bots. Some of them were unique to the bot being created, others were comment to all. One such problem was how to control the bot. Regardless of how the signal got to the Arduino board (Bluetooth, RF and USB were available), we had to command our bots to move forwards, backwards, left and right (and in some cases, to deploy an extensive range of weaponry and distractions).

After some trial and error, I settled on using a simple web server and web page front-end that made API calls to the server. The server would then map these API calls to bot controls. This provided a way for us to use mouse, keyboard and touch input to control our electronic sumo minion. You can see the very basic user interface1 in this Vine that I took during our build.

https://vine.co/v/Ounjjiu6Br5

Using AngularJS, the buttons in the web page were connected to API calls. By clicking buttons in the web page, using the numpad or AWSD keys, or touching the screen of my laptop, we could control the robot. The API itself was implemented using the Express package in node.

Express

I installed express into our node application, using npm:

npm install express

Then I added express to our bot code and defined a simple API to process web requests:

var express = require("express");

var app = express();

app.post('/move', doMove);
app.post('/rotate', doRotate);
app.post('/stop', doStop);

app.use(express.static(__dirname + '/public'));

app.listen(4242);

This snippet of code has been edited down to show the pertinent details; you can view the real code on GitHub. First, we require the express module, then we use it to create our server app. The three calls to post set up our three API methods and the handlers for those methods. Using the post method defined these as POST endpoints, we could have used put, get or delete, if it were appropriate. The use call sets up a redirect for static page requests so that those requests are satisfied from our public directory. Finally, we tell the app to listen on port 4242.

Each request that matches one of the three calls I have setup will be sent to the appropriate handling methods. These handlers each take a request object and a response object, which they can use to get additional information about the request and craft an appropriate response.

Here is an implementation of the doRotate method:

function doRotate(req, res) {
    var direction = req.param('direction');
    var rate = req.param('rate');
    drive.rotate(direction, rate);
    res.send();
}

In this handler, we get the direction and rate parameters from the request and pass them to the code that does the real work. At the end, we respond to the request. We could provide data in our response or even send an error if we wanted.

This allowed me to host a local website and API for controlling our bot. It was that simple.

Conclusion

Hacking a robot using node.js was a great way to delve into a new facet of JavaScript programming; hacking hardware. Not only that, but it allowed me to discover some of the cooler things that can be done quickly and easily using node.js, such as setting up a web server using express.

Have you hacked a robot with node? How did you implement control? Please leave a comment with your experience or any questions you may have. And if you are interested in hacking a bot of your own, watch this space.

  1. and an early prototype of our robot []