ruby-nxt 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +340 -0
- data/README +49 -0
- data/examples/commands.rb +180 -0
- data/examples/drb_client.rb +11 -0
- data/examples/drb_server.rb +40 -0
- data/examples/mary.rb +78 -0
- data/examples/move_by_degrees.rb +42 -0
- data/examples/nxt_comm_demo.rb +65 -0
- data/examples/nxt_remote_control.rb +70 -0
- data/examples/socket_server.rb +37 -0
- data/lib/autodetect_nxt.rb +36 -0
- data/lib/brick.rb +53 -0
- data/lib/commands.rb +40 -0
- data/lib/commands/light_sensor.rb +82 -0
- data/lib/commands/mixins/motor.rb +84 -0
- data/lib/commands/mixins/sensor.rb +38 -0
- data/lib/commands/motor.rb +136 -0
- data/lib/commands/move.rb +210 -0
- data/lib/commands/rotation_sensor.rb +72 -0
- data/lib/commands/sound.rb +102 -0
- data/lib/commands/sound_sensor.rb +67 -0
- data/lib/commands/touch_sensor.rb +84 -0
- data/lib/commands/ultrasonic_sensor.rb +84 -0
- data/lib/motor.rb +235 -0
- data/lib/nxt.rb +189 -0
- data/lib/nxt_comm.rb +596 -0
- data/lib/sensors/light_sensor.rb +45 -0
- data/lib/sensors/sensor.rb +93 -0
- data/lib/sensors/sound_sensor.rb +48 -0
- data/lib/sensors/touch_sensor.rb +35 -0
- data/lib/sensors/ultrasonic_sensor.rb +95 -0
- data/lib/ultrasonic_comm.rb +102 -0
- data/test/bt_test.rb +10 -0
- data/test/interactive/interactive_test_helper.rb +89 -0
- data/test/interactive/test_sensors.rb +236 -0
- data/test/test.rb +22 -0
- data/test/test_helper.rb +1 -0
- data/test/unit/motor_test.rb +177 -0
- data/test/unit/nxt_comm_test.rb +155 -0
- data/test/unit/nxt_test.rb +60 -0
- metadata +95 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
require File.dirname(__FILE__) + '/../test_helper'
|
2
|
+
require "test/unit"
|
3
|
+
require "nxt"
|
4
|
+
require "autodetect_nxt"
|
5
|
+
|
6
|
+
class NXTTest < Test::Unit::TestCase
|
7
|
+
|
8
|
+
def setup
|
9
|
+
@nxt = NXT.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def teardown
|
13
|
+
@nxt.disconnect
|
14
|
+
end
|
15
|
+
|
16
|
+
def test_motors_individual
|
17
|
+
@nxt.motor_a do |m|
|
18
|
+
m.reset_tacho
|
19
|
+
m.forward(:degrees => 90, :power => 8)
|
20
|
+
|
21
|
+
# FIXME: 35 is a pretty big margin of error... not sure why but sometimes the tests
|
22
|
+
# come in at over 30... maybe there is a problem with the scheduling of the state poll?
|
23
|
+
# the problem doesn't seem to be as bad when we run motor_test.rb...
|
24
|
+
assert_in_delta(90, m.read_state[:rotation_count], 35)
|
25
|
+
end
|
26
|
+
|
27
|
+
@nxt.motor_b do |m|
|
28
|
+
m.reset_tacho
|
29
|
+
m.forward(:degrees => 90, :power => 8)
|
30
|
+
assert_in_delta(90, m.read_state[:rotation_count], 35)
|
31
|
+
end
|
32
|
+
|
33
|
+
@nxt.motor_c do |m|
|
34
|
+
m.reset_tacho
|
35
|
+
m.forward(:degrees => 90, :power => 8)
|
36
|
+
assert_in_delta(90, m.read_state[:rotation_count], 35)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
# def test_motors_multiple
|
41
|
+
# @nxt.motors_abc do |m|
|
42
|
+
# m.reset_tacho
|
43
|
+
# end
|
44
|
+
#
|
45
|
+
# @nxt.motors_abc do |m|
|
46
|
+
# m.forward(:degrees => 360, :power => 10)
|
47
|
+
# end
|
48
|
+
#
|
49
|
+
# @nxt.motors_abc do |m|
|
50
|
+
# assert_in_delta(360, m.read_state[:rotation_count], 30)
|
51
|
+
# end
|
52
|
+
# end
|
53
|
+
#
|
54
|
+
# def test_sensors
|
55
|
+
# @nxt.sensor_1 do |s|
|
56
|
+
#
|
57
|
+
# end
|
58
|
+
# end
|
59
|
+
|
60
|
+
end
|
metadata
ADDED
@@ -0,0 +1,95 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
rubygems_version: 0.9.0
|
3
|
+
specification_version: 1
|
4
|
+
name: ruby-nxt
|
5
|
+
version: !ruby/object:Gem::Version
|
6
|
+
version: 0.8.1
|
7
|
+
date: 2006-11-03 00:00:00 -05:00
|
8
|
+
summary: Provides a Ruby interface to LEGO Mindstorms NXT
|
9
|
+
require_paths:
|
10
|
+
- lib
|
11
|
+
email: gr0k@rubyforge.org
|
12
|
+
homepage: ruby-nxt.rubyforge.org
|
13
|
+
rubyforge_project: ruby-nxt
|
14
|
+
description:
|
15
|
+
autorequire:
|
16
|
+
default_executable:
|
17
|
+
bindir: bin
|
18
|
+
has_rdoc: true
|
19
|
+
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">"
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: 0.0.0
|
24
|
+
version:
|
25
|
+
platform: ruby
|
26
|
+
signing_key:
|
27
|
+
cert_chain:
|
28
|
+
post_install_message:
|
29
|
+
authors:
|
30
|
+
- Tony Buser
|
31
|
+
files:
|
32
|
+
- test/bt_test.rb
|
33
|
+
- test/interactive
|
34
|
+
- test/test.rb
|
35
|
+
- test/test_helper.rb
|
36
|
+
- test/unit
|
37
|
+
- test/interactive/interactive_test_helper.rb
|
38
|
+
- test/interactive/test_sensors.rb
|
39
|
+
- test/unit/motor_test.rb
|
40
|
+
- test/unit/nxt_comm_test.rb
|
41
|
+
- test/unit/nxt_test.rb
|
42
|
+
- examples/commands.rb
|
43
|
+
- examples/drb_client.rb
|
44
|
+
- examples/drb_server.rb
|
45
|
+
- examples/mary.rb
|
46
|
+
- examples/move_by_degrees.rb
|
47
|
+
- examples/nxt_comm_demo.rb
|
48
|
+
- examples/nxt_remote_control.rb
|
49
|
+
- examples/socket_server.rb
|
50
|
+
- lib/autodetect_nxt.rb
|
51
|
+
- lib/brick.rb
|
52
|
+
- lib/commands
|
53
|
+
- lib/commands.rb
|
54
|
+
- lib/motor.rb
|
55
|
+
- lib/nxt.rb
|
56
|
+
- lib/nxt_comm.rb
|
57
|
+
- lib/sensors
|
58
|
+
- lib/ultrasonic_comm.rb
|
59
|
+
- lib/commands/light_sensor.rb
|
60
|
+
- lib/commands/mixins
|
61
|
+
- lib/commands/motor.rb
|
62
|
+
- lib/commands/move.rb
|
63
|
+
- lib/commands/rotation_sensor.rb
|
64
|
+
- lib/commands/sound.rb
|
65
|
+
- lib/commands/sound_sensor.rb
|
66
|
+
- lib/commands/touch_sensor.rb
|
67
|
+
- lib/commands/ultrasonic_sensor.rb
|
68
|
+
- lib/commands/mixins/motor.rb
|
69
|
+
- lib/commands/mixins/sensor.rb
|
70
|
+
- lib/sensors/light_sensor.rb
|
71
|
+
- lib/sensors/sensor.rb
|
72
|
+
- lib/sensors/sound_sensor.rb
|
73
|
+
- lib/sensors/touch_sensor.rb
|
74
|
+
- lib/sensors/ultrasonic_sensor.rb
|
75
|
+
- README
|
76
|
+
- LICENSE
|
77
|
+
test_files: []
|
78
|
+
|
79
|
+
rdoc_options:
|
80
|
+
- --main
|
81
|
+
- README
|
82
|
+
- --title
|
83
|
+
- "'ruby-nxt RDoc'"
|
84
|
+
- --line-numbers
|
85
|
+
extra_rdoc_files:
|
86
|
+
- README
|
87
|
+
- LICENSE
|
88
|
+
executables: []
|
89
|
+
|
90
|
+
extensions: []
|
91
|
+
|
92
|
+
requirements: []
|
93
|
+
|
94
|
+
dependencies: []
|
95
|
+
|