ruby-player 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/NEWS.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 2012-02-17 0.3.0
2
+
3
+ * Method Position2d::position is renamed to Position2d::state. Position2d::position is deprecated
4
+ * Added gripper interface
5
+
1
6
  ## 2012-02-16 0.2.0
2
7
 
3
8
  * Added power interface
data/README.md CHANGED
@@ -11,6 +11,7 @@ API coverage
11
11
  The list of support objects and devices of Player.
12
12
 
13
13
  * Client object
14
+ * Gripper
14
15
  * Position2d
15
16
  * Power
16
17
  * Ranger
@@ -30,7 +31,7 @@ Example
30
31
  pos2d.set_speed(vx: 1, vy: 0, va: 0.2)
31
32
  #main loop
32
33
  robot.loop do
33
- puts "Position: x=%{px}, y=%{py}, a=%{pa}" % pos2d.position
34
+ puts "Position: x=%{px}, y=%{py}, a=%{pa}" % pos2d.state
34
35
  puts "Rangers: #{ranger.rangers}"
35
36
  end
36
37
  end
@@ -4,7 +4,7 @@ Player::Client.connect("localhost") do |robot|
4
4
  ranger = robot.subscribe(:ranger)
5
5
  #main loop
6
6
  robot.loop(0.05) do
7
- puts "Position: x=%{px}, y=%{py}, a=%{pa}" % pos2d.position
7
+ puts "Position: x=%{px}, y=%{py}, a=%{pa}" % pos2d.state
8
8
  r = ranger.rangers
9
9
  puts "Rangers: #{r}"
10
10
 
@@ -12,7 +12,7 @@ driver
12
12
  driver
13
13
  (
14
14
  name "stage"
15
- provides [ "position2d:0" "ranger:0" ]
15
+ provides [ "position2d:0" "ranger:0" "gripper:0"]
16
16
 
17
17
  model "bender"
18
18
  )
@@ -54,6 +54,11 @@ define bender_ranger ranger
54
54
  )
55
55
  )
56
56
 
57
+ define bender_gripper gripper
58
+ (
59
+ size [0.5 0.5 0.5]
60
+ )
61
+
57
62
  define bender2dx position
58
63
  (
59
64
  color "grey"
@@ -72,6 +77,12 @@ define bender2dx position
72
77
  drive "omni"
73
78
 
74
79
  bender_ranger()
80
+
81
+ bender_gripper
82
+ (
83
+ pose [0.8 0 -0.80 0]
84
+ color "blue"
85
+ )
75
86
  size [1 1 1]
76
87
  )
77
88
 
@@ -81,6 +92,14 @@ carton
81
92
  pose [ 3 0 0 0.0]
82
93
  )
83
94
 
95
+ carton
96
+ (
97
+ name "b1"
98
+ pose [1 1 0 0.0]
99
+ size [0.2 0.2 0.5]
100
+
101
+ )
102
+
84
103
  bender2dx
