 (defn make-robot
   "Constructs a map representing a robot including any requested proxies. Most functions will construct the proxies they need on-the-fly if they are not already defined but since these are not stored it is more efficient to ask for any needed proxies in the call to make-robot."
   ([hostname] {:hostname hostname :port 9559})
-  ([hostname port] {:hostname hostname :port port})
+  ([hostname port] ( {:hostname hostname :port port}))
   ([hostname port proxies]
      (add-proxies {:hostname hostname :port port} proxies)))
+
+(defn make-application
+  "Creates an instance of an application object"
+  []
+  (com.aldebaran.qimessaging.Application.))
+
+(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"

                    :tts "com.aldebaran.proxy.ALTextToSpeechProxy"
                    })

(def joint-names '("HeadYaw", "HeadPitch", 
                   "LShoulderPitch", "LShoulderRoll", "LElbowYaw", "LElbowRoll", 
                   "LWristYaw", "LHand",
                   "LHipYawPitch", "LHipRoll", "LHipPitch", 
                   "LKneePitch", "LAnklePitch", "LAnkleRoll",
                   "RHipYawPitch", "RHipRoll", "RHipPitch", 
                   "RKneePitch",  "RAnklePitch", "RAnkleRoll",
                   "RShoulderPitch", "RShoulderRoll", "RElbowYaw", "RElbowRoll", 
                   "RWristYaw", "RHand"))

(def postures {:crouch "Crouch"

(defn set-volume
  "Set the volume used by the robot"
  [robot vol]
  (.setVolume (get-proxy robot :tts) (float vol)))
