189 stories
·
2 followers

World Domination with Hexapods and Clojure

1 Comment

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
(ns clj-hexapod.core
  (require [serial-port :as serial]))

;; Use this command to see what port your serial port
;; is assinged to
(serial/list-ports)

;; replace the USB0 with whater it shows
(def port (serial/open "/dev/ttyUSB0" 38400))

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
(defn checksum [v]
  (mod (- 255 (reduce + v)) 256))

(defn vec->bytes [v]
  (byte-array (map #(-> % (Integer.) (.byteValue) (byte)) v)))

(defn build-packet [r-vert r-horz l-vert l-horz buttons]
  [255 ;header
   r-vert
   r-horz
   l-vert
   l-horz
   buttons
   0
   (checksum [r-vert r-horz l-vert l-horz buttons])])

(defn send [packet]
  (serial/write port (vec->bytes packet)))

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
;;values between 129-254
(defn up [speed]
  "joystick up for speed between 1-100"
  (if (good-range? speed)
    (int (+ 129 (* 125 (/ speed 100.0))))
    CENTER))

;;values between 0 and 125
(defn down [speed]
  "joystick down speed between 1-100"
  (if (good-range? speed)
    (int (- 125 (* 125 (/ speed 100.0))))
    CENTER))

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
(defn walk-forward [speed]
  "walk forward speed between 1-100"
  (send (build-packet CENTER CENTER (up speed) CENTER 0)))

(defn walk-backwards [speed]
  "walk backwards speed between 1-100"
  (send (build-packet CENTER CENTER (down speed) CENTER 0)))

(defn walk-right [speed]
  "walk right speed between 1-100"
  (send (build-packet CENTER CENTER CENTER (up speed) 0)))

(defn walk-left [speed]
  "walk right speed between 1-100"
  (send (build-packet CENTER CENTER CENTER (down speed) 0)))

(defn turn-right [speed]
  "turn right speed between 1-100"
  (send (build-packet CENTER (up speed) CENTER CENTER 0)))

(defn turn-left [speed]
  "turn left speed between 1-100"
  (send (build-packet CENTER (down speed) CENTER CENTER 0)))

(defn change-gait [gait-key]
  (let [gait-num (gait-key gaits)]
    (send (build-packet CENTER CENTER CENTER CENTER gait-num))))

(defn stop []
  "stop hexapod"
  (send (build-packet CENTER CENTER CENTER CENTER 0)))

You can control it from the REPL with some simple commands

1
2
3
4
5
6
7
8
9
10
11
(walk-forward 20)
(walk-backwards 10)
(walk-right 10)
(walk-left 10)
(turn-right 10)
(turn-left 10)
(change-gait :ripple-smooth)
(change-gait :tripod-normal)
(change-gait :ripple)
(change-gait :amble)
(stop)

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 :)

Read the whole story
bartlantz
3547 days ago
reply
clojure and hexapods FTW!
Share this story
Delete

Microsoft tells US: The world’s servers are not yours for the taking

1 Comment and 2 Shares

Microsoft's fight against the US position that it may search its overseas servers with a valid US warrant is getting nasty.

Microsoft, which is fighting a US warrant that it hand over e-mail to the US from its Ireland servers, wants the Obama administration to ponder a scenario where the "shoe is on the other foot."

"Imagine this scenario. Officers of the local Stadtpolizei investigating a suspected leak to the press descend on Deutsche Bank headquarters in Frankfurt, Germany," Microsoft said. "They serve a warrant to seize a bundle of private letters that a New York Times reporter is storing in a safe deposit box at a Deutsche Bank USA branch in Manhattan. The bank complies by ordering the New York branch manager to open the reporter's box with a master key, rummage through it, and fax the private letters to the Stadtpolizei."

Read 9 remaining paragraphs | Comments








Read the whole story
bartlantz
3634 days ago
reply
Wow, go Microsoft!
Share this story
Delete

Cindy Wilson performs vintage B-52s song

2 Shares
Cindy Wilson, founding member of The B-52s, has recently been performing with Glenn Phillips and his band at small venues in the Atlanta area. In this clip, she performs the classic song Hero Worship from the B's eponymous first album from 1978, and totally rocks it out.
Read the whole story
bartlantz
3640 days ago
reply
Share this story
Delete

Judge who unsealed phone snooping orders not a privacy-minded activist

1 Share

A Charlotte, North Carolina, judge has single-handedly sparked the release of surveillance applications involving the use of secretive cell-site simulators known as stingrays. To date, it's the most substantial set of surveillance applications—specifically "trap and trace device" orders, a cousin of the "pen register"—to become available.

Senior Resident Judge Richard Boner told Ars on Monday that he’s no privacy absolutist, and he shouldn't get credit. The way Boner sees it, he simply signed off on a common sense compromise between journalists and police.

"The Charlotte Observer has been pursuing this, and I met them two weeks ago with the editors and the reporters," Boner said. "They asked how they would be able to see the orders that had been entered and I said, 'file a motion and I will get police and district attorney to have their say and see if they had any objection for keeping them sealed.' As it turned out, the attorney for the Observer got together with the police attorney and they reached an agreement, so the records for cases that are now closed could be released and would not jeopardize prosecution. They agreed on the form—it wasn't necessarily a matter of me ordering to release the records."

Security through obscurity

While stingrays do target specific phones, they also sweep up cell data of innocents near by who have no idea that such collection is taking place. Authorities have been notoriously tight-lipped about how such devices are acquired and implemented. Former federal magistrate judge Brian Owsley (now a law professor at Indiana Tech) has been unsuccessful in his efforts to unseal similar orders despite familiarity with the legal system. And just last week, prosecutors in a Baltimore robbery case even dropped key evidence that stemmed from stingray use rather than fully disclose how the device was used.

Read 12 remaining paragraphs | Comments








Read the whole story
bartlantz
3648 days ago
reply
Share this story
Delete

Man exercising right to open carry robbed at gun point

2 Comments and 3 Shares
Via "William Coleman III of Gresham, Oregon, was robbed of his Walther-brand P22 handgun. The gun was stolen by a young man who walked up to Coleman, pulled out his own gun, and said, 'I like your gun. Give it to me.'"
Read the whole story
bartlantz
3696 days ago
reply
Share this story
Delete
2 public comments
deebee
3688 days ago
reply
Thats why you always carry TWO guns.
America City, America
vanbcguy
3689 days ago
reply
Priceless
Vancouver

Do animals cry?

1 Share
Maria Konnikova on the appearance and the authenticity of emotion in the animal kingdom--and how we can use science to explore it. Read the rest
Read the whole story
bartlantz
3718 days ago
reply
Share this story
Delete
Next Page of Stories