85
104
  (
86
105
  name "bender"
data/lib/ruby-player.rb CHANGED
@@ -23,6 +23,7 @@ require "ruby-player/device"
23
23
  require "ruby-player/client"
24
24
 
25
25
  #interfaces
26
+ require "ruby-player/gripper"
26
27
  require "ruby-player/position2d"
27
28
  require "ruby-player/power"
28
29
  require "ruby-player/ranger"
@@ -59,8 +59,30 @@ module Player
59
59
  ""
60
60
  end
61
61
 
62
+ def fill_hash!(hash, ary)
63
+ hash.keys.each do |k|
64
+ if ary.empty?
65
+ break
66
+ else
67
+ hash[k] = ary.shift
68
+ end
69
+ end
70
+ end
71
+
62
72
  def unexpected_message(hdr)
63
73
  warn "Get unexpection message type #{hdr.type_name}::#{hdr.subtype_name} for #@addr"
64
74
  end
75
+
76
+ def geom_to_s(geom)
77
+ "px=%.2f, py=%.2f, pz=%.2f, proll=%.2f, ppitch=%.2f, pyaw=%.2f, sw=%.2f, sl=%.2f, sh=%.2f" % geom.values
78
+ end
79
+
80
+ def pose_to_s(pose)
81
+ "px=%.2f, py=%.2f, pz=%.2f, proll=%.2f, ppitch=%.2f, pyaw=%.2f" % pose.values
82
+ end
83
+
84
+ def size_to_s(size)
85
+ "sw=%.2f, sl=%.2f, sh=%.2f" % size.values
86
+ end
65
87
  end
66
88
  end
@@ -0,0 +1,171 @@
1
+ # Ruby Player - Ruby client library for Player (tools for robots)
2
+ #
3
+ # Copyright (C) 2012 Timin Aleksey
4
+ #
5
+ # This program is free software: you can redistribute it and/or modify
6
+ # it under the terms of the GNU General Public License as published by
7
+ # the Free Software Foundation, either version 3 of the License, or
8
+ # (at your option) any later version.
9
+ #
10
+ # This program is distributed in the hope that it will be useful,
11
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
12
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
+ # GNU General Public License for more details.
14
+
15
+ module Player
16
+ # Gripper interface.
17
+ #
18
+ # The gripper interface provides access to a robotic gripper.
19
+ # A gripper is a device capable of closing around and carrying an object
20
+ # of suitable size and shape. On a mobile robot, a gripper is typically mounted near the floor on the front,
21
+ # or on the end of a robotic limb. Grippers typically have two "fingers" that close around an object. i
22
+ # Some grippers can detect whether an objcet is within the gripper (using, for example, light beams).
23
+ # Some grippers also have the ability to move the a carried object into a storage system,
24
+ # freeing the gripper to pick up a new object, and move objects from the storage system back into the gripper.
25
+ class Gripper < Device
26
+ # The gripper interface returns the current state of the gripper
27
+ # and information on a potential object in the gripper.
28
+ #
29
+ # *:state* may be PLAYER_GRIPPER_STATE_OPEN, PLAYER_GRIPPER_STATE_CLOSED,
30
+ # PLAYER_GRIPPER_STATE_MOVING or PLAYER_GRIPPER_STATE_ERROR.
31
+ #
32
+ # *:beams* provides information on how far into the gripper an object is.
33
+ # For most grippers, this will be a bit mask, with each bit representing whether
34
+ # a beam has been interrupted or not.
35
+ #
36
+ # *:stored* - Number of currently stored objects
37
+ #
38
+ # @return [Hash] { :state, :beams, :stored }
39
+ attr_reader :state
40
+
41
+
42
+ # Geometry data of gripper
43
+ #
44
+ # *:pose* - Gripper pose, in robot cs (m, m, m, rad, rad, rad).
45
+ #
46
+ # *:outer_size* - Outside dimensions of gripper (m, m, m).
47
+ #
48
+ # *:inner_size* - Inside dimensions of gripper, i.e.
49
+ #
50
+ # *:number_beams* - Number of breakbeams the gripper has.
51
+ #
52
+ # *:capacity* - Capacity for storing objects - if 0, then the gripper can't store.
53
+ #
54
+ # @return [Hash] { :pose => {:px,:py,:pz,:proll,:ppitch,:pyaw,
55
+ # :outer_size => { :sw, :sl, :sh },
56
+ # :inner_size => { :sw, :sl, :sh },
57
+ # :number_beams, :capacity
58
+ # }
59
+ attr_reader :geom
60
+
61
+ def initialize(addr, client)
62
+ super
63
+ @state = { state: PLAYER_GRIPPER_STATE_OPEN, beams: 0, stored: 0 }
64
+ @geom = {
65
+ pose: { px: 0.0, py: 0.0, pz: 0.0, proll: 0.0, ppitch: 0.0, pyaw: 0.0 },
66
+ outer_size: { sw: 0.0, sl: 0.0, sh: 0.0 },
67
+ inner_size: { sw: 0.0, sl: 0.0, sh: 0.0 },
68
+ number_beams: 0,
69
+ capacity: 0
70
+ }
71
+ end
72
+
73
+ # Query gripper geometry
74
+ # @return self
75
+ def query_geom
76
+ send_message(PLAYER_MSGTYPE_REQ, PLAYER_RANGER_REQ_GET_GEOM)
77
+ self
78
+ end
79
+
80
+ # Check openinig
81
+ def open?
82
+ state[:state] & PLAYER_GRIPPER_STATE_OPEN > 0
83
+ end
84
+
85
+ # Check closing
86
+ def closed?
87
+ state[:state] & PLAYER_GRIPPER_STATE_CLOSED > 0
88
+ end
89
+
90
+ # Check moving
91
+ def moving?
92
+ state[:state] & PLAYER_GRIPPER_STATE_MOVING > 0
93
+ end
94
+
95
+ # Check error
96
+ def error?
97
+ state[:state] & PLAYER_GRIPPER_STATE_ERROR > 0
98
+ end
99
+
100
+ # Tells the gripper to open
101
+ def open!
102
+ send_message(PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_OPEN)
103
+ self
104
+ end
105
+
106
+ # Tells the gripper to close
107
+ def close!
108
+ send_message(PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_CLOSE)
109
+ self
110
+ end
111
+
112
+ # Tells the gripper to stop
113
+ def stop!
114
+ send_message(PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_STOP)
115
+ self
116
+ end
117
+
118
+ # Tells the gripper to store whatever it is holding.
119
+ def store!
120
+ send_message(PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_STORE)
121
+ self
122
+ end
123
+
124
+ # Tells the gripper to retrieve a stored object (so that it can be put back into the world).
125
+ # The opposite of store.
126
+ def retrieve!
127
+ send_message(PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_RETRIEVE)
128
+ self
129
+ end
130
+
131
+ def fill(hdr, msg)
132
+ case hdr.subtype
133
+ when PLAYER_GRIPPER_DATA_STATE
134
+ read_state(msg)
135
+ else
136
+ undexpected_message hdr
137
+ end
138
+ end
139
+
140
+ def handle_response(hdr, msg)
141
+ case hdr.subtype
142
+ when PLAYER_GRIPPER_REQ_GET_GEOM
143
+ read_geom(msg)
144
+ else
145
+ undexpected_message hdr
146
+ end
147
+ end
148
+
149
+ private
150
+ def read_state(msg)
151
+ fill_hash!(@state, msg.unpack("NNN"))
152
+ debug("Get gripper state state=%d, beams=%d, stored=%d" % @state.values)
153
+ end
154
+
155
+ def read_geom(msg)
156
+ data = msg.unpack("G12NN")
157
+ fill_hash!(@geom[:pose], data)
158
+ debug "Get gripper pose: " + pose_to_s(@geom[:pose])
159
+
160
+ fill_hash!(@geom[:outer_size], data)
161
+ debug "Get gripper outer size: " + size_to_s(@geom[:outer_size])
162
+
163
+ fill_hash!(@geom[:inner_size], data)
164
+ debug "Get gripper inner size: " + size_to_s(@geom[:inner_size])
165
+
166
+ @geom[:number_beams] = data.shift
167
+ @geom[:capacity] = data.shift
168
+ debug("Get number_beams=%{number_beams}, capacity=%{capacity}" % @geom)
169
+ end
170
+ end
171
+ end
@@ -24,13 +24,13 @@ module Player
24
24
  # #update data from server
25
25
  # client.read!
26
26
  # #read velocityand position by X,Y and angle
27
- # pos2d.position #=> { :px => 0.2321, :py => 0,01, :pa => 0.2, :vx => 1.2, :vy => 0.1, :va => 0.3, :stall => 1 }
27
+ # pos2d.state #=> { :px => 0.2321, :py => 0,01, :pa => 0.2, :vx => 1.2, :vy => 0.1, :va => 0.3, :stall => 1 }
28
28
  # pos2d.stop!
29
29
  class Position2d < Device
30
30
 
31
31
  # Position of robot
32
32
  # @return [Hash] hash position {:px, :py, :pa, :vx, :vy, :va, :stall }
33
- attr_reader :position
33
+ attr_reader :state
34
34
 
35
35
  # Device geometry
36
36
  # @return [Hash] geometry { :px, :py. :pz, :proll, :ppitch, :pyaw, :sw, :sl, :sh }
@@ -39,10 +39,16 @@ module Player
39
39
 
40
40
  def initialize(addr, client)
41
41
  super
42
- @position = {px: 0.0, py: 0.0, pa: 0.0, vx: 0.0, vy: 0.0, va: 0.0, stall: 0}
42
+ @state = {px: 0.0, py: 0.0, pa: 0.0, vx: 0.0, vy: 0.0, va: 0.0, stall: 0}
43
43
  @geom = {px: 0.0, py: 0.0, pz: 0.0, proll: 0.0, ppitch: 0.0, pyaw: 0.0, sw: 0.0, sl: 0.0, sh: 0.0}
44
44
  end
45
45
 
46
+ # Depricated alias for data
47
+ def position
48
+ warn "Method `position` is deprecated. Pleas use `data` for access to position"
49
+ state
50
+ end
51
+
46
52
  # Query robot geometry
47
53
  # @return self
48
54
  def query_geom
@@ -163,10 +169,10 @@ module Player
163
169
  # @return self
164
170
  def set_speed(speeds)
165
171
  data = [
166
- speeds[:vx] || @position[:vx],
167
- speeds[:vy] || @position[:vy],
168
- speeds[:va] || @position[:va],
169
- speeds[:stall] || @position[:stall]
172
+ speeds[:vx] || @state[:vx],
173
+ speeds[:vy] || @state[:vy],
174
+ speeds[:va] || @state[:va],
175
+ speeds[:stall] || @state[:stall]
170
176
  ]
171
177
  send_message(PLAYER_MSGTYPE_CMD, PLAYER_POSITION2D_CMD_VEL, data.pack("GGGN"))
172
178
  self
@@ -178,8 +184,8 @@ module Player
178
184
  # @option speeds :a turning angle (rad).
179
185
  def set_car(speeds)
180
186
  data = [
181
- speeds[:vx] || @position[:vx],
182
- speeds[:a] || @position[:pa]
187
+ speeds[:vx] || @state[:vx],
188
+ speeds[:a] || @state[:pa]
183
189
  ]
184
190
  send_message(PLAYER_MSGTYPE_CMD, PLAYER_POSITION2D_CMD_CAR, data.pack("GG"))
185
191
  self
@@ -192,8 +198,8 @@ module Player
192
198
  # @option speeds :a absolutle angle (rad).
193
199
  def set_speed_head(speeds)
194
200
  data = [
195
- speeds[:vx] || @position[:vx],
196
- speeds[:a] || @position[:pa]
201
+ speeds[:vx] || @state[:vx],
202
+ speeds[:a] || @state[:pa]
197
203
  ]
198
204
  send_message(PLAYER_MSGTYPE_CMD, PLAYER_POSITION2D_CMD_VEL_HEAD, data.pack("GG"))
199
205
  self
@@ -203,7 +209,7 @@ module Player
203
209
  # State of motor
204
210
  # @return [Boolean] true - on
205
211
  def power
206
- @position[:stall] == 1
212
+ @state[:stall] == 1
207
213
  end
208
214
 
209
215
  # Stop robot set speed to 0
@@ -214,13 +220,13 @@ module Player
214
220
 
215
221
  # Check of robot state
216
222
  def stoped?
217
- speed[:vx] == 0 && speed[:vy] == 0 && speed[:va] == 0
223
+ @state[:vx] == 0 && @state[:vy] == 0 && @state[:va] == 0
218
224
  end
219
225
 
220
226
  def fill(hdr, msg)
221
227
  case hdr.subtype
222
228
  when PLAYER_POSITION2D_DATA_STATE
223
- read_position(msg)
229
+ read_state(msg)
224
230
  when PLAYER_POSITION2D_DATA_GEOM
225
231
  read_geom(msg)
226
232
  else
@@ -240,21 +246,14 @@ module Player
240
246
  end
241
247
 
242
248
  private
243
- def read_position(msg)
244
- data = msg.unpack("GGGGGGN")
245
- @position.keys.each_with_index do |k,i|
246
- @position[k] = data[i]
247
- end
248
- debug("Get position px=%.2f py=%.2f pa=%.2f; vx=%.2f, vy=%.2f, va=%.2f, stall=%d" % position.values)
249
+ def read_state(msg)
250
+ fill_hash!(@state, msg.unpack("GGGGGGN"))
251
+ debug("Get state px=%.2f py=%.2f pa=%.2f; vx=%.2f, vy=%.2f, va=%.2f, stall=%d" % @state.values)
249
252
  end
250
253
 
251
254
  def read_geom(msg)
252
- data = msg.unpack("G*")
253
- [:px,:py,:pz, :proll,:ppitch,:pyaw, :sw,:sl,:sh].each_with_index do |k,i|
254
- @geom[k] = data[i]
255
- end
256
- debug("Get geom px=%.2f py=%.2f pz=%.2f; proll=%.2f, ppitch=%.2f, pyaw=%.2f, sw=%.2f, sl=%.2f, sh=%.2f" % @geom.values)
255
+ fill_hash!(@geom, msg.unpack("G*"))
256
+ debug "Get geom " + geom_to_s(@geom)
257
257
  end
258
-
259
258
  end
260
259
  end
@@ -95,10 +95,7 @@ module Player
95
95
 
96
96
  private
97
97
  def read_state(msg)
98
- data = msg.unpack("NggggN")
99
- @state.keys.each_with_index do |k,i|
100
- @state[k] = data[i]
101
- end
98
+ fill_hash!(@state, msg.unpack("NggggN"))
102
99
  debug("Get power state valid=%x volts=%.2f, percent=%.2f, joules=%.2f; watts=%.2f, charging=%d" % @state.values)
103
100
  end
104
101
  end
@@ -129,22 +129,21 @@ module Player
129
129
  when 2..4
130
130
  nil
131
131
  when PLAYER_RANGER_REQ_GET_CONFIG
132
- data = msg.unpack("G*")
133
- [:min_angle, :max_angle, :angular_res, :min_range, :max_range, :range_res, :frequecy].each_with_index do |k,i|
134
- @config[k] = data[i]
135
- end
132
+ read_config(msg)
136
133
  else
137
134
  unexpected_message hdr
138
135
  end
139
136
  end
140
137
 
141
138
  private
139
+ def read_config(msg)
140
+ fill_hash!(@config, msg.unpack("G*"))
141
+ end
142
+
142
143
  def read_geom(msg)
143
144
  data = msg[0,72].unpack("G*")
144
- [:px,:py,:pz, :proll,:ppitch,:pyaw, :sw,:sl,:sh].each_with_index do |k,i|
145
- @geom[k] = data[i]
146
- end
147
- debug("Get geom px=%.2f py=%.2f pz=%.2f; proll=%.2f, ppitch=%.2f, pyaw=%.2f, sw=%.2f, sl=%.2f, sh=%.2f" % @geom.values)
145
+ fill_hash!(@geom, data)
146
+ debug("Get geom: " + geom_to_s(@geom))
148
147
 
149
148
 
150
149
  p_count = msg[72,8].unpack("NN")
@@ -13,5 +13,5 @@
13
13
  # GNU General Public License for more details.
14
14
 
15
15
  module Player
16
- VERSION = "0.2.0"
16
+ VERSION = "0.3.0"
17
17
  end
@@ -0,0 +1,122 @@
1
+ require File.dirname(__FILE__) + "/spec_helper"
2
+
3
+ include Player
4
+ describe Player::Position2d do
5
+ before do
6
+ client = mock_client
7
+ @gripper = Player::Gripper.new(
8
+ Player::DevAddr.new(host: 0, robot:0, interface: PLAYER_GRIPPER_CODE, index: 0),
9
+ client
10
+ )
11
+
12
+ mock_sending_message(@gripper)
13
+ end
14
+
15
+ it 'should have default values' do
16
+ @gripper.state.should eql(state: PLAYER_GRIPPER_STATE_OPEN, beams: 0, stored: 0)
17
+ @gripper.geom.should eql(pose: { px: 0.0, py: 0.0, pz: 0.0, proll: 0.0, ppitch: 0.0, pyaw: 0.0 },
18
+ outer_size: { sw: 0.0, sl: 0.0, sh: 0.0 },
19
+ inner_size: { sw: 0.0, sl: 0.0, sh: 0.0 },
20
+ number_beams: 0,
21
+ capacity: 0
22
+ )
23
+ end
24
+
25
+ it 'should have open? attribute' do
26
+ @gripper.should_receive(:state).and_return(state: PLAYER_GRIPPER_STATE_OPEN)
27
+ @gripper.open?.should be_true
28
+
29
+ @gripper.should_receive(:state).and_return(state: 0)
30
+ @gripper.open?.should be_false
31
+ end
32
+
33
+ it 'should have closed? attribute' do
34
+ @gripper.should_receive(:state).and_return(state: PLAYER_GRIPPER_STATE_CLOSED)
35
+ @gripper.closed?.should be_true
36
+
37
+ @gripper.should_receive(:state).and_return(state: 0)
38
+ @gripper.closed?.should be_false
39
+ end
40
+
41
+ it 'should have moving? attribute' do
42
+ @gripper.should_receive(:state).and_return(state: PLAYER_GRIPPER_STATE_MOVING)
43
+ @gripper.moving?.should be_true
44
+
45
+ @gripper.should_receive(:state).and_return(state: 0)
46
+ @gripper.moving?.should be_false
47
+ end
48
+
49
+ it 'should have error? attribute' do
50
+ @gripper.should_receive(:state).and_return(state: PLAYER_GRIPPER_STATE_ERROR)
51
+ @gripper.error?.should be_true
52
+
53
+ @gripper.should_receive(:state).and_return(state: 0)
54
+ @gripper.error?.should be_false
55
+ end
56
+
57
+ it 'should open gripper' do
58
+ should_send_message(PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_OPEN)
59
+ @gripper.open!
60
+ end
61
+
62
+ it 'should close gripper' do
63
+ should_send_message(PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_CLOSE)
64
+ @gripper.close!
65
+ end
66
+
67
+ it 'should stop gripper' do
68
+ should_send_message(PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_STOP)
69
+ @gripper.stop!
70
+ end
71
+
72
+ it 'should store whatever it is holding' do
73
+ should_send_message(PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_STORE)
74
+ @gripper.store!
75
+ end
76
+
77
+ it 'should retrieve stored object' do
78
+ should_send_message(PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_RETRIEVE)
79
+ @gripper.retrieve!
80
+ end
81
+
82
+ it 'should query geom' do
83
+ should_send_message(PLAYER_MSGTYPE_REQ, PLAYER_GRIPPER_REQ_GET_GEOM)
84
+ @gripper.query_geom
85
+ end
86
+
87
+ it 'should fill state data' do
88
+ state = { state: PLAYER_GRIPPER_STATE_CLOSED, beams: 3, stored: 4 }
89
+
90
+ msg = state.values.pack("NNN")
91
+ @gripper.fill(
92
+ Player::Header.from_a([0,0,PLAYER_GRIPPER_CODE,0, PLAYER_MSGTYPE_DATA, PLAYER_POWER_DATA_STATE, 0.0, 0, msg.bytesize]),
93
+ msg
94
+ )
95
+ @gripper.state.should eql(state)
96
+ end
97
+
98
+ it 'should get geom by request' do
99
+ geom = { pose: { px: 1.0, py: 2.0, pz: 3.0, proll: 4.0, ppitch: 5.0, pyaw: 6.0 },
100
+ outer_size: { sw: 7.0, sl: 8.0, sh: 9.0 },
101
+ inner_size: { sw: 10.0, sl: 11.0, sh: 12.0 },
102
+ number_beams: 13,
103
+ capacity: 14
104
+ }
105
+
106
+ msg = geom[:pose].values.pack("G*") + geom[:outer_size].values.pack("G*") + geom[:inner_size].values.pack("G*")
107
+ msg << [geom[:number_beams], geom[:capacity]].pack("NN")
108
+ @gripper.handle_response(
109
+ Player::Header.from_a([0,0,4,0, PLAYER_MSGTYPE_RESP_ACK, PLAYER_GRIPPER_REQ_GET_GEOM, 0.0, 0, msg.bytesize]),
110
+ msg
111
+ )
112
+ @gripper.geom.should eql(geom)
113
+ end
114
+
115
+ it 'should not puts warn message for ACK subtypes 1' do
116
+ @gripper.should_not_receive(:unexpected_message)
117
+ @gripper.stub!(:read_geom)
118
+ @gripper.handle_response(
119
+ Player::Header.from_a([0,0,PLAYER_GRIPPER_CODE,0, PLAYER_MSGTYPE_RESP_ACK, PLAYER_GRIPPER_REQ_GET_GEOM, 0.0, 0, 0]),
120
+ "")
121
+ end
122
+ end
@@ -13,7 +13,7 @@ describe Player::Position2d do
13
13
  end
14
14
 
15
15
  it 'should have default values' do
16
- @pos2d.position.should eql(px:0.0, py:0.0, pa:0.0, vx:0.0, vy:0.0, va:0.0, stall: 0)
16
+ @pos2d.state.should eql(px:0.0, py:0.0, pa:0.0, vx:0.0, vy:0.0, va:0.0, stall: 0)
17
17
  @pos2d.geom.should eql(px:0.0, py:0.0, pz:0.0, proll:0.0, ppitch:0.0, pyaw:0.0, sw:0.0, sl:0.0, sh:0.0)
18
18
  end
19
19
 
@@ -82,7 +82,7 @@ describe Player::Position2d do
82
82
  Player::Header.from_a([0,0,4,0, PLAYER_MSGTYPE_DATA, PLAYER_POSITION2D_DATA_STATE, 0.0, 0, 52]),
83
83
  pos.values.pack("GGGGGGN")
84
84
  )
