MINT-core 1.0.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. data/Gemfile +22 -3
  2. data/Gemfile.lock +98 -22
  3. data/History.txt +262 -0
  4. data/LICENSE +30 -0
  5. data/MINT-core.gemspec +25 -80
  6. data/Manifest.txt +145 -30
  7. data/README.rdoc +6 -163
  8. data/Rakefile +16 -17
  9. data/bin/mint-aui +3 -3
  10. data/bin/mint-cui-gfx +3 -2
  11. data/bin/mint-juggernaut.sh +0 -0
  12. data/bin/mint-tuplespace +0 -0
  13. data/lib/MINT-core.rb +53 -15
  14. data/lib/MINT-core/agent/agent.rb +1 -1
  15. data/lib/MINT-core/agent/aui.rb +0 -14
  16. data/lib/MINT-core/agent/auicontrol.rb +91 -38
  17. data/lib/MINT-core/agent/cui-gfx.rb +3 -3
  18. data/lib/MINT-core/agent/cuicontrol.rb +94 -24
  19. data/lib/MINT-core/connector/redis_connector.rb +16 -0
  20. data/lib/MINT-core/manager/mapping_manager.rb +101 -0
  21. data/lib/MINT-core/manager/mapping_parser.rb +89 -0
  22. data/lib/MINT-core/manager/mapping_server.rb +99 -0
  23. data/lib/MINT-core/manager/position_updater.rb +33 -0
  24. data/lib/MINT-core/manager/scxml_client.rb +118 -0
  25. data/lib/MINT-core/manager/scxml_server.rb +86 -0
  26. data/lib/MINT-core/mapping/action/action.rb +32 -0
  27. data/lib/MINT-core/mapping/action/backend_action.rb +32 -0
  28. data/lib/MINT-core/mapping/action/bind_action.rb +88 -0
  29. data/lib/MINT-core/mapping/action/event_action.rb +40 -0
  30. data/lib/MINT-core/mapping/complementary_mapping.rb +31 -0
  31. data/lib/MINT-core/mapping/mapping.rb +170 -34
  32. data/lib/MINT-core/mapping/observation/negation_observation.rb +64 -0
  33. data/lib/MINT-core/mapping/observation/observation.rb +219 -0
  34. data/lib/MINT-core/mapping/sequential.rb +1 -2
  35. data/lib/MINT-core/mapping/sequential_mapping.rb +60 -0
  36. data/lib/MINT-core/model/aui/AIChoiceElement.rb +17 -0
  37. data/lib/MINT-core/model/aui/AICommand.rb +7 -0
  38. data/lib/MINT-core/model/aui/AIContainer.rb +73 -0
  39. data/lib/MINT-core/model/aui/AIContext.rb +12 -0
  40. data/lib/MINT-core/model/aui/AIIN.rb +8 -0
  41. data/lib/MINT-core/model/aui/AIINContinuous.rb +56 -0
  42. data/lib/MINT-core/model/aui/AIINDiscrete.rb +8 -0
  43. data/lib/MINT-core/model/aui/AIMultiChoice.rb +1 -2
  44. data/lib/MINT-core/model/aui/AIMultiChoiceElement.rb +4 -51
  45. data/lib/MINT-core/model/aui/AIO.rb +76 -123
  46. data/lib/MINT-core/model/aui/AIOUT.rb +8 -0
  47. data/lib/MINT-core/model/aui/AIOUTContinuous.rb +61 -0
  48. data/lib/MINT-core/model/aui/AIReference.rb +16 -0
  49. data/lib/MINT-core/model/aui/AISingleChoice.rb +18 -1
  50. data/lib/MINT-core/model/aui/AISingleChoiceElement.rb +10 -56
  51. data/lib/MINT-core/model/aui/AISinglePresence.rb +39 -71
  52. data/lib/MINT-core/model/aui/aicommand.scxml +47 -0
  53. data/lib/MINT-core/model/aui/aicontainer.scxml +41 -0
  54. data/lib/MINT-core/model/aui/aicontext.scxml +34 -0
  55. data/lib/MINT-core/model/aui/aiincontinuous.scxml +59 -0
  56. data/lib/MINT-core/model/aui/aiinrange.scxml +86 -0
  57. data/lib/MINT-core/model/aui/aimultichoice.scxml +67 -0
  58. data/lib/MINT-core/model/aui/aimultichoiceelement.scxml +51 -0
  59. data/lib/MINT-core/model/aui/aio.scxml +18 -27
  60. data/lib/MINT-core/model/aui/aioutcontinuous.scxml +66 -0
  61. data/lib/MINT-core/model/aui/aireference.scxml +28 -0
  62. data/lib/MINT-core/model/aui/aisinglechoice.scxml +60 -0
  63. data/lib/MINT-core/model/aui/aisinglechoiceelement.scxml +45 -60
  64. data/lib/MINT-core/model/aui/aisinglepresence.scxml +15 -24
  65. data/lib/MINT-core/model/aui/model.rb +15 -38
  66. data/lib/MINT-core/model/cui/gfx/CIC.rb +34 -10
  67. data/lib/MINT-core/model/cui/gfx/CIO.rb +66 -115
  68. data/lib/MINT-core/model/cui/gfx/CarouFredSel.scxml +58 -0
  69. data/lib/MINT-core/model/cui/gfx/MarkableRadioButton.rb +8 -0
  70. data/lib/MINT-core/model/cui/gfx/RadioButton.rb +8 -0
  71. data/lib/MINT-core/model/cui/gfx/RadioButtonGroup.rb +6 -0
  72. data/lib/MINT-core/model/cui/gfx/button.rb +16 -0
  73. data/lib/MINT-core/model/cui/gfx/button.scxml +58 -0
  74. data/lib/MINT-core/model/cui/gfx/caroufredsel.rb +48 -0
  75. data/lib/MINT-core/model/cui/gfx/cic.scxml +57 -0
  76. data/lib/MINT-core/model/cui/gfx/cio.scxml +54 -0
  77. data/lib/MINT-core/model/cui/gfx/markableradiobutton.scxml +67 -0
  78. data/lib/MINT-core/model/cui/gfx/model.rb +39 -176
  79. data/lib/MINT-core/model/cui/gfx/radiobutton.scxml +59 -0
  80. data/lib/MINT-core/model/interactor.rb +167 -46
  81. data/lib/MINT-core/model/interactor.scxml +3 -0
  82. data/lib/MINT-core/model/interactor_helpers.rb +25 -0
  83. data/lib/MINT-core/model/ir/body/OneHandPoseNavigation.rb +15 -0
  84. data/lib/MINT-core/model/ir/body/body.rb +5 -0
  85. data/lib/MINT-core/model/ir/body/fingertip.rb +114 -0
  86. data/lib/MINT-core/model/ir/body/fingertip.scxml +43 -0
  87. data/lib/MINT-core/model/{body → ir/body}/gesture_button.rb +0 -0
  88. data/lib/MINT-core/model/ir/body/hand.rb +5 -0
  89. data/lib/MINT-core/model/ir/body/head.rb +102 -0
  90. data/lib/MINT-core/model/ir/body/head.scxml +92 -0
  91. data/lib/MINT-core/model/ir/body/onehandposenavigation.scxml +53 -0
  92. data/lib/MINT-core/model/ir/body/pose.rb +99 -0
  93. data/lib/MINT-core/model/ir/browserscreen.rb +27 -0
  94. data/lib/MINT-core/model/ir/browserscreen.scxml +14 -0
  95. data/lib/MINT-core/model/{device → ir}/button.rb +1 -1
  96. data/lib/MINT-core/model/ir/ir.rb +5 -0
  97. data/lib/MINT-core/model/ir/irmedia.rb +5 -0
  98. data/lib/MINT-core/model/ir/irmode.rb +5 -0
  99. data/lib/MINT-core/model/{device → ir}/joypad.rb +1 -1
  100. data/lib/MINT-core/model/ir/mouse.rb +44 -0
  101. data/lib/MINT-core/model/ir/mouse.scxml +35 -0
  102. data/lib/MINT-core/model/{device/mouse.rb → ir/mouse_old.rb} +2 -2
  103. data/lib/MINT-core/model/{device → ir}/pointer.rb +20 -22
  104. data/lib/MINT-core/model/ir/pointer.scxml +19 -0
  105. data/lib/MINT-core/model/ir/screen.rb +5 -0
  106. data/lib/MINT-core/model/{device → ir}/wheel.rb +1 -1
  107. data/lib/MINT-core/model/mim/aicommand_activate_to_button_press.xml +13 -0
  108. data/lib/MINT-core/model/mim/aicommand_deactivate_to_button_release.xml +13 -0
  109. data/lib/MINT-core/model/mim/aio_defocus_to_cio_unhighlight.xml +13 -0
  110. data/lib/MINT-core/model/mim/aio_focus_to_cio_highlight.xml +14 -0
  111. data/lib/MINT-core/model/mim/aio_present_to_cio_display.xml +14 -0
  112. data/lib/MINT-core/model/mim/aio_suspend_to_cio_hide.xml +13 -0
  113. data/lib/MINT-core/model/mim/aisinglechoice_present_to_child_present.xml +14 -0
  114. data/lib/MINT-core/model/mim/aisinglechoiceelement_chosen_to_radiobutton_select.xml +13 -0
  115. data/lib/MINT-core/model/mim/aisinglechoiceelement_unchosen_to_radiobutton_unselect.xml +13 -0
  116. data/lib/MINT-core/model/mim/aisinglepresence_children_finished_to_caroufredsel_init_js.xml +14 -0
  117. data/lib/MINT-core/model/mim/aisinglepresence_present_to_child_present.xml +15 -0
  118. data/lib/MINT-core/model/mim/browserscreen_reload_to_cuicontrol_refresh_all.xml +12 -0
  119. data/lib/MINT-core/model/mim/button_press_to_aicommand_activate.xml +12 -0
  120. data/lib/MINT-core/model/mim/button_release_to_aicommand_deactivate.xml +12 -0
  121. data/lib/MINT-core/model/mim/caroufredsel_refreshing_to_caroufredsel_init_js.xml +14 -0
  122. data/lib/MINT-core/model/mim/cio_display_to_aio_defocus.xml +13 -0
  123. data/lib/MINT-core/model/mim/cio_display_to_aio_present.xml +12 -0
  124. data/lib/MINT-core/model/mim/cio_display_to_cio_display_cache_add.xml +11 -0
  125. data/lib/MINT-core/model/mim/cio_hide_to_aio_suspend.xml +12 -0
  126. data/lib/MINT-core/model/mim/cio_hide_to_cio_display_cache_remove.xml +12 -0
  127. data/lib/MINT-core/model/mim/cio_highlight_to_aio_focus.xml +13 -0
  128. data/lib/MINT-core/model/mim/head_looking_left_to_aisinglepresence_prev.xml +14 -0
  129. data/lib/MINT-core/model/mim/head_looking_right_to_aisinglepresence_next.xml +15 -0
  130. data/lib/MINT-core/model/mim/head_nodding_to_aisinglepresence_next.xml +15 -0
  131. data/lib/MINT-core/model/mim/head_tilting_left_to_aisinglepresence_prev.xml +14 -0
  132. data/lib/MINT-core/model/mim/head_tilting_right_to_aisinglepresence_next.xml +15 -0
  133. data/lib/MINT-core/model/mim/left_button_aisinglepresence_enter.xml +15 -0
  134. data/lib/MINT-core/model/mim/left_button_aisinglepresence_next.xml +15 -0
  135. data/lib/MINT-core/model/mim/mim_default.xml +52 -0
  136. data/lib/MINT-core/model/mim/mint-mappings.xsd +127 -0
  137. data/lib/MINT-core/model/mim/mouse_press_to_aicommand_activate.xml +17 -0
  138. data/lib/MINT-core/model/mim/mouse_press_to_aisinglechoiceelement_choose.xml +17 -0
  139. data/lib/MINT-core/model/mim/mouse_press_to_aisinglechoiceelement_unchoose.xml +17 -0
  140. data/lib/MINT-core/model/mim/mouse_release_to_aicommand_deactivate.xml +16 -0
  141. data/lib/MINT-core/model/mim/mouse_stop_to_cio_highlight.xml +13 -0
  142. data/lib/MINT-core/model/mim/onehandposnav_confirm_to_aichoiceelement_choose.xml +14 -0
  143. data/lib/MINT-core/model/mim/onehandposnav_next_to_aio_next.xml +14 -0
  144. data/lib/MINT-core/model/mim/onehandposnav_previous_to_aio_prev.xml +14 -0
  145. data/lib/MINT-core/model/mim/radiobutton_selected_to_aisinglechoiceelement_choose.xml +13 -0
  146. data/lib/MINT-core/model/mim/radiobutton_unselected_to_aisinglechoiceelement_unchoose.xml +13 -0
  147. data/lib/MINT-core/model/mim/right_button_aisinglepresence_prev.xml +15 -0
  148. data/lib/MINT-core/model/task.rb +6 -6
  149. data/script/console +0 -0
  150. data/script/destroy +0 -0
  151. data/script/generate +0 -0
  152. data/spec/AICommand_spec.rb +20 -0
  153. data/spec/AIContainer_spec.rb +161 -0
  154. data/spec/AIINContinuous_spec.rb +92 -0
  155. data/spec/AIOUTContinuous_spec.rb +93 -0
  156. data/spec/AIO_spec.rb +73 -0
  157. data/spec/AIReference_spec.rb +105 -0
  158. data/spec/AISinglePresence_spec.rb +204 -60
  159. data/spec/Button_spec.rb +114 -0
  160. data/spec/CIO_spec.rb +145 -0
  161. data/spec/Interactor_spec.rb +95 -0
  162. data/spec/MappingManager_spec.rb +126 -0
  163. data/spec/Spontaneous_spec.rb +53 -0
  164. data/spec/aio_agent_spec.rb +215 -186
  165. data/spec/aisinglechoice_spec.rb +147 -88
  166. data/spec/aisinglechoiceelement_spec.rb +154 -70
  167. data/spec/complementary_mapping_spec.rb +158 -0
  168. data/spec/core_spec.rb +27 -15
  169. data/spec/cui_helper.rb +100 -0
  170. data/spec/examples/browserscreen_reload_to_cuicontrol_refresh_all.xml +12 -0
  171. data/spec/examples/mim_streaming_example.xml +9 -0
  172. data/spec/examples/mouse_highlight.xml +22 -0
  173. data/spec/examples/performance_mapping.xml +15 -0
  174. data/spec/examples/reset_click.xml +24 -0
  175. data/spec/interactor_test.scxml +32 -0
  176. data/spec/interactor_test_2.scxml +16 -0
  177. data/spec/mapping_performance_spec.rb +118 -0
  178. data/spec/mapping_server_spec.rb +161 -0
  179. data/spec/mapping_spec.rb +307 -0
  180. data/spec/music_spec.rb +301 -135
  181. data/spec/performance_counter.scxml +9 -0
  182. data/spec/sequential_mappings_spec.rb +69 -0
  183. data/spec/shared/aio_shared.rb +144 -0
  184. data/spec/spec_helper.rb +22 -3
  185. data/spec/spontaneous.scxml +11 -0
  186. data/spec/support/connection_helper.rb +19 -0
  187. data/spec/support/redis_connector_monkey_patch.rb +1 -0
  188. data/spec/support/statemachine_helper.rb +84 -0
  189. data/spec/sync_mappings_spec.rb +96 -0
  190. metadata +219 -354
  191. data/lib/MINT-core/mapping/complementary.rb +0 -100
  192. data/lib/MINT-core/mapping/on_state_change.rb +0 -65
  193. data/lib/MINT-core/model/aui/AIC.rb +0 -86
  194. data/lib/MINT-core/model/aui/AIChoice.rb +0 -65
  195. data/lib/MINT-core/model/aui/AIINChoose.rb +0 -54
  196. data/lib/MINT-core/model/aui/AIOUTDiscrete.rb +0 -43
  197. data/lib/MINT-core/model/aui/aic.png +0 -0
  198. data/lib/MINT-core/model/aui/aic.scxml +0 -50
  199. data/lib/MINT-core/model/aui/aichoice.png +0 -0
  200. data/lib/MINT-core/model/aui/aichoice.scxml +0 -60
  201. data/lib/MINT-core/model/aui/aio.png +0 -0
  202. data/lib/MINT-core/model/aui/aisinglechoiceelement.png +0 -0
  203. data/lib/MINT-core/model/aui/aisinglepresence.png +0 -0
  204. data/lib/MINT-core/model/body/handgesture.rb +0 -279
  205. data/lib/MINT-core/model/body/head.png +0 -0
  206. data/lib/MINT-core/model/body/head.rb +0 -51
  207. data/lib/MINT-core/model/body/head.scxml +0 -28
  208. data/lib/MINT-core/model/cui/gfx/screen.rb +0 -18
  209. data/lib/MINT-core/overrides/rinda.rb +0 -34
  210. data/spec/AIC_spec.rb +0 -69
  211. data/spec/MINT-core_spec.rb +0 -11
  212. data/spec/aio_spec.rb +0 -144
  213. data/spec/cio_spec.rb +0 -369
  214. data/tasks/rspec.rake +0 -21
