Class: Player::Gripper

Inherits:
Device
  • Object
show all
Defined in:
lib/ruby-player/gripper.rb

Overview

Gripper interface.

The gripper interface provides access to a robotic gripper. A gripper is a device capable of closing around and carrying an object of suitable size and shape. On a mobile robot, a gripper is typically mounted near the floor on the front, or on the end of a robotic limb. Grippers typically have two “fingers” that close around an object. i Some grippers can detect whether an objcet is within the gripper (using, for example, light beams). Some grippers also have the ability to move the a carried object into a storage system, freeing the gripper to pick up a new object, and move objects from the storage system back into the gripper.

Instance Attribute Summary collapse

Attributes inherited from Device

#addr

Instance Method Summary collapse

Methods inherited from Device

#send_message

Constructor Details

#initialize(addr, client) ⇒ Gripper

Returns a new instance of Gripper.



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/ruby-player/gripper.rb', line 61

def initialize(addr, client)
  super
  @state = { state: PLAYER_GRIPPER_STATE_OPEN, beams: 0, stored: 0 }
  @geom = {
    pose: { px: 0.0, py: 0.0, pz: 0.0, proll: 0.0, ppitch: 0.0, pyaw: 0.0 },
    outer_size: { sw: 0.0, sl: 0.0, sh: 0.0 },
    inner_size: { sw: 0.0, sl: 0.0, sh: 0.0 },
    number_beams: 0,
    capacity: 0
  }
end

Instance Attribute Details

#geomHash (readonly)

Geometry data of gripper

:pose - Gripper pose, in robot cs (m, m, m, rad, rad, rad).

:outer_size - Outside dimensions of gripper (m, m, m).

:inner_size - Inside dimensions of gripper, i.e.

:number_beams - Number of breakbeams the gripper has.

:capacity - Capacity for storing objects - if 0, then the gripper can’t store.

Returns:

  • (Hash)

    { :pose => {:px,:py,:pz,:proll,:ppitch,:pyaw, :outer_size => { :sw, :sl, :sh }, :inner_size => { :sw, :sl, :sh }, :number_beams, :capacity }



59
60
61
# File 'lib/ruby-player/gripper.rb', line 59

def geom
  @geom
end

#stateHash (readonly)

The gripper interface returns the current state of the gripper and information on a potential object in the gripper.

:state may be PLAYER_GRIPPER_STATE_OPEN, PLAYER_GRIPPER_STATE_CLOSED, PLAYER_GRIPPER_STATE_MOVING or PLAYER_GRIPPER_STATE_ERROR.

:beams provides information on how far into the gripper an object is. For most grippers, this will be a bit mask, with each bit representing whether a beam has been interrupted or not.

:stored - Number of currently stored objects

Returns:

  • (Hash)

    { :state, :beams, :stored }



39
40
41
# File 'lib/ruby-player/gripper.rb', line 39

def state
  @state
end

Instance Method Details

#beamsObject

Provides information on how far into the gripper an object is. For most grippers, this will be a bit mask, with each bit representing whether a beam has been interrupted or not.

See Also:



85
86
87
# File 'lib/ruby-player/gripper.rb', line 85

def beams
  state[:beams]
end

#close!Gripper

Tells the gripper to close

Returns:



125
126
127
128
# File 'lib/ruby-player/gripper.rb', line 125

def close!
  send_message(PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_CLOSE)
  self
end

#closed?Boolean

Check closing

Returns:

  • (Boolean)


102
103
104
# File 'lib/ruby-player/gripper.rb', line 102

def closed?
  state[:state] & PLAYER_GRIPPER_STATE_CLOSED > 0
end

#error?Boolean

Check error

Returns:

  • (Boolean)


112
113
114
# File 'lib/ruby-player/gripper.rb', line 112

def error?
  state[:state] & PLAYER_GRIPPER_STATE_ERROR > 0
end

#fill(hdr, msg) ⇒ Object



152
153
154
155
156
157
158
159
# File 'lib/ruby-player/gripper.rb', line 152

def fill(hdr, msg)
  case hdr.subtype
  when PLAYER_GRIPPER_DATA_STATE
    read_state(msg)
  else
    undexpected_message hdr
  end
end

#handle_response(hdr, msg) ⇒ Object



161
162
163
164
165
166
167
168
# File 'lib/ruby-player/gripper.rb', line 161

def handle_response(hdr, msg)
  case hdr.subtype
  when PLAYER_GRIPPER_REQ_GET_GEOM
    read_geom(msg)
  else
    undexpected_message hdr
  end
end

#moving?Boolean

Check moving

Returns:

  • (Boolean)


107
108
109
# File 'lib/ruby-player/gripper.rb', line 107

def moving?
  state[:state] & PLAYER_GRIPPER_STATE_MOVING > 0
end

#open!Gripper

Tells the gripper to open

Returns:



118
119
120
121
# File 'lib/ruby-player/gripper.rb', line 118

def open!
  send_message(PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_OPEN)
  self
end

#open?Boolean

Check openinig

Returns:

  • (Boolean)


97
98
99
# File 'lib/ruby-player/gripper.rb', line 97

def open?
  state[:state] & PLAYER_GRIPPER_STATE_OPEN > 0
end

#query_geomObject

Query gripper geometry

Returns:

  • self



75
76
77
78
# File 'lib/ruby-player/gripper.rb', line 75

def query_geom
  send_message(PLAYER_MSGTYPE_REQ, PLAYER_RANGER_REQ_GET_GEOM)
  self
end

#retrieve!Gripper

Tells the gripper to retrieve a stored object (so that it can be put back into the world). The opposite of store.

Returns:



147
148
149
150
# File 'lib/ruby-player/gripper.rb', line 147

def retrieve!
  send_message(PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_RETRIEVE)
  self
end

#stop!Gripper

Tells the gripper to stop

Returns:



132
133
134
135
# File 'lib/ruby-player/gripper.rb', line 132

def stop!
  send_message(PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_STOP)
  self
end

#store!Gripper

Tells the gripper to store whatever it is holding.

Returns:



139
140
141
142
# File 'lib/ruby-player/gripper.rb', line 139

def store!
  send_message(PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_STORE)
  self
end

#storedObject

Number of currently stored objects

See Also:



92
93
94
# File 'lib/ruby-player/gripper.rb', line 92

def stored
  state[:stored]
end