85
- @pos2d.position.should eql(pos)
85
+ @pos2d.state.should eql(pos)
86
86
  end
87
87
 
88
88
  it 'should fill geom data' do
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby-player
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -13,7 +13,7 @@ date: 2012-02-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: isna
16
- requirement: &12972860 !ruby/object:Gem::Requirement
16
+ requirement: &18940320 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 0.0.4
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *12972860
24
+ version_requirements: *18940320
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &12972000 !ruby/object:Gem::Requirement
27
+ requirement: &18939820 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ~>
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '2.7'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *12972000
35
+ version_requirements: *18939820
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &12971460 !ruby/object:Gem::Requirement
38
+ requirement: &18939180 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ~>
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0.9'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *12971460
46
+ version_requirements: *18939180
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: pry
49
- requirement: &12970860 !ruby/object:Gem::Requirement
49
+ requirement: &18938680 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *12970860
57
+ version_requirements: *18938680
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: yard
60
- requirement: &12970220 !ruby/object:Gem::Requirement
60
+ requirement: &18938080 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *12970220
68
+ version_requirements: *18938080
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: redcarpet
71
- requirement: &12969640 !ruby/object:Gem::Requirement
71
+ requirement: &18937400 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *12969640
79
+ version_requirements: *18937400
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: guard-rspec
82
- requirement: &12968920 !ruby/object:Gem::Requirement
82
+ requirement: &18936740 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,7 +87,7 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *12968920
90
+ version_requirements: *18936740
91
91
  description: Ruby Player - Ruby client library for Player (tools for robots)
92
92
  email:
93
93
  - atimin@gmail.com
@@ -113,6 +113,7 @@ files:
113
113
  - lib/ruby-player/constants.rb
114
114
  - lib/ruby-player/dev_addr.rb
115
115
  - lib/ruby-player/device.rb
116
+ - lib/ruby-player/gripper.rb
116
117
  - lib/ruby-player/header.rb
117
118
  - lib/ruby-player/position2d.rb
118
119
  - lib/ruby-player/power.rb
@@ -120,6 +121,7 @@ files:
120
121
  - lib/ruby-player/version.rb
121
122
  - ruby-player.gemspec
122
123
  - spec/client_spec.rb
124
+ - spec/gripper_spec.rb
123
125
  - spec/position2d_spec.rb
124
126
  - spec/power_spec.rb
125
127
  - spec/ranger_spec.rb