Class: Player::Gripper
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
-
#geom ⇒ Hash
readonly
Geometry data of gripper.
-
#state ⇒ Hash
readonly
The gripper interface returns the current state of the gripper and information on a potential object in the gripper.
Attributes inherited from Device
Instance Method Summary collapse
-
#beams ⇒ Object
Provides information on how far into the gripper an object is.
-
#close! ⇒ Gripper
Tells the gripper to close.
-
#closed? ⇒ Boolean
Check closing.
-
#error? ⇒ Boolean
Check error.
- #fill(hdr, msg) ⇒ Object
- #handle_response(hdr, msg) ⇒ Object
-
#initialize(addr, client) ⇒ Gripper
constructor
A new instance of Gripper.
-
#moving? ⇒ Boolean
Check moving.
-
#open! ⇒ Gripper
Tells the gripper to open.
-
#open? ⇒ Boolean
Check openinig.
-
#query_geom ⇒ Object
Query gripper geometry.
-
#retrieve! ⇒ Gripper
Tells the gripper to retrieve a stored object (so that it can be put back into the world).
-
#stop! ⇒ Gripper
Tells the gripper to stop.
-
#store! ⇒ Gripper
Tells the gripper to store whatever it is holding.
-
#stored ⇒ Object
Number of currently stored objects.
Methods inherited from Device
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
#geom ⇒ Hash (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.
59 60 61 |
# File 'lib/ruby-player/gripper.rb', line 59 def geom @geom end |
#state ⇒ Hash (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
39 40 41 |
# File 'lib/ruby-player/gripper.rb', line 39 def state @state end |
Instance Method Details
#beams ⇒ Object
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.
85 86 87 |
# File 'lib/ruby-player/gripper.rb', line 85 def beams state[:beams] end |
#close! ⇒ Gripper
Tells the gripper to close
125 126 127 128 |
# File 'lib/ruby-player/gripper.rb', line 125 def close! (PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_CLOSE) self end |
#closed? ⇒ Boolean
Check closing
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
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 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 hdr end end |
#moving? ⇒ Boolean
Check moving
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
118 119 120 121 |
# File 'lib/ruby-player/gripper.rb', line 118 def open! (PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_OPEN) self end |
#open? ⇒ Boolean
Check openinig
97 98 99 |
# File 'lib/ruby-player/gripper.rb', line 97 def open? state[:state] & PLAYER_GRIPPER_STATE_OPEN > 0 end |
#query_geom ⇒ Object
Query gripper geometry
75 76 77 78 |
# File 'lib/ruby-player/gripper.rb', line 75 def query_geom (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.
147 148 149 150 |
# File 'lib/ruby-player/gripper.rb', line 147 def retrieve! (PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_RETRIEVE) self end |
#stop! ⇒ Gripper
Tells the gripper to stop
132 133 134 135 |
# File 'lib/ruby-player/gripper.rb', line 132 def stop! (PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_STOP) self end |
#store! ⇒ Gripper
Tells the gripper to store whatever it is holding.
139 140 141 142 |
# File 'lib/ruby-player/gripper.rb', line 139 def store! (PLAYER_MSGTYPE_CMD, PLAYER_GRIPPER_CMD_STORE) self end |
#stored ⇒ Object
Number of currently stored objects
92 93 94 |
# File 'lib/ruby-player/gripper.rb', line 92 def stored state[:stored] end |