smalruby 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of smalruby might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65341fb6a0f46746184553d0f6d7ff608fa7b450
4
- data.tar.gz: 429d4cf04d55b187666deb6d4349cd9e950a6f5b
3
+ metadata.gz: ce2d379edb87ad0adc98158e75fa25fe84112568
4
+ data.tar.gz: 69798c03f6d893f0ebc99e432371e060e408bb61
5
5
  SHA512:
6
- metadata.gz: b9b402fb9aa30840ee2393e345222e2b68a4e0aa6ac64dd90e85b01226483c5cb9c41c0526cb2f4e97b2e0485a1b2ca19eeac9a4cd61f9545b551fa8a2add365
7
- data.tar.gz: 1135cdd801f17c8e9314f3df0813f8d6715bb7d1918e5c7d42b6e752d6b94f82e70221c7c6fdc3ad059c5a3494917a9c74f81a9c56bac620d9cfb49551afb00b
6
+ metadata.gz: d6d65b04552500c11eb6a5a0d03346b4f9847538c46fae2458edd45c68f9c93e3d3e64ae880e2d791df7f21a77308a93f6b978e2b5e523753d6833c483c886eb
7
+ data.tar.gz: 7cd9dd7d633e4cf716827778fc8a143e3bf1327fd04cf771884206a35ff6ec4a691a2b74471377c8c819bd19a4c05f0147efb96ed3760c4e78d6b342d5edb63b
@@ -7,8 +7,8 @@ module Smalruby
7
7
  class SmalrubotS1
8
8
  include Smalrubot::Board::Studuino
9
9
 
10
- # default dc motor pace ratio
11
- DEFAULT_DC_MOTOR_PACE_RATIO = 50
10
+ # default dc motor power ratio
11
+ DEFAULT_DC_MOTOR_POWER_RATIO = 50
12
12
 
13
13
  def initialize(_)
14
14
  world.board.init_dc_motor_port(PORT_M1, 0)
@@ -20,26 +20,26 @@ module Smalruby
20
20
  world.board.init_sensor_port(PORT_A4, PIDIRPHOTOREFLECTOR)
21
21
  world.board.init_sensor_port(PORT_A5, PIDIRPHOTOREFLECTOR)
22
22
 