@@ -0,0 +1,43 @@
1
+ <scxml initial="disconnected" name="Fingertip" version="0.9" xmlns="http://www.w3.org/2005/07/scxml"><!-- node-size-and-position x=0.0 y=0.0 w=870.0 h=660.0 -->
2
+ <state id="disconnected"><!-- node-size-and-position x=280.0 y=60.0 w=100.0 h=50.0 -->
3
+ <onentry>
4
+ <log expr="consume(name)"></log>
5
+ </onentry>
6
+ <transition event="connect" target="connected"></transition>
7
+ </state>
8
+ <state id="connected"><!-- node-size-and-position x=70.0 y=190.0 w=760.0 h=410.0 -->
9
+ <onentry>
10
+ <script>
11
+
12
+ @d = consume(&quot;data&quot;)
13
+ </script>
14
+ </onentry>
15
+ <transition event="disconnect" target="disconnected"><!-- edge-path [disconnected] x=400.0 y=160.0 --></transition>
16
+ <parallel id="finger"><!-- node-size-and-position x=40.0 y=50.0 w=610.0 h=290.0 -->
17
+ <state id="touch_handling" initial="waiting"><!-- node-size-and-position x=20.0 y=40.0 w=290.0 h=170.0 -->
18
+ <state id="waiting"><!-- node-size-and-position x=30.0 y=40.0 w=100.0 h=40.0 -->
19
+ <transition event="press" target="touching"></transition>
20
+ </state>
21
+ <state id="touching"><!-- node-size-and-position x=30.0 y=120.0 w=100.0 h=30.0 -->
22
+ <transition event="release" target="touched"></transition>
23
+ </state>
24
+ <state id="touched"><!-- node-size-and-position x=170.0 y=60.0 w=90.0 h=30.0 -->
25
+ <onentry>
26
+ <script>
27
+ start_one_time_tick(0.3,:tick)
28
+ </script>
29
+ </onentry>
30
+ <transition event="tick" target="waiting"></transition>
31
+ </state>
32
+ </state>
33
+ <state id="movement" initial="stopped"><!-- node-size-and-position x=340.0 y=40.0 w=150.0 h=190.0 -->
34
+ <state id="stopped"><!-- node-size-and-position x=20.0 y=40.0 w=100.0 h=40.0 -->
35
+ <transition event="move" target="moving"><!-- edge-path [moving] x=20.0 y=100.0 pointx=0.0 pointy=-14.0 offsetx=-8.0 offsety=6.0 --></transition>
36
+ </state>
37
+ <state id="moving"><!-- node-size-and-position x=20.0 y=120.0 w=100.0 h=40.0 -->
38
+ <transition event="stop" target="stopped"></transition>
39
+ </state>
40
+ </state>
41
+ </parallel>
42
+ </state>
43
+ </scxml>
@@ -0,0 +1,5 @@
1
+ module MINT
2
+ class Hand < Body
3
+
4
+ end
5
+ end
@@ -0,0 +1,102 @@
1
+
2
+ module MINT
3
+ class Head < Body
4
+ attr_accessor :connection
5
+ property :head_angle, Float, :default => Math::PI/2
6
+ property :head_angle_threshold, Float, :default => 0.2
7
+ property :nose_x, Float, :default => 0
8
+ property :nose_x_threshold, Float, :default => 0.05
9
+ property :nose_y, Float, :default => 0
10
+ property :nose_y_threshold, Float, :default => 0.05
11
+
12
+ def getSCXML
13
+ "#{File.dirname(__FILE__)}/head.scxml"
14
+ end
15
+
16
+ def initialize(attributes = nil)
17
+ super(attributes)
18
+ end
19
+
20
+ def start(host ="0.0.0.0", port=4242)
21
+ EventMachine::start_server host, port, StatefulProtocol do |conn|
22
+ @connection = conn
23
+
24
+ conn.head = self
25
+ puts "connection..."
26
+ self.process_event :connect
27
+ end
28
+ puts "Started head control server on #{host}:#{port}"
29
+ end
30
+
31
+ def consume_nose_movement(consume = true)
32
+ @connection.consume_nose_movement = consume
33
+ end
34
+
35
+ def consume_head_movement(consume = true)
36
+ @connection.consume_head_movement = consume
37
+ [@head_x,@head_y, @head_scale, @hand_angle]
38
+ end
39
+
40
+ class StatefulProtocol < EventMachine::Connection
41
+ include EM::Protocols::LineText2
42
+ attr_accessor :head
43
+ attr_accessor :consume_head_movement, :consume_nose_movement
44
+ # attr_accessor :speed
45
+
46
+ def initialize
47
+ super()
48
+ @consume_head_movement = false
49
+ @consume_nose_movement = false
50
+
51
+ end
52
+
53
+ def receive_line(data)
54
+ begin
55
+ d = data.split('/')
56
+
57
+ case d[0]
58
+ when "Move", "HeadMove"
59
+ if @consume_head_movement
60
+ head_x = d[1].gsub(',',".").to_f
61
+ head_y = d[2].gsub(',',".").to_f
62
+ head_scale = d[3].gsub(',',".").to_f
63
+ @head_angle = d[4].gsub(',',".").to_f
64
+
65
+ if (@head.head_angle-@head_angle).abs > @head.head_angle_threshold
66
+ @head.process_event "head_move"
67
+ @head.attribute_set(:head_angle,@head_angle)
68
+ @channel_name = @head.create_attribute_channel_name("head_angle")
69
+ RedisConnector.redis.publish @channel_name,MultiJson.encode({:name=>@head.name,:head_angle => @head_angle})
70
+ end
71
+ end
72
+ when "FaceMove"
73
+ if @consume_nose_movement
74
+ @nose_x = d[1].gsub(',',".").to_f
75
+ @nose_y = d[2].gsub(',',".").to_f
76
+
77
+ if (@head.nose_x-@nose_x).abs > @head.nose_x_threshold or (@head.nose_y-@nose_y).abs > @head.nose_y_threshold
78
+ @head.process_event "face_move"
79
+ @head.attribute_set(:nose_x,@nose_x)
80
+ @head.attribute_set(:nose_y,@nose_y)
81
+ @channel_name = @head.create_attribute_channel_name("nose")
82
+ RedisConnector.redis.publish @channel_name,MultiJson.encode({:name=>@head.name,:x => @nose_x,:y =>@nose_y})
83
+ RedisConnector.redis.publish("out_channel:#{@head.create_channel_w_name}:testuser",MultiJson.encode({:name=>@head.name,:x => @nose_x,:y =>@nose_y}))
84
+ end
85
+ end
86
+ when 'Leave'
87
+ @head.process_event :face_lost
88
+ when 'Enter'
89
+ @head.process_event :face_found
90
+ else
91
+ p "ERROR\r\nReceived Unknown data:#{data}\r\n "
92
+ end
93
+ end
94
+ rescue Statemachine::TransitionMissingException => bang
95
+ puts "ERROR\n#{bang}"
96
+ end
97
+ end
98
+
99
+
100
+
101
+ end
102
+ end
@@ -0,0 +1,92 @@
1
+ <scxml initial="disconnected" name="disconnect" version="0.9" xmlns="http://www.w3.org/2005/07/scxml"><!-- node-size-and-position x=0.0 y=0.0 w=1190.0 h=580.0 -->
2
+ <state id="disconnected"><!-- node-size-and-position x=220.0 y=30.0 w=100.0 h=50.0 -->
3
+ <transition event="connect" target="connected"></transition>
4
+ </state>
5
+ <state id="connected" initial="face_detected"><!-- node-size-and-position x=40.0 y=110.0 w=1140.0 h=460.0 -->
6
+ <transition event="disconnect" target="disconnected"><!-- edge-path [disconnected] x=400.0 y=120.0 --></transition>
7
+ <state id="face_detected" initial="tilting_detection"><!-- node-size-and-position x=20.0 y=100.0 w=1100.0 h=340.0 -->
8
+ <transition event="face_lost" target="face_lost"><!-- edge-path [face_lost] x=300.0 y=80.0 --></transition>
9
+ <state id="tilting_detection" initial="centered"><!-- node-size-and-position x=20.0 y=40.0 w=520.0 h=120.0 -->
10
+ <onentry>
11
+ <script>
12
+
13
+ consume_head_movement(true);
14
+ </script>
15
+ </onentry>
16
+ <onexit>
17
+ <script>
18
+
19
+ consume_head_movement(false);
20
+ </script>
21
+ </onexit>
22
+ <transition event="turn_mode" target="turning_detection"><!-- edge-path [turning_detection] x=190.0 y=180.0 --></transition>
23
+ <transition event="nodd_mode" target="nodding_detection"><!-- edge-path [nodding_detection] x=600.0 y=100.0 --></transition>
24
+ <state id="centered"><!-- node-size-and-position x=210.0 y=40.0 w=100.0 h=40.0 -->
25
+ <transition cond="@head_angle &gt; ((Math::PI/2)+0.4)" event="head_move" target="tilting_right"></transition>
26
+ <transition cond="@head_angle &lt; ((Math::PI/2)-0.4)" event="head_move" target="tilting_left"></transition>
27
+ </state>
28
+ <state id="tilting_right"><!-- node-size-and-position x=400.0 y=40.0 w=90.0 h=40.0 -->
29
+ <transition cond="@head_angle &lt; ((Math::PI/2)+0.4)" event="head_move" target="centered"><!-- edge-path [centered] x=360.0 y=90.0 --></transition>
30
+ </state>
31
+ <state id="tilting_left"><!-- node-size-and-position x=20.0 y=40.0 w=100.0 h=40.0 -->
32
+ <transition cond="@head_angle &gt; ((Math::PI/2)-0.4)" event="head_move" target="centered"><!-- edge-path [centered] x=170.0 y=80.0 pointx=0.0 pointy=-20.0 offsetx=9.0 offsety=1.0 --></transition>
33
+ </state>
34
+ </state>
35
+ <state id="turning_detection" initial="looking_straight"><!-- node-size-and-position x=30.0 y=210.0 w=520.0 h=120.0 -->
36
+ <onentry>
37
+ <script>
38
+
39
+ consume_nose_movement(true);
40
+ </script>
41
+ </onentry>
42
+ <onexit>
43
+ <script>
44
+
45
+ consume_nose_movement(false);
46
+ </script>
47
+ </onexit>
48
+ <transition event="tilt_mode" target="tilting_detection"></transition>
49
+ <transition event="nodd_mode" target="nodding_detection"></transition>
50
+ <state id="looking_straight"><!-- node-size-and-position x=210.0 y=40.0 w=100.0 h=40.0 -->
51
+ <transition cond="@nose_x &gt; 0.8" event="face_move" target="looking_right"></transition>
52
+ <transition cond="@nose_x &lt; -0.8" event="face_move" target="looking_left"></transition>
53
+ </state>
54
+ <state id="looking_right"><!-- node-size-and-position x=400.0 y=40.0 w=90.0 h=40.0 -->
55
+ <transition cond="-0.5 &lt; @nose_x and @nose_x &lt; 0.5" event="face_move" target="looking_straight"><!-- edge-path [looking_straight] x=360.0 y=90.0 --></transition>
56
+ </state>
57
+ <state id="looking_left"><!-- node-size-and-position x=20.0 y=40.0 w=100.0 h=40.0 -->
58
+ <transition cond="-0.5 &lt; @nose_x and @nose_x &lt; 0.5" event="face_move" target="looking_straight"><!-- edge-path [looking_straight] x=170.0 y=80.0 pointx=0.0 pointy=-20.0 offsetx=9.0 offsety=1.0 --></transition>
59
+ </state>
60
+ </state>
61
+ <state id="nodding_detection" initial="neutral"><!-- node-size-and-position x=680.0 y=110.0 w=380.0 h=170.0 -->
62
+ <onentry>
63
+ <script>
64
+
65
+ consume_nose_movement(true);
66
+ </script>
67
+ </onentry>
68
+ <onexit>
69
+ <script>
70
+
71
+ consume_nose_movement(false);
72
+ </script>
73
+ </onexit>
74
+ <transition event="tilt_mode" target="tilting_detection"></transition>
75
+ <transition event="turn_mode" target="turning_detection"><!-- edge-path [turning_detection] x=610.0 y=260.0 --></transition>
76
+ <state id="looking_down"><!-- node-size-and-position x=280.0 y=40.0 w=90.0 h=50.0 -->
77
+ <transition cond="0.5&gt; @nose_y and @nose_y &gt; -0.5" event="face_move" target="nodded"></transition>
78
+ <transition cond="0.5&lt; @nose_y or @nose_y &lt; -0.5" event="face_move" target="neutral"><!-- edge-path [neutral] x=210.0 y=40.0 --></transition>
79
+ </state>
80
+ <state id="neutral"><!-- node-size-and-position x=30.0 y=40.0 w=80.0 h=50.0 -->
81
+ <transition cond="@nose_y&lt;=0.2 and 0.5&gt;@nose_x and @nose_x &gt;-0.5" event="face_move" target="looking_down"></transition>
82
+ </state>
83
+ <state id="nodded"><!-- node-size-and-position x=150.0 y=100.0 w=90.0 h=50.0 -->
84
+ <transition target="neutral"></transition>
85
+ </state>
86
+ </state>
87
+ </state>
88
+ <state id="face_lost"><!-- node-size-and-position x=360.0 y=30.0 w=100.0 h=40.0 -->
89
+ <transition event="face_found" target="face_detected"></transition>
90
+ </state>
91
+ </state>
92
+ </scxml>
@@ -0,0 +1,53 @@
1
+ <scxml initial="disconnected" name="OneHandNav_Final" version="0.9" xmlns="http://www.w3.org/2005/07/scxml"><!-- node-size-and-position x=0.0 y=0.0 w=670.0 h=760.0 -->
2
+ <state id="connected" initial="NoHands"><!-- node-size-and-position x=20.0 y=110.0 w=640.0 h=640.0 -->
3
+ <transition event="disconnect" target="disconnected"><!-- edge-path [disconnected] x=360.0 y=60.0 pointx=0.0 pointy=12.0 offsetx=-24.0 offsety=-1.0 --></transition>
4
+ <state id="OneHand"><!-- node-size-and-position x=20.0 y=120.0 w=620.0 h=500.0 -->
5
+ <transition event="no_hands" target="NoHands"><!-- edge-path [NoHands] x=270.0 y=100.0 pointx=0.0 pointy=-30.0 offsetx=20.0 offsety=29.0 --></transition>
6
+ <state id="Navigation" initial="stopped"><!-- node-size-and-position x=20.0 y=40.0 w=600.0 h=440.0 -->
7
+ <state id="Command"><!-- node-size-and-position x=140.0 y=330.0 w=300.0 h=110.0 -->
8
+ <transition event="next_pose" target="next"><!-- edge-path [next] x=110.0 y=290.0 pointx=0.0 pointy=-49.0 offsetx=-7.0 offsety=37.0 --></transition>
9
+ <transition event="previous_pose" target="previous"><!-- edge-path [previous] x=410.0 y=300.0 pointx=-1.0 pointy=-14.0 offsetx=77.0 offsety=-52.0 --></transition>
10
+ <state id="confirmed"><!-- node-size-and-position x=30.0 y=40.0 w=80.0 h=40.0 -->
11
+ <transition event="select_pose" target="selected"><!-- edge-path [selected] pointx=0.0 pointy=-10.0 offsetx=5.0 offsety=0.0 --></transition>
12
+ </state>
13
+ <state id="selected"><!-- node-size-and-position x=200.0 y=40.0 w=80.0 h=40.0 -->
14
+ <transition event="confirm_pose" target="confirmed"><!-- edge-path [confirmed] x=160.0 y=40.0 pointx=0.0 pointy=-10.0 offsetx=5.0 offsety=0.0 --></transition>
15
+ </state>
16
+ </state>
17
+ <state id="stopped"><!-- node-size-and-position x=230.0 y=200.0 w=100.0 h=40.0 -->
18
+ <transition event="next_pose" target="next"><!-- edge-path [next] x=150.0 y=220.0 pointx=0.0 pointy=-30.0 offsetx=0.0 offsety=-15.0 --></transition>
19
+ <transition event="previous_pose" target="previous"><!-- edge-path [previous] x=380.0 y=220.0 --></transition>
20
+ <transition event="confirm_pose" target="confirmed"></transition>
21
+ </state>
22
+ <state id="next"><!-- node-size-and-position x=100.0 y=130.0 w=80.0 h=50.0 -->
23
+ <onentry>
24
+ <script>start_ticker(800)</script>
25
+ </onentry>
26
+ <onexit>
27
+ <script>stop_ticker</script>
28
+ </onexit>
29
+ <transition event="previous_pose" target="previous"><!-- edge-path [previous] x=250.0 y=140.0 pointx=0.0 pointy=15.0 offsetx=-5.0 offsety=0.0 --></transition>
30
+ <transition event="select_pose" target="stopped"></transition>
31
+ <transition event="tick" target="next"><!-- edge-path [next] pointx=0.0 pointy=-25.0 offsetx=-5.0 offsety=0.0 --></transition>
32
+ </state>
33
+ <state id="previous"><!-- node-size-and-position x=310.0 y=130.0 w=100.0 h=50.0 -->
34
+ <onentry>
35
+ <script>start_ticker(800)</script>
36
+ </onentry>
37
+ <onexit>
38
+ <script>stop_ticker</script>
39
+ </onexit>
40
+ <transition event="next_pose" target="next"><!-- edge-path [next] x=249.0 y=157.0 pointx=0.0 pointy=13.0 offsetx=5.0 offsety=0.0 --></transition>
41
+ <transition event="tick" target="previous"></transition>
42
+ <transition event="select_pose" target="stopped"></transition>
43
+ </state>
44
+ </state>
45
+ </state>
46
+ <state id="NoHands"><!-- node-size-and-position x=160.0 y=40.0 w=100.0 h=40.0 -->
47
+ <transition event="one_hand" target="OneHand"><!-- edge-path [OneHand] x=170.0 y=100.0 --></transition>
48
+ </state>
49
+ </state>
50
+ <state id="disconnected"><!-- node-size-and-position x=170.0 y=40.0 w=100.0 h=30.0 -->
51
+ <transition event="connect" target="connected"><!-- edge-path [connected] x=130.0 y=50.0 pointx=-1.0 pointy=19.0 offsetx=-41.0 offsety=2.0 --></transition>
52
+ </state>
53
+ </scxml>
@@ -0,0 +1,99 @@
1
+ module MINT
2
+ class Pose < Hand
3
+ attr_accessor :buffer
4
+
5
+ LEFT_HAND_POSE = 0
6
+ RIGHT_HAND_POSE = 5
7
+
8
+ PROCESS_RESOLUTION = 0.1
9
+
10
+ def initialize(attributes = nil)
11
+ super(attributes)
12
+ @buffer = ""
13
+ start
14
+ end
15
+
16
+ def start_ticker(ms)
17
+ @ticker = EM::PeriodicTimer.new(0.8) {
18
+ p "tick"
19
+ self.process_event :tick
20
+ }
21
+ end
22
+
23
+ def stop_ticker
24
+ @ticker.cancel if @ticker
25
+ end
26
+
27
+
28
+ def start(host ="0.0.0.0", port=5000)
29
+ EventMachine::start_server host, port, StatefulProtocol do |conn|
30
+ @connection = conn
31
+
32
+ conn.pose = self
33
+ puts "connection..."
34
+ self.process_event :connect
35
+ end
36
+ puts "Started pose control server on #{host}:#{port}"
37
+
38
+ EventMachine::add_periodic_timer( PROCESS_RESOLUTION ) { process_data }
39
+
40
+ end
41
+
42
+ def is_new_data?(data)
43
+ return false if data == nil or data.eql? @old_data
44
+ @old_data = data
45
+ true
46
+ end
47
+
48
+ def inform_hand_appearance
49
+ if @no_hand
50
+ self.process_event :one_hand
51
+ @no_hand = false
52
+ end
53
+ end
54
+
55
+ def process_data
56
+ # -;;;;;prev;599;1877;138;74
57
+ data = @buffer.dup # real copy
58
+ d = data.split(';')
59
+
60
+ return if not is_new_data? d[RIGHT_HAND_POSE]
61
+
62
+ inform_hand_appearance
63
+
64
+ case d[RIGHT_HAND_POSE]
65
+ when 'prev'
66
+ self.process_event :previous_pose
67
+ when 'next'
68
+ self.process_event :next_pose
69
+ when 'select'
70
+ self.process_event :select_pose
71
+ when 'confirm'
72
+ self.process_event :confirm_pose
73
+ when '-'
74
+ self.process_event :no_hands
75
+ @no_hand = true
76
+ end
77
+ end
78
+
79
+ class StatefulProtocol < EventMachine::Connection
80
+ include EM::Protocols::LineText2
81
+ attr_accessor :pose
82
+
83
+ def initialize
84
+ super()
85
+
86
+ end
87
+
88
+ def receive_line(data)
89
+ pose.buffer = data
90
+ end
91
+
92
+ def unbind
93
+ pose.process_event :disconnect
94
+ end
95
+
96
+ end
97
+
98
+ end
99
+ end
@@ -0,0 +1,27 @@
1
+ module MINT
2
+
3
+ class BrowserScreen < Screen
4
+ def getSCXML
5
+ "#{File.dirname(__FILE__)}/browserscreen.scxml"
6
+ end
7
+
8
+ def subscribe_for_refresh
9
+ return if @subscribed
10
+
11
+ redis = RedisConnector.redis
12
+
13
+ fiber = Fiber.current
14
+
15
+ redis.pubsub.psubscribe('in_channel:Interactor.BrowserScreen.reload*') { |key,message|
16
+ if message
17
+ process_event :reload
18
+ end
19
+
20
+ }.callback { @subscribed = true; fiber.resume}
21
+ Fiber.yield
22
+
23
+
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,14 @@
1
+ <scxml initial="displaying" name="BrowserScreen" version="0.9" xmlns="http://www.w3.org/2005/07/scxml"><!-- node-size-and-position x=0.0 y=0.0 w=662.0 h=580.0 -->
2
+ <state id="displaying"><!-- node-size-and-position x=100.0 y=200.0 w=100.0 h=100.0 -->
3
+ <onentry>
4
+ <script>
5
+
6
+ subscribe_for_refresh
7
+ </script>
8
+ </onentry>
9
+ <transition event="reload" target="reloaded"></transition>
10
+ </state>
11
+ <state id="reloaded"><!-- node-size-and-position x=370.0 y=200.0 w=100.0 h=100.0 -->
12
+ <transition target="displaying"><!-- edge-path [displaying] x=290.0 y=190.0 --></transition>
13
+ </state>
14
+ </scxml>
@@ -1,6 +1,6 @@
1
1
  module MINT
2
2
 
3
- class HWButton < Element
3
+ class HWButton < Interactor
4
4
 
5
5
  def initialize_statemachine
6
6
  if @statemachine.blank?