Class: Player::ActArray
- Includes:
- Enumerable
- Defined in:
- lib/ruby-player/actarray.rb
Overview
The actuator array interface provides access to an array of actuators.
Instance Attribute Summary collapse
-
#geom ⇒ Object
readonly
Geometry of base actarray.
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Attributes inherited from Device
Instance Method Summary collapse
-
#[](joint) ⇒ Actuator
Get single actuator.
-
#brakes_off! ⇒ ActArray
Turn off brakes all actuators.
-
#brakes_on! ⇒ ActArray
Turn on brakes all actuators.
- #each ⇒ Object
- #fill(hdr, msg) ⇒ Object
-
#go_home! ⇒ ActArray
Command to go to home position for all joints.
- #handle_response(hdr, msg) ⇒ Object
-
#initialize(dev, client) ⇒ ActArray
constructor
A new instance of ActArray.
-
#power? ⇒ Boolean
Check common power.
-
#power_off! ⇒ ActArray
Turn off power all actuators Be careful when turning power on that the array is not obstructed from its home position in case it moves to it (common behaviour).
-
#power_on! ⇒ ActArray
Turn on power all actuators Be careful when turning power on that the array is not obstructed from its home position in case it moves to it (common behaviour).
-
#query_geom ⇒ ActArray
Query actarray geometry.
-
#set_current_all(curr) ⇒ ActArray
Command all joints to attempt to move with the given current.
-
#set_currents(currents) ⇒ ActArray
Tells all joints/actuators to attempt to move with the given current.
-
#set_positions(poses) ⇒ ActArray
Tells all joints/actuators to attempt to move to the given positions.
-
#set_speeds(speeds) ⇒ ActArray
Tells all joints/actuators to attempt to move with the given speed.
Methods inherited from Device
Constructor Details
#initialize(dev, client) ⇒ ActArray
Returns a new instance of ActArray.
25 26 27 28 29 30 |
# File 'lib/ruby-player/actarray.rb', line 25 def initialize(dev, client) super @actuators = [] @state = { motor_state: 0 } @geom = { px: 0.0, py: 0.0, pz: 0.0, proll: 0.0, ppitch: 0.0, pyaw: 0.0 } end |
Instance Attribute Details
#geom ⇒ Object (readonly)
Geometry of base actarray
23 24 25 |
# File 'lib/ruby-player/actarray.rb', line 23 def geom @geom end |
#state ⇒ Object (readonly)
Returns the value of attribute state.
20 21 22 |
# File 'lib/ruby-player/actarray.rb', line 20 def state @state end |
Instance Method Details
#[](joint) ⇒ Actuator
Get single actuator
80 81 82 |
# File 'lib/ruby-player/actarray.rb', line 80 def [](joint) @actuators[joint] ||= Actuator.new(joint, self) end |
#brakes_off! ⇒ ActArray
Turn off brakes all actuators
65 66 67 68 |
# File 'lib/ruby-player/actarray.rb', line 65 def brakes_off! (PLAYER_MSGTYPE_REQ, PLAYER_ACTARRAY_REQ_BRAKES, [0].pack("N")) self end |
#brakes_on! ⇒ ActArray
Turn on brakes all actuators
58 59 60 61 |
# File 'lib/ruby-player/actarray.rb', line 58 def brakes_on! (PLAYER_MSGTYPE_REQ, PLAYER_ACTARRAY_REQ_BRAKES, [1].pack("N")) self end |
#each ⇒ Object
132 133 134 |
# File 'lib/ruby-player/actarray.rb', line 132 def each @actuators.each { |a| yield a } end |
#fill(hdr, msg) ⇒ Object
136 137 138 139 140 141 142 143 |
# File 'lib/ruby-player/actarray.rb', line 136 def fill(hdr, msg) case hdr.subtype when PLAYER_ACTARRAY_DATA_STATE read_state(msg) else hdr end end |
#go_home! ⇒ ActArray
Command to go to home position for all joints
108 109 110 111 |
# File 'lib/ruby-player/actarray.rb', line 108 def go_home! (PLAYER_MSGTYPE_CMD, PLAYER_ACTARRAY_CMD_HOME, [-1].pack("N")) self end |
#handle_response(hdr, msg) ⇒ Object
145 146 147 148 149 150 151 152 |
# File 'lib/ruby-player/actarray.rb', line 145 def handle_response(hdr, msg) case hdr.subtype when PLAYER_ACTARRAY_REQ_GET_GEOM read_geom(msg) else hdr end end |
#power? ⇒ Boolean
Check common power
34 35 36 |
# File 'lib/ruby-player/actarray.rb', line 34 def power? state[:motor_state] != 0 end |
#power_off! ⇒ ActArray
Turn off power all actuators Be careful when turning power on that the array is not obstructed from its home position in case it moves to it (common behaviour)
51 52 53 54 |
# File 'lib/ruby-player/actarray.rb', line 51 def power_off! (PLAYER_MSGTYPE_REQ, PLAYER_ACTARRAY_REQ_POWER, [0].pack("N")) self end |
#power_on! ⇒ ActArray
Turn on power all actuators Be careful when turning power on that the array is not obstructed from its home position in case it moves to it (common behaviour)
42 43 44 45 |
# File 'lib/ruby-player/actarray.rb', line 42 def power_on! (PLAYER_MSGTYPE_REQ, PLAYER_ACTARRAY_REQ_POWER, [1].pack("N")) self end |
#query_geom ⇒ ActArray
Query actarray geometry
72 73 74 75 |
# File 'lib/ruby-player/actarray.rb', line 72 def query_geom (PLAYER_MSGTYPE_REQ, PLAYER_ACTARRAY_REQ_GET_GEOM) self end |
#set_current_all(curr) ⇒ ActArray
Command all joints to attempt to move with the given current
116 117 118 119 |
# File 'lib/ruby-player/actarray.rb', line 116 def set_current_all(curr) (PLAYER_MSGTYPE_CMD, PLAYER_ACTARRAY_CMD_CURRENT, [-1, curr].pack("Ng")) self end |
#set_currents(currents) ⇒ ActArray
Tells all joints/actuators to attempt to move with the given current.
124 125 126 127 128 129 130 |
# File 'lib/ruby-player/actarray.rb', line 124 def set_currents(currents) ( PLAYER_MSGTYPE_CMD, PLAYER_ACTARRAY_CMD_MULTI_CURRENT, ([currents.size] + currents).pack("Ng*") ) self end |
#set_positions(poses) ⇒ ActArray
Tells all joints/actuators to attempt to move to the given positions.
87 88 89 90 91 92 93 |
# File 'lib/ruby-player/actarray.rb', line 87 def set_positions(poses) ( PLAYER_MSGTYPE_CMD, PLAYER_ACTARRAY_CMD_MULTI_POS, ([poses.size] + poses).pack("Ng*") ) self end |
#set_speeds(speeds) ⇒ ActArray
Tells all joints/actuators to attempt to move with the given speed.
98 99 100 101 102 103 104 |
# File 'lib/ruby-player/actarray.rb', line 98 def set_speeds(speeds) ( PLAYER_MSGTYPE_CMD, PLAYER_ACTARRAY_CMD_MULTI_SPEED, ([speeds.size] + speeds).pack("Ng*") ) self end |