Once you have your hexapod assembled and running using the hand held controller, of course, your thoughts naturally turn to world domination.
The most powerful tool in the world is the Clojure REPL
World domination requires the most powerful tools available. That of course calls for Clojure and the Clojure REPL. I recommend Emacs as the editor of choice of such an endeavor. However, it if you are content with city, state, or single country domination, other editors that support Clojure are also fine.
Connect the XBee to your computer
First, we need to get the computer to talk to the hexapod wirelessly. We can do this with a USB to Serial adapter that uses the paired XBee from the handheld commander.
Take the XBee from the handheld commander
and move it to the USB to serial adapter
Now plug the usb into your computer.
Get your Clojure ready
In your clojure project, the only magic you need is the Serial Port library. Import the library and list your serial ports. Then open the one that shows up for you.
1 2 3 4 5 6 7 8 9
Since we are going to be talking to the hexapod. We need to send the commands in the same format that it is expecting. Basically, a packet of where the postions of the joystick are, as well as what buttons are pushed.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
From here, we can simply make functions for the joystick controls to go up and down
1 2 3 4 5 6 7 8 9 10 11 12 13
Then we can do things like walk, turn, and change the gait
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
You can control it from the REPL with some simple commands
1 2 3 4 5 6 7 8 9 10 11
If you want to see the code, it is out on github as clj-hexapod. Please keep in mind that it is early days still, and I am still just exploring.
Phoneix Code Firmware
It is worth noting the the above code was meant to run with the default hexapod firmware. That is the “Nuke” firmware. There is another firmware, the Phoenix code, that gives the hexapod more lifelike moves and allows it to twist and shift is rather creepy ways.
I just loaded it on the hexapod yesterday. The commander software changed too, so I will of course need to revisit the code, to add in the new moves. But here is a sneak preview of what it can do:
That is my daughter singing in the background
That’s all for now
I hope I have given you pointers for getting started on your own world domination with Clojure and Hexapods. Remember to practice your laugh …. Muhahaha :)