Class: WiiRoboticArm
- Inherits:
-
SimpleWiimote
- Object
- SimpleWiimote
- WiiRoboticArm
- Defined in:
- lib/wii-robotic-arm.rb
Instance Method Summary collapse
-
#initialize ⇒ WiiRoboticArm
constructor
A new instance of WiiRoboticArm.
- #on_btn_1_press(wm) ⇒ Object
- #on_btn_2_press(wm) ⇒ Object
- #on_btn_a_down(wm) ⇒ Object
- #on_btn_a_up(wm) ⇒ Object
- #on_btn_b_down(wm) ⇒ Object
- #on_btn_b_up(wm) ⇒ Object
- #on_btn_down_down(wm) ⇒ Object
- #on_btn_down_up(wm) ⇒ Object
- #on_btn_left_down(wm) ⇒ Object
- #on_btn_left_up(wm) ⇒ Object
- #on_btn_minus_press(wm) ⇒ Object
- #on_btn_plus_press(wm) ⇒ Object
- #on_btn_right_down(wm) ⇒ Object
- #on_btn_right_up(wm) ⇒ Object
- #on_btn_up_down(wm) ⇒ Object
- #on_btn_up_up(wm) ⇒ Object
Constructor Details
#initialize ⇒ WiiRoboticArm
Returns a new instance of WiiRoboticArm.
10 11 12 13 14 15 |
# File 'lib/wii-robotic-arm.rb', line 10 def initialize() super() @ra = RoboticArm.new @played = nil @terminator = ['home'] end |
Instance Method Details
#on_btn_1_press(wm) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/wii-robotic-arm.rb', line 24 def on_btn_1_press(wm) if @ra.recording? then @ra.recording.stop @played = nil else @ra.recording.start end end |
#on_btn_2_press(wm) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/wii-robotic-arm.rb', line 33 def on_btn_2_press(wm) if @played != :reverse then puts 'playing in reverse' @ra.recording.reverse_play @played = :reverse else puts 'playing forward' @ra.recording.playback @played = :played end end |
#on_btn_a_down(wm) ⇒ Object
66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/wii-robotic-arm.rb', line 66 def on_btn_a_down(wm) x,y = wm.acc if x < 110 and @ra.base.moving? != :left then @ra.base.left elsif x > 130 and @ra.base.moving? != :right then @ra.base.right end if y < 117 and @ra.shoulder.moving? != :up then @ra.shoulder.up elsif y > 127 and @ra.shoulder.moving? != :down then @ra.shoulder.down end end |
#on_btn_a_up(wm) ⇒ Object
84 85 86 87 |
# File 'lib/wii-robotic-arm.rb', line 84 def on_btn_a_up(wm) @ra.base.stop @ra.shoulder.stop end |
#on_btn_b_down(wm) ⇒ Object
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/wii-robotic-arm.rb', line 89 def on_btn_b_down(wm) x,y = wm.acc if x < 110 and @ra.base.moving? != :left then @ra.base.left elsif x > 130 and @ra.base.moving? != :right then @ra.base.right end if y < 117 and @ra.elbow.moving? != :up then @ra.elbow.up elsif y > 127 and @ra.elbow.moving? != :down then @ra.elbow.down end end |
#on_btn_b_up(wm) ⇒ Object
107 108 109 110 |
# File 'lib/wii-robotic-arm.rb', line 107 def on_btn_b_up(wm) @ra.base.stop @ra.elbow.stop end |
#on_btn_down_down(wm) ⇒ Object
58 59 60 61 62 |
# File 'lib/wii-robotic-arm.rb', line 58 def on_btn_down_down(wm) if @ra.wrist.moving? != :down then @ra.wrist.down end end |
#on_btn_down_up(wm) ⇒ Object
64 |
# File 'lib/wii-robotic-arm.rb', line 64 def on_btn_down_up(wm) @ra.wrist.stop end |
#on_btn_left_down(wm) ⇒ Object
45 |
# File 'lib/wii-robotic-arm.rb', line 45 def on_btn_left_down(wm) @ra.gripper.open end |
#on_btn_left_up(wm) ⇒ Object
46 |
# File 'lib/wii-robotic-arm.rb', line 46 def on_btn_left_up(wm) @ra.gripper.stop end |
#on_btn_minus_press(wm) ⇒ Object
21 22 |
# File 'lib/wii-robotic-arm.rb', line 21 def on_btn_minus_press(wm) end |
#on_btn_plus_press(wm) ⇒ Object
17 18 19 |
# File 'lib/wii-robotic-arm.rb', line 17 def on_btn_plus_press(wm) @ra.led.on? ? @ra.led.off : @ra.led.on end |
#on_btn_right_down(wm) ⇒ Object
47 |
# File 'lib/wii-robotic-arm.rb', line 47 def on_btn_right_down(wm) @ra.gripper.close end |
#on_btn_right_up(wm) ⇒ Object
48 |
# File 'lib/wii-robotic-arm.rb', line 48 def on_btn_right_up(wm) @ra.gripper.stop end |
#on_btn_up_down(wm) ⇒ Object
50 51 52 53 54 |
# File 'lib/wii-robotic-arm.rb', line 50 def on_btn_up_down(wm) if @ra.wrist.moving? != :up then @ra.wrist.up end end |
#on_btn_up_up(wm) ⇒ Object
56 |
# File 'lib/wii-robotic-arm.rb', line 56 def on_btn_up_up(wm) @ra.wrist.stop end |