rapiro_wrapper 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +16 -0
  3. data/.rspec +2 -0
  4. data/.ruby-gemset +1 -0
  5. data/.ruby-version +1 -0
  6. data/Gemfile +4 -0
  7. data/LICENSE.txt +22 -0
  8. data/README.md +138 -0
  9. data/Rakefile +5 -0
  10. data/bin/rapiro_wrapper +147 -0
  11. data/lib/rapiro_wrapper.rb +23 -0
  12. data/lib/rapiro_wrapper/body.rb +43 -0
  13. data/lib/rapiro_wrapper/command.rb +19 -0
  14. data/lib/rapiro_wrapper/commander.rb +28 -0
  15. data/lib/rapiro_wrapper/led.rb +4 -0
  16. data/lib/rapiro_wrapper/led/eyes.rb +23 -0
  17. data/lib/rapiro_wrapper/servo_motor.rb +27 -0
  18. data/lib/rapiro_wrapper/servo_motor/head.rb +21 -0
  19. data/lib/rapiro_wrapper/servo_motor/left_foot_pitch.rb +21 -0
  20. data/lib/rapiro_wrapper/servo_motor/left_foot_yaw.rb +21 -0
  21. data/lib/rapiro_wrapper/servo_motor/left_hand_grip.rb +21 -0
  22. data/lib/rapiro_wrapper/servo_motor/left_sholder_pitch.rb +18 -0
  23. data/lib/rapiro_wrapper/servo_motor/left_sholder_roll.rb +18 -0
  24. data/lib/rapiro_wrapper/servo_motor/right_foot_pitch.rb +21 -0
  25. data/lib/rapiro_wrapper/servo_motor/right_foot_yaw.rb +21 -0
  26. data/lib/rapiro_wrapper/servo_motor/right_hand_grip.rb +21 -0
  27. data/lib/rapiro_wrapper/servo_motor/right_sholder_pitch.rb +18 -0
  28. data/lib/rapiro_wrapper/servo_motor/right_sholder_roll.rb +14 -0
  29. data/lib/rapiro_wrapper/servo_motor/waist.rb +21 -0
  30. data/lib/rapiro_wrapper/version.rb +4 -0
  31. data/rapiro_wrapper.gemspec +27 -0
  32. data/spec/integration/base_spec.rb +577 -0
  33. data/spec/rapiro_wrapper/body_spec.rb +77 -0
  34. data/spec/rapiro_wrapper/command_spec.rb +54 -0
  35. data/spec/rapiro_wrapper/commander_spec.rb +111 -0
  36. data/spec/rapiro_wrapper/led/eyes_spec.rb +38 -0
  37. data/spec/rapiro_wrapper/servo_moter/head_spec.rb +248 -0
  38. data/spec/rapiro_wrapper/servo_moter/left_foot_pitch_spec.rb +261 -0
  39. data/spec/rapiro_wrapper/servo_moter/left_foot_yaw_spec.rb +256 -0
  40. data/spec/rapiro_wrapper/servo_moter/left_hand_grip_spec.rb +256 -0
  41. data/spec/rapiro_wrapper/servo_moter/left_sholder_pitch_spec.rb +134 -0
  42. data/spec/rapiro_wrapper/servo_moter/left_sholder_roll_spec.rb +150 -0
  43. data/spec/rapiro_wrapper/servo_moter/right_foot_pitch_spec.rb +261 -0
  44. data/spec/rapiro_wrapper/servo_moter/right_foot_yaw_spec.rb +256 -0
  45. data/spec/rapiro_wrapper/servo_moter/right_hand_grip_spec.rb +256 -0
  46. data/spec/rapiro_wrapper/servo_moter/right_sholder_pitch_spec.rb +134 -0
  47. data/spec/rapiro_wrapper/servo_moter/right_sholder_roll_spec.rb +150 -0
  48. data/spec/rapiro_wrapper/servo_moter/waist_spec.rb +248 -0
  49. data/spec/rapiro_wrapper/servo_moter_spec.rb +64 -0
  50. data/spec/rapiro_wrapper/version_spec.rb +11 -0
  51. data/spec/spec_helper.rb +4 -0
  52. metadata +199 -0
