wii-robotic-arm 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/wii-robotic-arm.rb +93 -0
  2. metadata +75 -0
@@ -0,0 +1,93 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ # file: wii-robotic-arm.rb
4
+
5
+ require 'robotic-arm'
6
+ require 'simple_wiimote'
7
+
8
+ class WiiRoboticArm < SimpleWiimote
9
+
10
+ def initialize()
11
+ super()
12
+ @ra = RoboticArm.new
13
+ end
14
+
15
+ private
16
+
17
+ def on_btn_plus_press(wm) @ra.led.on end
18
+ def on_btn_minus_press(wm) @ra.led.off end
19
+ def on_btn_plus_press(wm) @ra.led.on end
20
+ def on_btn_minus_press(wm) @ra.led.off end
21
+ def on_btn_left_down(wm) @ra.gripper.open end
22
+ def on_btn_left_up(wm) @ra.gripper.stop end
23
+ def on_btn_right_down(wm) @ra.gripper.close end
24
+ def on_btn_right_up(wm) @ra.gripper.stop end
25
+
26
+ def on_btn_up_down(wm)
27
+ if @ra.wrist.moving? != :up then
28
+ @ra.wrist.up
29
+ end
30
+ end
31
+
32
+ def on_btn_up_up(wm) @ra.wrist.stop end
33
+
34
+ def on_btn_down_down(wm)
35
+ if @ra.wrist.moving? != :down then
36
+ @ra.wrist.down
37
+ end
38
+ end
39
+
40
+ def on_btn_down_up(wm) @ra.wrist.stop end
41
+
42
+ def on_btn_a_down(wm)
43
+
44
+ x,y = wm.acc
45
+
46
+ if x < 110 and @ra.base.moving? != :left then
47
+ @ra.base.left
48
+ elsif x > 130 and @ra.base.moving? != :right then
49
+ @ra.base.right
50
+ end
51
+
52
+ if y < 117 and @ra.shoulder.moving? != :up then
53
+ @ra.shoulder.up
54
+ elsif y > 127 and @ra.shoulder.moving? != :down then
55
+ @ra.shoulder.down
56
+ end
57
+
58
+ end
59
+
60
+ def on_btn_a_up(wm)
61
+ @ra.base.stop
62
+ @ra.shoulder.stop
63
+ end
64
+
65
+ def on_btn_b_down(wm)
66
+
67
+ x,y = wm.acc
68
+
69
+ if x < 110 and @ra.base.moving? != :left then
70
+ @ra.base.left
71
+ elsif x > 130 and @ra.base.moving? != :right then
72
+ @ra.base.right
73
+ end
74
+
75
+ if y < 117 and @ra.elbow.moving? != :up then
76
+ @ra.elbow.up
77
+ elsif y > 127 and @ra.elbow.moving? != :down then
78
+ @ra.elbow.down
79
+ end
80
+
81
+ end
82
+
83
+ def on_btn_b_up(wm)
84
+ @ra.base.stop
85
+ @ra.elbow.stop
86
+ end
87
+
88
+ end
89
+
90
+ if __FILE__ == $0 then
91
+ wra = WiiRoboticArm.new
92
+ wra.activate
93
+ end
metadata ADDED
@@ -0,0 +1,75 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wii-robotic-arm
3
+ version: !ruby/object:Gem::Version
4
+ prerelease:
5
+ version: 0.1.0
6
+ platform: ruby
7
+ authors:
8
+ - James Robertson
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+
13
+ date: 2012-12-20 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
16
+ name: simple_wiimote
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "0"
24
+ type: :runtime
25
+ version_requirements: *id001
26
+ - !ruby/object:Gem::Dependency
27
+ name: robotic-arm
28
+ prerelease: false
29
+ requirement: &id002 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ">="
33
+ - !ruby/object:Gem::Version
34
+ version: "0"
35
+ type: :runtime
36
+ version_requirements: *id002
37
+ description:
38
+ email:
39
+ executables: []
40
+
41
+ extensions: []
42
+
43
+ extra_rdoc_files: []
44
+
45
+ files:
46
+ - lib/wii-robotic-arm.rb
47
+ homepage:
48
+ licenses: []
49
+
50
+ post_install_message:
51
+ rdoc_options: []
52
+
53
+ require_paths:
54
+ - lib
55
+ required_ruby_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ">="
59
+ - !ruby/object:Gem::Version
60
+ version: "0"
61
+ required_rubygems_version: !ruby/object:Gem::Requirement
62
+ none: false
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: "0"
67
+ requirements: []
68
+
69
+ rubyforge_project:
70
+ rubygems_version: 1.8.23
71
+ signing_key:
72
+ specification_version: 3
73
+ summary: wii-robotic-arm
74
+ test_files: []
75
+