23
- @dc_motor_pace_ratios = {
24
- PORT_M1 => DEFAULT_DC_MOTOR_PACE_RATIO,
25
- PORT_M2 => DEFAULT_DC_MOTOR_PACE_RATIO,
23
+ @dc_motor_power_ratios = {
24
+ PORT_M1 => DEFAULT_DC_MOTOR_POWER_RATIO,
25
+ PORT_M2 => DEFAULT_DC_MOTOR_POWER_RATIO,
26
26
  }
27
27
  end
28
28
 
29
- def left_dc_motor_pace_ratio
30
- @dc_motor_pace_ratios[PORT_M1]
29
+ def left_dc_motor_power_ratio
30
+ @dc_motor_power_ratios[PORT_M1]
31
31
  end
32
32
 
33
- def left_dc_motor_pace_ratio=(val)
34
- set_dc_motor_pace_ratio(PORT_M1, val)
33
+ def left_dc_motor_power_ratio=(val)
34
+ set_dc_motor_power_ratio(PORT_M1, val)
35
35
  end
36
36
 
37
- def right_dc_motor_pace_ratio
38
- @dc_motor_pace_ratios[PORT_M2]
37
+ def right_dc_motor_power_ratio
38
+ @dc_motor_power_ratios[PORT_M2]
39
39
  end
40
40
 
41
- def right_dc_motor_pace_ratio=(val)
42
- set_dc_motor_pace_ratio(PORT_M2, val)
41
+ def right_dc_motor_power_ratio=(val)
42
+ set_dc_motor_power_ratio(PORT_M2, val)
43
43
  end
44
44
 
45
45
  # @!method forward(sec: nil)
@@ -102,25 +102,25 @@ module Smalruby
102
102
 
103
103
  private
104
104
 
105
- def set_dc_motor_pace_ratio(port, val)
105
+ def set_dc_motor_power_ratio(port, val)
106
106
  if val < 0
107
- @dc_motor_pace_ratios[port] = 0
107
+ @dc_motor_power_ratios[port] = 0
108
108
  elsif val > 100
109
- @dc_motor_pace_ratios[port] = 100
109
+ @dc_motor_power_ratios[port] = 100
110
110
  else
111
- @dc_motor_pace_ratios[port] = val
111
+ @dc_motor_power_ratios[port] = val
112
112
  end
113
113
  set_dc_motor_power(port)
114
114
  end
115
115
 
116
116
  def set_dc_motor_power(port)
117
- ratio = @dc_motor_pace_ratios[port]
117
+ ratio = @dc_motor_power_ratios[port]
118
118
  power = Smalrubot::Board::HIGH * (ratio.to_f / 100)
119
119
  world.board.dc_motor_power(port, power.round)
120
120
  end
121
121
 
122
122
  def set_dc_motor_powers
123
- @dc_motor_pace_ratios.keys.each do |port|
123
+ @dc_motor_power_ratios.keys.each do |port|
124
124
  set_dc_motor_power(port)
125
125
  end
126
126
  end
@@ -60,19 +60,19 @@ module Smalruby
60
60
  @current_motor_direction = :stop
61
61
  end
62
62
 
63
- def left_dc_motor_pace_ratio
63
+ def left_dc_motor_power_ratio
64
64
  @left_motor.speed
65
65
  end
66
66
 
67
- def left_dc_motor_pace_ratio=(val)
67
+ def left_dc_motor_power_ratio=(val)
68
68
  @left_motor.speed = val
69
69
  end
70
70
 
71
- def right_dc_motor_pace_ratio
71
+ def right_dc_motor_power_ratio
72
72
  @right_motor.speed
73
73
  end
74
74
 
75
- def right_dc_motor_pace_ratio=(val)
75
+ def right_dc_motor_power_ratio=(val)
76
76
  @right_motor.speed = val
77
77
  end
78
78
 
@@ -1,5 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  module Smalruby
4
- VERSION = '0.1.5'
4
+ VERSION = '0.1.6'
5
5
  end
@@ -0,0 +1,214 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ def setup_smalrubot(stage1, smalrubot)
4
+ stage1.on(:start) do
5
+ fill(color: 'white')
6
+ draw_font(string: DESCRIPTION, color: 'black')
7
+
8
+ smalrubot.left_dc_motor_power_ratio = 100
9
+ smalrubot.right_dc_motor_power_ratio = 100
10
+
11
+ loop do
12
+ if Input.key_down?(K_UP)
13
+ fill(color: 'white')
14
+ draw_font(string: '進む', color: 'black')
15
+
16
+ smalrubot.forward
17
+
18
+ await until !Input.key_down?(K_UP)
19
+
20
+ fill(color: 'white')
21
+
22
+ smalrubot.stop
23
+ end
24
+
25
+ if Input.key_down?(K_DOWN)
26
+ fill(color: 'white')
27
+ draw_font(string: 'バックする', color: 'black')
28
+
29
+ smalrubot.backward
30
+
31
+ await until !Input.key_down?(K_DOWN)
32
+
33
+ fill(color: 'white')
34
+
35
+ smalrubot.stop
36
+ end
37
+
38
+ if Input.key_down?(K_LEFT)
39
+ fill(color: 'white')
40
+ draw_font(string: '左に旋回する', color: 'black')
41
+
42
+ smalrubot.turn_left
43
+
44
+ await until !Input.key_down?(K_LEFT)
45
+
46
+ fill(color: 'white')
47
+
48
+ smalrubot.stop
49
+ end
50
+
51
+ if Input.key_down?(K_RIGHT)
52
+ fill(color: 'white')
53
+ draw_font(string: '右に旋回する', color: 'black')
54
+
55
+ smalrubot.turn_right
56
+
57
+ await until !Input.key_down?(K_RIGHT)
58
+
59
+ fill(color: 'white')
60
+
61
+ smalrubot.stop
62
+ end
63
+
64
+ if Input.key_down?(K_W) || Input.key_down?(K_S)
65
+ if Input.key_down?(K_W)
66
+ smalrubot.left_dc_motor_power_ratio += 10
67
+ else
68
+ smalrubot.left_dc_motor_power_ratio -= 10
69
+ end
70
+
71
+ fill(color: 'white')
72
+ draw_font(string: "左の速度: #{smalrubot.left_dc_motor_power_ratio}%",
73
+ color: 'black')
74
+ end
75
+
76
+ if Input.key_down?(K_O) || Input.key_down?(K_L)
77
+ if Input.key_down?(K_O)
78
+ smalrubot.right_dc_motor_power_ratio += 10
79
+ else
80
+ smalrubot.right_dc_motor_power_ratio -= 10
81
+ end
82
+
83
+ fill(color: 'white')
84
+ draw_font(string: "右の速度: #{smalrubot.right_dc_motor_power_ratio}%",
85
+ color: 'black')
86
+ end
87
+
88
+ if Input.key_down?(K_SPACE)
89
+ fill(color: 'white')
90
+ draw_font(string: '右のLEDを光らせる', color: 'black')
91
+
92
+ smalrubot.turn_on_right_led
93
+
94
+ sleep(1)
95
+
96
+ smalrubot.turn_off_right_led
97
+
98
+ fill(color: 'white')
99
+ draw_font(string: '左のLEDを光らせる', color: 'black')
100
+
101
+ smalrubot.turn_on_left_led
102
+
103
+ sleep(1)
104
+
105
+ smalrubot.turn_off_left_led
106
+
107
+ fill(color: 'white')
108
+ end
109
+
110
+ if Input.key_down?(K_H)
111
+ until !Input.key_down?(K_H)
112
+ fill(color: 'white')
113
+ msg = 'センサーの情報: ' +
114
+ "左 #{smalrubot.left_sensor_value} " +
115
+ "右 #{smalrubot.right_sensor_value}"
116
+ draw_font(string: msg, color: 'black')
117
+ await
118
+ end
119
+ fill(color: 'white')
120
+ end
121
+ end
122
+ end
123
+
124
+ stage1.on(:key_push, K_A) do
125
+ threshold = 400
126
+
127
+ loop do
128
+ fill(color: 'white')
129
+ draw_font(string: '自動運転', color: 'black')
130
+
131
+ left_sensor = smalrubot.left_sensor_value < threshold
132
+ right_sensor = smalrubot.right_sensor_value < threshold
133
+
134
+ if !left_sensor && !right_sensor
135
+ smalrubot.forward
136
+ end
137
+
138
+ loop do
139
+ if left_sensor || right_sensor
140
+ if left_sensor && right_sensor
141
+ fill(color: 'white')
142
+ draw_font(string: '前方障害物発見!', color: 'black')
143
+
144
+ smalrubot.backward
145
+
146
+ loop do
147
+ left_sensor = smalrubot.left_sensor_value < threshold
148
+ right_sensor = smalrubot.right_sensor_value < threshold
149
+ if !left_sensor && !right_sensor
150
+ smalrubot.stop
151
+ break
152
+ end
153
+ end
154
+
155
+ if rand(2) == 1
156
+ smalrubot.turn_left(sec: 0.1)
157
+ else
158
+ smalrubot.turn_right(sec: 0.1)
159
+ end
160
+ else
161
+ if right_sensor
162
+ fill(color: 'white')
163
+ draw_font(string: '右側障害物発見!', color: 'black')
164
+
165
+ #smalrubot.backward(sec: 0.1)
166
+ smalrubot.turn_left
167
+
168
+ loop do
169
+ left_sensor = smalrubot.left_sensor_value < threshold
170
+ right_sensor = smalrubot.right_sensor_value < threshold
171
+ if !left_sensor && !right_sensor
172
+ smalrubot.stop
173
+ break
174
+ end
175
+ end
176
+ else
177
+ if left_sensor
178
+ fill(color: 'white')
179
+ draw_font(string: '左側障害物発見!', color: 'black')
180
+
181
+ #smalrubot.backward(sec: 0.1)
182
+ smalrubot.turn_right
183
+
184
+ loop do
185
+ left_sensor = smalrubot.left_sensor_value < threshold
186
+ right_sensor = smalrubot.right_sensor_value < threshold
187
+ if !left_sensor && !right_sensor
188
+ smalrubot.stop
189
+ break
190
+ end
191
+ end
192
+ end
193
+ end
194
+ end
195
+ break
196
+ end
197
+
198
+ if Input.key_down?(K_Y)
199
+ fill(color: 'white')
200
+ break
201
+ end
202
+
203
+ left_sensor = smalrubot.left_sensor_value < threshold
204
+ right_sensor = smalrubot.right_sensor_value < threshold
205
+ end
206
+
207
+ if Input.key_down?(K_Y)
208
+ fill(color: 'white')
209
+ smalrubot.stop
210
+ break
211
+ end
212
+ end
213
+ end
214
+ end
@@ -1,181 +1,14 @@
1
1
  # -*- coding: utf-8 -*-
2
2
 
3
3
  DESCRIPTION = <<EOS
4
- Smalrubot on Studuino v1を操作します
4
+ スモウルボットS1を操作します
5
5
  EOS
6
6
 
7
7
  require 'smalruby'
8
+ require_relative 'check_hardware_smalrubot'
8
9
 
9
10
  init_hardware(device: ENV['SMALRUBOT_DEVICE'],
10
11
  baud: ENV['SMALRUBOT_BAUD'] ? ENV['SMALRUBOT_BAUD'].to_i : nil)
11
12
 
12
13
  stage1 = Stage.new(color: 'white')
13
-
14
- stage1.on(:start) do
15
- fill(color: 'white')
16
- draw_font(string: DESCRIPTION, color: 'black')
17
-
18
- smalrubot_s1.left_dc_motor_pace_ratio = 100
19
- smalrubot_s1.right_dc_motor_pace_ratio = 100
20
-
21
- loop do
22
- if Input.key_down?(K_UP)
23
- fill(color: 'white')
24
- draw_font(string: '進む', color: 'black')
25
-
26
- smalrubot_s1.forward
27
-
28
- await until !Input.key_down?(K_UP)
29
-
30
- [75, 50, 25].each do |ratio|
31
- smalrubot_s1.left_dc_motor_pace_ratio = ratio
32
- smalrubot_s1.right_dc_motor_pace_ratio = ratio
33
- sleep(0.1)
34
- end
35
-
36
- fill(color: 'white')
37
-
38
- smalrubot_s1.left_dc_motor_pace_ratio = 100
39
- smalrubot_s1.right_dc_motor_pace_ratio = 100
40
-
41
- smalrubot_s1.stop
42
- end
43
-
44
- if Input.key_down?(K_DOWN)
45
- fill(color: 'white')
46
- draw_font(string: 'バックする', color: 'black')
47
-
48
- smalrubot_s1.backward
49
-
50
- await until !Input.key_down?(K_DOWN)
51
-
52
- fill(color: 'white')
53
-
54
- smalrubot_s1.stop
55
- end
56
-
57
- if Input.key_down?(K_LEFT)
58
- fill(color: 'white')
59
- draw_font(string: '左に旋回する', color: 'black')
60
-
61
- smalrubot_s1.turn_left
62
-
63
- await until !Input.key_down?(K_LEFT)
64
-
65
- fill(color: 'white')
66
-
67
- smalrubot_s1.stop
68
- end
69
-
70
- if Input.key_down?(K_RIGHT)
71
- fill(color: 'white')
72
- draw_font(string: '右に旋回する', color: 'black')
73
-
74
- smalrubot_s1.turn_right
75
-
76
- await until !Input.key_down?(K_RIGHT)
77
-
78
- fill(color: 'white')
79
-
80
- smalrubot_s1.stop
81
- end
82
-
83
- if Input.key_down?(K_S)
84
- until !Input.key_down?(K_S)
85
- fill(color: 'white')
86
- draw_font(string: "ライントレーサーの情報: 左(#{smalrubot_s1.left_ir_photoreflector_value}) 右(#{smalrubot_s1.right_ir_photoreflector_value})",
87
- color: 'black')
88
- await
89
- end
90
-
91
- fill(color: 'white')
92
- end
93
-
94
- if Input.key_down?(K_W)
95
- fill(color: 'white')
96
- draw_font(string: '右のLEDを光らせる', color: 'black')
97
-
98
- smalrubot_s1.turn_on_right_led
99
-
100
- await until !Input.key_down?(K_W)
101
-
102
- fill(color: 'white')
103
-
104
- smalrubot_s1.turn_off_right_led
105
- end
106
-
107
- if Input.key_down?(K_B)
108
- fill(color: 'white')
109
- draw_font(string: '左のLEDを光らせる', color: 'black')
110
-
111
- smalrubot_s1.turn_on_left_led
112
-
113
- await until !Input.key_down?(K_B)
114
-
115
- smalrubot_s1.turn_off_left_led
116
-
117
- fill(color: 'white')
118
- end
119
- end
120
- end
121
-
122
- stage1.on(:key_push, K_A) do
123
- loop do
124
- fill(color: 'white')
125
- draw_font(string: '自動運転', color: 'black')
126
-
127
- smalrubot_s1.forward
128
-
129
- loop do
130
- if smalrubot_s1.left_ir_photoreflector_value < 300 && smalrubot_s1.right_ir_photoreflector_value < 300
131
- fill(color: 'white')
132
- draw_font(string: '前方障害物発見!', color: 'black')
133
-
134
- smalrubot_s1.backward
135
- sleep(0.25)
136
- if rand(2) == 1
137
- smalrubot_s1.turn_left
138
- sleep(0.1)
139
- else
140
- smalrubot_s1.turn_right
141
- sleep(0.1)
142
- end
143
- break
144
- end
145
-
146
- if smalrubot_s1.left_ir_photoreflector_value < 300
147
- fill(color: 'white')
148
- draw_font(string: '左側障害物発見!', color: 'black')
149
-
150
- smalrubot_s1.backward
151
- sleep(0.25)
152
- smalrubot_s1.turn_right
153
- sleep(0.1)
154
- break
155
- end
156
-
157
- if smalrubot_s1.right_ir_photoreflector_value < 300
158
- fill(color: 'white')
159
- draw_font(string: '右側障害物発見!', color: 'black')
160
-
161
- smalrubot_s1.backward
162
- sleep(0.25)
163
- smalrubot_s1.turn_left
164
- sleep(0.1)
165
- break
166
- end
167
-
168
- if Input.key_down?(K_Y)
169
- fill(color: 'white')
170
- break
171
- end
172
- end
173
- smalrubot_s1.stop
174
- sleep(0.1)
175
-
176
- if Input.key_down?(K_Y)
177
- fill(color: 'white')
178
- break
179
- end
180
- end
181
- end
14
+ setup_smalrubot(stage1, stage1.smalrubot_s1)
@@ -5,217 +5,10 @@ DESCRIPTION = <<EOS
5
5
  EOS
6
6
 
7
7
  require 'smalruby'
8
+ require_relative 'check_hardware_smalrubot'
8
9
 
9
10
  init_hardware(device: ENV['SMALRUBOT_DEVICE'],
10
11
  baud: ENV['SMALRUBOT_BAUD'] ? ENV['SMALRUBOT_BAUD'].to_i : nil)
11
12
 
12
13
  stage1 = Stage.new(color: 'white')
13
- stage1.smalrubot_v3
14
-
15
- stage1.on(:start) do
16
- fill(color: 'white')
17
- draw_font(string: DESCRIPTION, color: 'black')
18
-
19
- loop do
20
- if Input.key_down?(K_UP)
21
- fill(color: 'white')
22
- draw_font(string: '進む', color: 'black')
23
-
24
- smalrubot_v3.forward
25
-
26
- await until !Input.key_down?(K_UP)
27
-
28
- fill(color: 'white')
29
-
30
- smalrubot_v3.stop
31
- end
32
-
33
- if Input.key_down?(K_DOWN)
34
- fill(color: 'white')
35
- draw_font(string: 'バックする', color: 'black')
36
-
37
- smalrubot_v3.backward
38
-
39
- await until !Input.key_down?(K_DOWN)
40
-
41
- fill(color: 'white')
42
-
43
- smalrubot_v3.stop
44
- end
45
-
46
- if Input.key_down?(K_LEFT)
47
- fill(color: 'white')
48
- draw_font(string: '左に旋回する', color: 'black')
49
-
50
- smalrubot_v3.turn_left
51
-
52
- await until !Input.key_down?(K_LEFT)
53
-
54
- fill(color: 'white')
55
-
56
- smalrubot_v3.stop
57
- end
58
-
59
- if Input.key_down?(K_RIGHT)
60
- fill(color: 'white')
61
- draw_font(string: '右に旋回する', color: 'black')
62
-
63
- smalrubot_v3.turn_right
64
-
65
- await until !Input.key_down?(K_RIGHT)
66
-
67
- fill(color: 'white')
68
-
69
- smalrubot_v3.stop
70
- end
71
-
72
- if Input.key_down?(K_W) || Input.key_down?(K_S)
73
- if Input.key_down?(K_W)
74
- smalrubot_v3.left_dc_motor_pace_ratio += 10
75
- else
76
- smalrubot_v3.left_dc_motor_pace_ratio -= 10
77
- end
78
-
79
- fill(color: 'white')
80
- draw_font(string: "左の速度: #{smalrubot_v3.left_dc_motor_pace_ratio}%",
81
- color: 'black')
82
- end
83
-
84
- if Input.key_down?(K_O) || Input.key_down?(K_L)
85
- if Input.key_down?(K_O)
86
- smalrubot_v3.right_dc_motor_pace_ratio += 10
87
- else
88
- smalrubot_v3.right_dc_motor_pace_ratio -= 10
89
- end
90
-
91
- fill(color: 'white')
92
- draw_font(string: "右の速度: #{smalrubot_v3.right_dc_motor_pace_ratio}%",
93
- color: 'black')
94
- end
95
-
96
- if Input.key_down?(K_SPACE)
97
- fill(color: 'white')
98
- draw_font(string: '右のLEDを光らせる', color: 'black')
99
-
100
- smalrubot_v3.turn_on_right_led
101
-
102
- sleep(1)
103
-
104
- smalrubot_v3.turn_off_right_led
105
-
106
- fill(color: 'white')
107
- draw_font(string: '左のLEDを光らせる', color: 'black')
108
-
109
- smalrubot_v3.turn_on_left_led
110
-
111
- sleep(1)
112
-
113
- smalrubot_v3.turn_off_left_led
114
-
115
- fill(color: 'white')
116
- end
117
-
118
- if Input.key_down?(K_H)
119
- until !Input.key_down?(K_H)
120
- fill(color: 'white')
121
- msg = 'センサーの情報: ' +
122
- "左 #{smalrubot_v3.left_sensor_value} " +
123
- "右 #{smalrubot_v3.right_sensor_value}"
124
- draw_font(string: msg, color: 'black')
125
- await
126
- end
127
- fill(color: 'white')
128
- end
129
- end
130
- end
131
-
132
- THRESHOLD = 400
133
-
134
- stage1.on(:key_push, K_A) do
135
- loop do
136
- fill(color: 'white')
137
- draw_font(string: '自動運転', color: 'black')
138
-
139
- left_sensor = smalrubot_v3.left_sensor_value < THRESHOLD
140
- right_sensor = smalrubot_v3.right_sensor_value < THRESHOLD
141
-
142
- if !left_sensor && !right_sensor
143
- smalrubot_v3.forward
144
- end
145
-
146
- loop do
147
- if left_sensor || right_sensor
148
- if left_sensor && right_sensor
149
- fill(color: 'white')
150
- draw_font(string: '前方障害物発見!', color: 'black')
151
-
152
- smalrubot_v3.backward
153
-
154
- loop do
155
- left_sensor = smalrubot_v3.left_sensor_value < THRESHOLD
156
- right_sensor = smalrubot_v3.right_sensor_value < THRESHOLD
157
- if !left_sensor && !right_sensor
158
- smalrubot_v3.stop
159
- break
160
- end
161
- end
162
-
163
- if rand(2) == 1
164
- smalrubot_v3.turn_left(sec: 0.1)
165
- else
166
- smalrubot_v3.turn_right(sec: 0.1)
167
- end
168
- else
169
- if right_sensor
170
- fill(color: 'white')
171
- draw_font(string: '右側障害物発見!', color: 'black')
172
-
173
- #smalrubot_v3.backward(sec: 0.1)
174
- smalrubot_v3.turn_left
175
-
176
- loop do
177
- left_sensor = smalrubot_v3.left_sensor_value < THRESHOLD
178
- right_sensor = smalrubot_v3.right_sensor_value < THRESHOLD
179
- if !left_sensor && !right_sensor
180
- smalrubot_v3.stop
181
- break
182
- end
183
- end
184
- else
185
- if left_sensor
186
- fill(color: 'white')
187
- draw_font(string: '左側障害物発見!', color: 'black')
188
-
189
- #smalrubot_v3.backward(sec: 0.1)
190
- smalrubot_v3.turn_right
191
-
192
- loop do
193
- left_sensor = smalrubot_v3.left_sensor_value < THRESHOLD
194
- right_sensor = smalrubot_v3.right_sensor_value < THRESHOLD
195
- if !left_sensor && !right_sensor
196
- smalrubot_v3.stop
197
- break
198
- end
199
- end
200
- end
201
- end
202
- end
203
- break
204
- end
205
-
206
- if Input.key_down?(K_Y)
207
- fill(color: 'white')
208
- break
209
- end
210
-
211
- left_sensor = smalrubot_v3.left_sensor_value < THRESHOLD
212
- right_sensor = smalrubot_v3.right_sensor_value < THRESHOLD
213
- end
214
-
215
- if Input.key_down?(K_Y)
216
- fill(color: 'white')
217
- smalrubot_v3.stop
218
- break
219
- end
220
- end
221
- end
14
+ setup_smalrubot(stage1, stage1.smalrubot_v3)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: smalruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kouji Takao
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-15 00:00:00.000000000 Z
11
+ date: 2015-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -278,6 +278,7 @@ files:
278
278
  - samples/car.rb
279
279
  - samples/cat.rb
280
280
  - samples/check_hardware_motor_driver.rb
281
+ - samples/check_hardware_smalrubot.rb
281
282
  - samples/check_hardware_smalrubot_s1.rb
282
283
  - samples/check_hardware_smalrubot_v3.rb
283
284
  - samples/console.rb