@@ -0,0 +1,256 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RapiroWrapper::LeftHandGrip do
4
+ context 'constants' do
5
+ context 'NO' do
6
+ subject { described_class.const_get(:NO) }
7
+ it { is_expected.to eq 7 }
8
+ end
9
+ context 'DEFAULT' do
10
+ subject { described_class.const_get(:DEFAULT) }
11
+ it { is_expected.to eq 90 }
12
+ end
13
+ context 'MIN' do
14
+ subject { described_class.const_get(:MIN) }
15
+ it { is_expected.to eq 60 }
16
+ end
17
+ context 'MAX' do
18
+ subject { described_class.const_get(:MAX) }
19
+ it { is_expected.to eq 110 }
20
+ end
21
+ end
22
+
23
+ context '.code' do
24
+ context 'without arguments' do
25
+ subject { described_class.code }
26
+ it { is_expected.to eq 'S07A090' }
27
+ end
28
+
29
+ context 'with both open and hold' do
30
+ subject { described_class.code(option) }
31
+ let(:option) { { open: 0, hold: 0 } }
32
+ it { expect { subject }.to raise_error ArgumentError }
33
+ end
34
+
35
+ context 'with open' do
36
+ subject { described_class.code(option) }
37
+
38
+ context '-180' do
39
+ let(:option) { { open: -180 } }
40
+ it { expect { subject }.to raise_error ArgumentError }
41
+ end
42
+
43
+ context '-90' do
44
+ let(:option) { { open: -90 } }
45
+ it { expect { subject }.to raise_error ArgumentError }
46
+ end
47
+
48
+ context '-1' do
49
+ let(:option) { { open: -1 } }
50
+ it { expect { subject }.to raise_error ArgumentError }
51
+ end
52
+
53
+ context '0' do
54
+ let(:option) { { open: 0 } }
55
+ it { is_expected.to eq 'S07A060' }
56
+ end
57
+
58
+ context '50' do
59
+ let(:option) { { open: 50 } }
60
+ it { is_expected.to eq 'S07A110' }
61
+ end
62
+
63
+ context '51' do
64
+ let(:option) { { open: 51 } }
65
+ it { expect { subject }.to raise_error ArgumentError }
66
+ end
67
+
68
+ context '90' do
69
+ let(:option) { { open: 90 } }
70
+ it { expect { subject }.to raise_error ArgumentError }
71
+ end
72
+
73
+ context '180' do
74
+ let(:option) { { open: 180 } }
75
+ it { expect { subject }.to raise_error ArgumentError }
76
+ end
77
+ end
78
+
79
+ context 'with hold' do
80
+ subject { described_class.code(option) }
81
+
82
+ context '-180' do
83
+ let(:option) { { hold: -180 } }
84
+ it { expect { subject }.to raise_error ArgumentError }
85
+ end
86
+
87
+ context '-90' do
88
+ let(:option) { { hold: -90 } }
89
+ it { expect { subject }.to raise_error ArgumentError }
90
+ end
91
+
92
+ context '-1' do
93
+ let(:option) { { hold: -1 } }
94
+ it { expect { subject }.to raise_error ArgumentError }
95
+ end
96
+
97
+ context '0' do
98
+ let(:option) { { hold: 0 } }
99
+ it { is_expected.to eq 'S07A110' }
100
+ end
101
+
102
+ context '50' do
103
+ let(:option) { { hold: 50 } }
104
+ it { is_expected.to eq 'S07A060' }
105
+ end
106
+
107
+ context '51' do
108
+ let(:option) { { hold: 51 } }
109
+ it { expect { subject }.to raise_error ArgumentError }
110
+ end
111
+
112
+ context '90' do
113
+ let(:option) { { hold: 90 } }
114
+ it { expect { subject }.to raise_error ArgumentError }
115
+ end
116
+
117
+ context '180' do
118
+ let(:option) { { hold: 180 } }
119
+ it { expect { subject }.to raise_error ArgumentError }
120
+ end
121
+ end
122
+ end
123
+
124
+ context 'constructor' do
125
+ context 'without arguments' do
126
+ subject { described_class.new }
127
+ it { expect { subject }.to_not raise_error }
128
+ context '@value' do
129
+ subject { described_class.new.instance_variable_get(:@value) }
130
+ it { is_expected.to eq 90 }
131
+ end
132
+ context '#to_code' do
133
+ subject { described_class.new.to_code }
134
+ it { is_expected.to eq 'S07A090' }
135
+ end
136
+ end
137
+
138
+ context 'with both open and hold' do
139
+ subject { described_class.new(option).instance_variable_get(:@value) }
140
+ let(:option) { { open: 0, hold: 0 } }
141
+ it { expect { subject }.to raise_error ArgumentError }
142
+ end
143
+
144
+ context 'with open' do
145
+ subject { described_class.new(option).instance_variable_get(:@value) }
146
+
147
+ context '-180' do
148
+ let(:option) { { open: -180 } }
149
+ it { expect { subject }.to raise_error ArgumentError }
150
+ end
151
+
152
+ context '-90' do
153
+ let(:option) { { open: -90 } }
154
+ it { expect { subject }.to raise_error ArgumentError }
155
+ end
156
+
157
+ context '-1' do
158
+ let(:option) { { open: -1 } }
159
+ it { expect { subject }.to raise_error ArgumentError }
160
+ end
161
+
162
+ context '0' do
163
+ let(:option) { { open: 0 } }
164
+ context '@value' do
165
+ it { is_expected.to eq 60 }
166
+ end
167
+ context '#to_code' do
168
+ subject { described_class.new(option).to_code }
169
+ it { is_expected.to eq 'S07A060' }
170
+ end
171
+ end
172
+
173
+ context '50' do
174
+ let(:option) { { open: 50 } }
175
+ context '@value' do
176
+ it { is_expected.to eq 110 }
177
+ end
178
+ context '#to_code' do
179
+ subject { described_class.new(option).to_code }
180
+ it { is_expected.to eq 'S07A110' }
181
+ end
182
+ end
183
+
184
+ context '51' do
185
+ let(:option) { { open: 51 } }
186
+ it { expect { subject }.to raise_error ArgumentError }
187
+ end
188
+
189
+ context '90' do
190
+ let(:option) { { open: 90 } }
191
+ it { expect { subject }.to raise_error ArgumentError }
192
+ end
193
+
194
+ context '180' do
195
+ let(:option) { { open: 180 } }
196
+ it { expect { subject }.to raise_error ArgumentError }
197
+ end
198
+ end
199
+
200
+ context 'with hold' do
201
+ subject { described_class.new(option).instance_variable_get(:@value) }
202
+
203
+ context '-180' do
204
+ let(:option) { { hold: -180 } }
205
+ it { expect { subject }.to raise_error ArgumentError }
206
+ end
207
+
208
+ context '-90' do
209
+ let(:option) { { hold: -90 } }
210
+ it { expect { subject }.to raise_error ArgumentError }
211
+ end
212
+
213
+ context '-1' do
214
+ let(:option) { { hold: -1 } }
215
+ it { expect { subject }.to raise_error ArgumentError }
216
+ end
217
+
218
+ context '0' do
219
+ let(:option) { { hold: 0 } }
220
+ context '@value' do
221
+ it { is_expected.to eq 110 }
222
+ end
223
+ context '#to_code' do
224
+ subject { described_class.new(option).to_code }
225
+ it { is_expected.to eq 'S07A110' }
226
+ end
227
+ end
228
+
229
+ context '50' do
230
+ let(:option) { { hold: 50 } }
231
+ context '@value' do
232
+ it { is_expected.to eq 60 }
233
+ end
234
+ context '#to_code' do
235
+ subject { described_class.new(option).to_code }
236
+ it { is_expected.to eq 'S07A060' }
237
+ end
238
+ end
239
+
240
+ context '51' do
241
+ let(:option) { { hold: 51 } }
242
+ it { expect { subject }.to raise_error ArgumentError }
243
+ end
244
+
245
+ context '90' do
246
+ let(:option) { { hold: 90 } }
247
+ it { expect { subject }.to raise_error ArgumentError }
248
+ end
249
+
250
+ context '180' do
251
+ let(:option) { { hold: 180 } }
252
+ it { expect { subject }.to raise_error ArgumentError }
253
+ end
254
+ end
255
+ end
256
+ end
@@ -0,0 +1,134 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RapiroWrapper::LeftSholderPitch do
4
+ context 'constants' do
5
+ context 'NO' do
6
+ subject { described_class.const_get(:NO) }
7
+ it { is_expected.to eq 6 }
8
+ end
9
+ context 'DEFAULT' do
10
+ subject { described_class.const_get(:DEFAULT) }
11
+ it { is_expected.to eq 50 }
12
+ end
13
+ context 'MIN' do
14
+ subject { described_class.const_get(:MIN) }
15
+ it { is_expected.to eq 50 }
16
+ end
17
+ context 'MAX' do
18
+ subject { described_class.const_get(:MAX) }
19
+ it { is_expected.to eq 140 }
20
+ end
21
+ end
22
+
23
+ context '.code' do
24
+ context 'without arguments' do
25
+ subject { described_class.code }
26
+ it { is_expected.to eq 'S06A050' }
27
+ end
28
+
29
+ context 'with up' do
30
+ subject { described_class.code(option) }
31
+
32
+ context '-180' do
33
+ let(:option) { { up: -180 } }
34
+ it { expect { subject }.to raise_error ArgumentError }
35
+ end
36
+
37
+ context '-90' do
38
+ let(:option) { { up: -90 } }
39
+ it { expect { subject }.to raise_error ArgumentError }
40
+ end
41
+
42
+ context '-1' do
43
+ let(:option) { { up: -1 } }
44
+ it { expect { subject }.to raise_error ArgumentError }
45
+ end
46
+
47
+ context '0' do
48
+ let(:option) { { up: 0 } }
49
+ it { is_expected.to eq 'S06A050' }
50
+ end
51
+
52
+ context '90' do
53
+ let(:option) { { up: 90 } }
54
+ it { is_expected.to eq 'S06A140' }
55
+ end
56
+
57
+ context '91' do
58
+ let(:option) { { up: 91 } }
59
+ it { expect { subject }.to raise_error ArgumentError }
60
+ end
61
+
62
+ context '180' do
63
+ let(:option) { { up: 180 } }
64
+ it { expect { subject }.to raise_error ArgumentError }
65
+ end
66
+ end
67
+ end
68
+
69
+ context 'constructor' do
70
+ context 'without arguments' do
71
+ subject { described_class.new }
72
+ it { expect { subject }.to_not raise_error }
73
+ context '@value' do
74
+ subject { described_class.new.instance_variable_get(:@value) }
75
+ it { is_expected.to eq 50 }
76
+ end
77
+ context '#to_code' do
78
+ subject { described_class.new.to_code }
79
+ it { is_expected.to eq 'S06A050' }
80
+ end
81
+ end
82
+
83
+ context 'with up' do
84
+ subject { described_class.new(option).instance_variable_get(:@value) }
85
+
86
+ context '-180' do
87
+ let(:option) { { up: -180 } }
88
+ it { expect { subject }.to raise_error ArgumentError }
89
+ end
90
+
91
+ context '-90' do
92
+ let(:option) { { up: -90 } }
93
+ it { expect { subject }.to raise_error ArgumentError }
94
+ end
95
+
96
+ context '-1' do
97
+ let(:option) { { up: -1 } }
98
+ it { expect { subject }.to raise_error ArgumentError }
99
+ end
100
+
101
+ context '0' do
102
+ let(:option) { { up: 0 } }
103
+ context '@value' do
104
+ it { is_expected.to eq 50 }
105
+ end
106
+ context '#to_code' do
107
+ subject { described_class.new(option).to_code }
108
+ it { is_expected.to eq 'S06A050' }
109
+ end
110
+ end
111
+
112
+ context '90' do
113
+ let(:option) { { up: 90 } }
114
+ context '@value' do
115
+ it { is_expected.to eq 140 }
116
+ end
117
+ context '#to_code' do
118
+ subject { described_class.new(option).to_code }
119
+ it { is_expected.to eq 'S06A140' }
120
+ end
121
+ end
122
+
123
+ context '91' do
124
+ let(:option) { { up: 91 } }
125
+ it { expect { subject }.to raise_error ArgumentError }
126
+ end
127
+
128
+ context '180' do
129
+ let(:option) { { up: 180 } }
130
+ it { expect { subject }.to raise_error ArgumentError }
131
+ end
132
+ end
133
+ end
134
+ end
@@ -0,0 +1,150 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RapiroWrapper::LeftSholderRoll do
4
+ context 'constants' do
5
+ context 'NO' do
6
+ subject { described_class.const_get(:NO) }
7
+ it { is_expected.to eq 5 }
8
+ end
9
+ context 'DEFAULT' do
10
+ subject { described_class.const_get(:DEFAULT) }
11
+ it { is_expected.to eq 180 }
12
+ end
13
+ context 'MIN' do
14
+ subject { described_class.const_get(:MIN) }
15
+ it { is_expected.to eq 0 }
16
+ end
17
+ context 'MAX' do
18
+ subject { described_class.const_get(:MAX) }
19
+ it { is_expected.to eq 180 }
20
+ end
21
+ end
22
+
23
+ context '.code' do
24
+ context 'without arguments' do
25
+ subject { described_class.code }
26
+ it { is_expected.to eq 'S05A180' }
27
+ end
28
+
29
+ context 'with up' do
30
+ subject { described_class.code(option) }
31
+
32
+ context '-180' do
33
+ let(:option) { { up: -180 } }
34
+ it { expect { subject }.to raise_error ArgumentError }
35
+ end
36
+
37
+ context '-90' do
38
+ let(:option) { { up: -90 } }
39
+ it { expect { subject }.to raise_error ArgumentError }
40
+ end
41
+
42
+ context '-1' do
43
+ let(:option) { { up: -1 } }
44
+ it { expect { subject }.to raise_error ArgumentError }
45
+ end
46
+
47
+ context '0' do
48
+ let(:option) { { up: 0 } }
49
+ it { is_expected.to eq 'S05A180' }
50
+ end
51
+
52
+ context '90' do
53
+ let(:option) { { up: 90 } }
54
+ it { is_expected.to eq 'S05A090' }
55
+ end
56
+
57
+ context '180' do
58
+ let(:option) { { up: 180 } }
59
+ it { is_expected.to eq 'S05A000' }
60
+ end
61
+
62
+ context '181' do
63
+ let(:option) { { up: 181 } }
64
+ it { expect { subject }.to raise_error ArgumentError }
65
+ end
66
+
67
+ context '270' do
68
+ let(:option) { { up: 270 } }
69
+ it { expect { subject }.to raise_error ArgumentError }
70
+ end
71
+ end
72
+ end
73
+
74
+ context 'constructor' do
75
+ context 'without arguments' do
76
+ subject { described_class.new }
77
+ it { expect { subject }.to_not raise_error }
78
+ context '@value' do
79
+ subject { described_class.new.instance_variable_get(:@value) }
80
+ it { is_expected.to eq 180 }
81
+ end
82
+ context '#to_code' do
83
+ subject { described_class.new.to_code }
84
+ it { is_expected.to eq 'S05A180' }
85
+ end
86
+ end
87
+
88
+ context 'with up' do
89
+ subject { described_class.new(option).instance_variable_get(:@value) }
90
+
91
+ context '-180' do
92
+ let(:option) { { up: -180 } }
93
+ it { expect { subject }.to raise_error ArgumentError }
94
+ end
95
+
96
+ context '-90' do
97
+ let(:option) { { up: -90 } }
98
+ it { expect { subject }.to raise_error ArgumentError }
99
+ end
100
+
101
+ context '-1' do
102
+ let(:option) { { up: -1 } }
103
+ it { expect { subject }.to raise_error ArgumentError }
104
+ end
105
+
106
+ context '0' do
107
+ let(:option) { { up: 0 } }
108
+ context '@value' do
109
+ it { is_expected.to eq 180 }
110
+ end
111
+ context '#to_code' do
112
+ subject { described_class.new(option).to_code }
113
+ it { is_expected.to eq 'S05A180' }
114
+ end
115
+ end
116
+
117
+ context '90' do
118
+ let(:option) { { up: 90 } }
119
+ context '@value' do
120
+ it { is_expected.to eq 90 }
121
+ end
122
+ context '#to_code' do
123
+ subject { described_class.new(option).to_code }
124
+ it { is_expected.to eq 'S05A090' }
125
+ end
126
+ end
127
+
128
+ context '180' do
129
+ let(:option) { { up: 180 } }
130
+ context '@value' do
131
+ it { is_expected.to eq 0 }
132
+ end
133
+ context '#to_code' do
134
+ subject { described_class.new(option).to_code }
135
+ it { is_expected.to eq 'S05A000' }
136
+ end
137
+ end
138
+
139
+ context '181' do
140
+ let(:option) { { up: 181 } }
141
+ it { expect { subject }.to raise_error ArgumentError }
142
+ end
143
+
144
+ context '270' do
145
+ let(:option) { { up: 270 } }
146
+ it { expect { subject }.to raise_error ArgumentError }
147
+ end
148
+ end
149
+ end
150
+ end