   ([hostname port proxies]
      (add-proxies {:hostname hostname :port port} proxies)))
 
+(defn attach-session
+  ""
+  [robot]
+  (let [app (make-application)
+        session (make-session (:hostname robot) (:port robot))]
+    ))
+
 (defn make-application
   "Creates an instance of an application object"
   []

(defn make-session
  "Create a session connected to a robot"
  [hostname port]
  (let [session (com.aldebaran.qimessaging.Session.)
        fut (.connect session (str "tcp://" hostname ":" port))]
        (.wait fut 1000)
        session))

(defn get-proxy
  "Gets a proxy from a robot, constructing it if necessary"

(defn wake-up
  "The robot wakes up: sets Motor on and, if needed, goes to initial position. For example, H25 or H21 sets the Stiffness on and keeps is current position."
  [robot]
  (call-service robot :motion "wakeUp"))

(defn relax
  "The robot rests: goes to a relax and safe position and sets Motor off. For example, H25 or H21 goes to the Crouch posture and sets the Stiffness off."
  [robot]
  (call-service robot :motion "rest"))

(defn walk
  "Walk at the specified speed. x, y, & theta represent normalised velocities from 0.0 to 1.0"
  [robot x y theta]
  (call-service robot :motion "moveToward" [x y theta]))

(defn walk-to
  "Walk to a specified location in the robot's frame of reference"
  [robot x y theta]
  (call-service robot :motion "moveTo" [x y theta]))

(defn get-joint-angles
  "Return a map of the current joint angles for a robot"
  [robot]
  (zipmap joint-names
          (call-service robot :motion "getAngles"
                      ["Body" true])))
(defn get-body-names
  "Return names of joints in the specified chain"
  [robot name]
  (call-service robot :motion "getBodyNames"  [name]))

;; broken - can't construct variant holding array of values
(defn set-joint-angles
  "Set the named joints to absolute changes"
  [robot names angles speed]
  (call-service robot :motion "setAngles"
              [(to-array names)
              (to-array angles) speed]))

;; broken - can't construct variant holding array of values
(defn change-joint-angles
  "Relative changes to joint angles"
  [robot names changes speed]
    (call-service robot :motion "changeAngles"
                   [(to-array names)
                   (to-array changes) speed]))

(defn get-robot-position
  "Get the current position of the robot using the sensors if true"
  [robot use-sensors]
  (call-service robot :motion "getRobotPosition"  [use-sensors]))

(defn get-position
  "Get the current 6D position (x, y, z, wx, wy, wz) of named component, using the sensors if use-sensors is true"
  [robot name space use-sensors]
  (call-service robot :motion "getPosition" [name space use-sensors]))

(defn get-sensor-names
  "Get the names of the available sensors"
  [robot]
  (call-service robot :motion "getSensorNames"))

; text to speech
(defn say
  "Say something"
  [robot text]
  (call-service robot :tts "say" [text]))

(defn get-language
  "Get the currently defined text-to-speech language"
  [robot]
  (call-service robot :tts "getLanguage"))

(defn set-language
  "Set the language the robot should use"
  [robot language]
  (call-service robot :tts "setLanguage" [language]))

(defn get-volume
  "Get the current volume for the robot"
  [robot]
  (call-service robot :tts "getVolume"))

(defn set-volume
  "Set the volume used by the robot"
  [robot vol]
  (call-service robot :tts "setVolume" [(float vol)]))
