Class: MINT::Pose
- Inherits:
-
Hand
show all
- Defined in:
- lib/MINT-core/model/ir/body/pose.rb
Defined Under Namespace
Classes: StatefulProtocol
Constant Summary
collapse
- LEFT_HAND_POSE =
0
- RIGHT_HAND_POSE =
5
- PROCESS_RESOLUTION =
0.1
Constants inherited
from Interactor
Interactor::PUBLISH_ATTRIBUTES
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods inherited from Interactor
class_from_channel_name, #create_attribute_channel_name, create_channel_name, #create_channel_w_name, get, getModel, #getSCXML, get_dm, #init_statemachine, #is_in?, #new_states, notify, #process_event, #process_event!, #process_event_vars, #publish_update, #states, #states=, #sync_event, #sync_states, #to_dot, wait
#restart_timeout, #start_timeout, #stop_timeout
Constructor Details
#initialize(attributes = nil) ⇒ Pose
10
11
12
13
14
|
# File 'lib/MINT-core/model/ir/body/pose.rb', line 10
def initialize(attributes = nil)
super(attributes)
@buffer = ""
start
end
|
Instance Attribute Details
#buffer ⇒ Object
Returns the value of attribute buffer.
3
4
5
|
# File 'lib/MINT-core/model/ir/body/pose.rb', line 3
def buffer
@buffer
end
|
Instance Method Details
48
49
50
51
52
53
|
# File 'lib/MINT-core/model/ir/body/pose.rb', line 48
def inform_hand_appearance
if @no_hand
self.process_event :one_hand
@no_hand = false
end
end
|
#is_new_data?(data) ⇒ Boolean
42
43
44
45
46
|
# File 'lib/MINT-core/model/ir/body/pose.rb', line 42
def is_new_data?(data)
return false if data == nil or data.eql? @old_data
@old_data = data
true
end
|
#process_data ⇒ Object
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/MINT-core/model/ir/body/pose.rb', line 55
def process_data
data = @buffer.dup
d = data.split(';')
return if not is_new_data? d[RIGHT_HAND_POSE]
inform_hand_appearance
case d[RIGHT_HAND_POSE]
when 'prev'
self.process_event :previous_pose
when 'next'
self.process_event :next_pose
when 'select'
self.process_event :select_pose
when 'confirm'
self.process_event :confirm_pose
when '-'
self.process_event :no_hands
@no_hand = true
end
end
|
#start(host = "0.0.0.0", port = 5000) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/MINT-core/model/ir/body/pose.rb', line 28
def start(host ="0.0.0.0", port=5000)
EventMachine::start_server host, port, StatefulProtocol do |conn|
@connection = conn
conn.pose = self
puts "connection..."
self.process_event :connect
end
puts "Started pose control server on #{host}:#{port}"
EventMachine::add_periodic_timer( PROCESS_RESOLUTION ) { process_data }
end
|
#start_ticker(ms) ⇒ Object
16
17
18
19
20
21
|
# File 'lib/MINT-core/model/ir/body/pose.rb', line 16
def start_ticker(ms)
@ticker = EM::PeriodicTimer.new(0.8) {
p "tick"
self.process_event :tick
}
end
|
#stop_ticker ⇒ Object
23
24
25
|
# File 'lib/MINT-core/model/ir/body/pose.rb', line 23
def stop_ticker
@ticker.cancel if @ticker
end
|