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,261 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RapiroWrapper::LeftFootPitch do
4
+ context 'constants' do
5
+ context 'NO' do
6
+ subject { described_class.const_get(:NO) }
7
+ it { is_expected.to eq 11 }
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 70 }
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 'S11A090' }
27
+ end
28
+
29
+ context 'with both open and close' do
30
+ subject { described_class.code(option) }
31
+ let(:option) { { open: 0, close: 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 '-21' do
49
+ let(:option) { { open: -21 } }
50
+ it { expect { subject }.to raise_error ArgumentError }
51
+ end
52
+
53
+ context '-1' do
54
+ let(:option) { { open: -1 } }
55
+ it { expect { subject }.to raise_error ArgumentError }
56
+ end
57
+
58
+ context '0' do
59
+ let(:option) { { open: 0 } }
60
+ it { is_expected.to eq 'S11A070' }
61
+ end
62
+
63
+ context '40' do
64
+ let(:option) { { open: 40 } }
65
+ it { is_expected.to eq 'S11A110' }
66
+ end
67
+
68
+ context '41' do
69
+ let(:option) { { open: 41 } }
70
+ it { expect { subject }.to raise_error ArgumentError }
71
+ end
72
+
73
+ context '90' do
74
+ let(:option) { { open: 90 } }
75
+ it { expect { subject }.to raise_error ArgumentError }
76
+ end
77
+
78
+ context '180' do
79
+ let(:option) { { open: 180 } }
80
+ it { expect { subject }.to raise_error ArgumentError }
81
+ end
82
+ end
83
+
84
+ context 'with close' do
85
+ subject { described_class.code(option) }
86
+
87
+ context '-180' do
88
+ let(:option) { { close: -180 } }
89
+ it { expect { subject }.to raise_error ArgumentError }
90
+ end
91
+
92
+ context '-90' do
93
+ let(:option) { { close: -90 } }
94
+ it { expect { subject }.to raise_error ArgumentError }
95
+ end
96
+
97
+ context '-1' do
98
+ let(:option) { { close: -1 } }
99
+ it { expect { subject }.to raise_error ArgumentError }
100
+ end
101
+
102
+ context '0' do
103
+ let(:option) { { close: 0 } }
104
+ it { is_expected.to eq 'S11A110' }
105
+ end
106
+
107
+ context '40' do
108
+ let(:option) { { close: 40 } }
109
+ it { is_expected.to eq 'S11A070' }
110
+ end
111
+
112
+ context '41' do
113
+ let(:option) { { close: 41 } }
114
+ it { expect { subject }.to raise_error ArgumentError }
115
+ end
116
+
117
+ context '90' do
118
+ let(:option) { { close: 90 } }
119
+ it { expect { subject }.to raise_error ArgumentError }
120
+ end
121
+
122
+ context '180' do
123
+ let(:option) { { close: 180 } }
124
+ it { expect { subject }.to raise_error ArgumentError }
125
+ end
126
+ end
127
+ end
128
+
129
+ context 'constructor' do
130
+ context 'without arguments' do
131
+ subject { described_class.new }
132
+ it { expect { subject }.to_not raise_error }
133
+ context '@value' do
134
+ subject { described_class.new.instance_variable_get(:@value) }
135
+ it { is_expected.to eq 90 }
136
+ end
137
+ context '#to_code' do
138
+ subject { described_class.new.to_code }
139
+ it { is_expected.to eq 'S11A090' }
140
+ end
141
+ end
142
+
143
+ context 'with both open and close' do
144
+ subject { described_class.new(option).instance_variable_get(:@value) }
145
+ let(:option) { { open: 0, close: 0 } }
146
+ it { expect { subject }.to raise_error ArgumentError }
147
+ end
148
+
149
+ context 'with open' do
150
+ subject { described_class.new(option).instance_variable_get(:@value) }
151
+
152
+ context '-180' do
153
+ let(:option) { { open: -180 } }
154
+ it { expect { subject }.to raise_error ArgumentError }
155
+ end
156
+
157
+ context '-90' do
158
+ let(:option) { { open: -90 } }
159
+ it { expect { subject }.to raise_error ArgumentError }
160
+ end
161
+
162
+ context '-1' do
163
+ let(:option) { { open: -1 } }
164
+ it { expect { subject }.to raise_error ArgumentError }
165
+ end
166
+
167
+ context '0' do
168
+ let(:option) { { open: 0 } }
169
+ context '@value' do
170
+ it { is_expected.to eq 70 }
171
+ end
172
+ context '#to_code' do
173
+ subject { described_class.new(option).to_code }
174
+ it { is_expected.to eq 'S11A070' }
175
+ end
176
+ end
177
+
178
+ context '40' do
179
+ let(:option) { { open: 40 } }
180
+ context '@value' do
181
+ it { is_expected.to eq 110 }
182
+ end
183
+ context '#to_code' do
184
+ subject { described_class.new(option).to_code }
185
+ it { is_expected.to eq 'S11A110' }
186
+ end
187
+ end
188
+
189
+ context '41' do
190
+ let(:option) { { open: 41 } }
191
+ it { expect { subject }.to raise_error ArgumentError }
192
+ end
193
+
194
+ context '90' do
195
+ let(:option) { { open: 90 } }
196
+ it { expect { subject }.to raise_error ArgumentError }
197
+ end
198
+
199
+ context '180' do
200
+ let(:option) { { open: 180 } }
201
+ it { expect { subject }.to raise_error ArgumentError }
202
+ end
203
+ end
204
+
205
+ context 'with close' do
206
+ subject { described_class.new(option).instance_variable_get(:@value) }
207
+
208
+ context '-180' do
209
+ let(:option) { { close: -180 } }
210
+ it { expect { subject }.to raise_error ArgumentError }
211
+ end
212
+
213
+ context '-90' do
214
+ let(:option) { { close: -90 } }
215
+ it { expect { subject }.to raise_error ArgumentError }
216
+ end
217
+
218
+ context '-1' do
219
+ let(:option) { { close: -1 } }
220
+ it { expect { subject }.to raise_error ArgumentError }
221
+ end
222
+
223
+ context '0' do
224
+ let(:option) { { close: 0 } }
225
+ context '@value' do
226
+ it { is_expected.to eq 110 }
227
+ end
228
+ context '#to_code' do
229
+ subject { described_class.new(option).to_code }
230
+ it { is_expected.to eq 'S11A110' }
231
+ end
232
+ end
233
+
234
+ context '40' do
235
+ let(:option) { { close: 40 } }
236
+ context '@value' do
237
+ it { is_expected.to eq 70 }
238
+ end
239
+ context '#to_code' do
240
+ subject { described_class.new(option).to_code }
241
+ it { is_expected.to eq 'S11A070' }
242
+ end
243
+ end
244
+
245
+ context '41' do
246
+ let(:option) { { close: 41 } }
247
+ it { expect { subject }.to raise_error ArgumentError }
248
+ end
249
+
250
+ context '90' do
251
+ let(:option) { { close: 90 } }
252
+ it { expect { subject }.to raise_error ArgumentError }
253
+ end
254
+
255
+ context '180' do
256
+ let(:option) { { close: 180 } }
257
+ it { expect { subject }.to raise_error ArgumentError }
258
+ end
259
+ end
260
+ end
261
+ end
@@ -0,0 +1,256 @@
1
+ require 'spec_helper'
2
+
3
+ RSpec.describe RapiroWrapper::LeftFootYaw do
4
+ context 'constants' do
5
+ context 'NO' do
6
+ subject { described_class.const_get(:NO) }
7
+ it { is_expected.to eq 10 }
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 50 }
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 'S10A090' }
27
+ end
28
+
29
+ context 'with both open and close' do
30
+ subject { described_class.code(option) }
31
+ let(:option) { { open: 0, close: 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 'S10A050' }
56
+ end
57
+
58
+ context '60' do
59
+ let(:option) { { open: 60 } }
60
+ it { is_expected.to eq 'S10A110' }
61
+ end
62
+
63
+ context '61' do
64
+ let(:option) { { open: 61 } }
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 close' do
80
+ subject { described_class.code(option) }
81
+
82
+ context '-180' do
83
+ let(:option) { { close: -180 } }
84
+ it { expect { subject }.to raise_error ArgumentError }
85
+ end
86
+
87
+ context '-90' do
88
+ let(:option) { { close: -90 } }
89
+ it { expect { subject }.to raise_error ArgumentError }
90
+ end
91
+
92
+ context '-1' do
93
+ let(:option) { { close: -1 } }
94
+ it { expect { subject }.to raise_error ArgumentError }
95
+ end
96
+
97
+ context '0' do
98
+ let(:option) { { close: 0 } }
99
+ it { is_expected.to eq 'S10A110' }
100
+ end
101
+
102
+ context '60' do
103
+ let(:option) { { close: 60 } }
104
+ it { is_expected.to eq 'S10A050' }
105
+ end
106
+
107
+ context '61' do
108
+ let(:option) { { close: 61 } }
109
+ it { expect { subject }.to raise_error ArgumentError }
110
+ end
111
+
112
+ context '90' do
113
+ let(:option) { { close: 90 } }
114
+ it { expect { subject }.to raise_error ArgumentError }
115
+ end
116
+
117
+ context '180' do
118
+ let(:option) { { close: 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 'S10A090' }
135
+ end
136
+ end
137
+
138
+ context 'with both open and close' do
139
+ subject { described_class.new(option).instance_variable_get(:@value) }
140
+ let(:option) { { open: 0, close: 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 50 }
166
+ end
167
+ context '#to_code' do
168
+ subject { described_class.new(option).to_code }
169
+ it { is_expected.to eq 'S10A050' }
170
+ end
171
+ end
172
+
173
+ context '60' do
174
+ let(:option) { { open: 60 } }
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 'S10A110' }
181
+ end
182
+ end
183
+
184
+ context '61' do
185
+ let(:option) { { open: 61 } }
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 close' do
201
+ subject { described_class.new(option).instance_variable_get(:@value) }
202
+
203
+ context '-180' do
204
+ let(:option) { { close: -180 } }
205
+ it { expect { subject }.to raise_error ArgumentError }
206
+ end
207
+
208
+ context '-90' do
209
+ let(:option) { { close: -90 } }
210
+ it { expect { subject }.to raise_error ArgumentError }
211
+ end
212
+
213
+ context '-1' do
214
+ let(:option) { { close: -1 } }
215
+ it { expect { subject }.to raise_error ArgumentError }
216
+ end
217
+
218
+ context '0' do
219
+ let(:option) { { close: 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 'S10A110' }
226
+ end
227
+ end
228
+
229
+ context '60' do
230
+ let(:option) { { close: 60 } }
231
+ context '@value' do
232
+ it { is_expected.to eq 50 }
233
+ end
234
+ context '#to_code' do
235
+ subject { described_class.new(option).to_code }
236
+ it { is_expected.to eq 'S10A050' }
237
+ end
238
+ end
239
+
240
+ context '61' do
241
+ let(:option) { { close: 61 } }
242
+ it { expect { subject }.to raise_error ArgumentError }
243
+ end
244
+
245
+ context '90' do
246
+ let(:option) { { close: 90 } }
247
+ it { expect { subject }.to raise_error ArgumentError }
248
+ end
249
+
250
+ context '180' do
251
+ let(:option) { { close: 180 } }
252
+ it { expect { subject }.to raise_error ArgumentError }
253
+ end
254
+ end
255
+ end
256
+ end