Class: Player::Actuator
- Inherits:
-
Object
- Object
- Player::Actuator
- Includes:
- Common
- Defined in:
- lib/ruby-player/actuator.rb
Overview
The actuator of actarray
Instance Attribute Summary collapse
-
#geom ⇒ Object
readonly
Geometry of actuator.
-
#joint ⇒ Integer
readonly
Number in actarray.
-
#state ⇒ Object
readonly
State of actuator.
Instance Method Summary collapse
-
#acceleration ⇒ Float
The acceleration of the actuator in m/s^2 or rad/s^2 depending on the type.
-
#braked? ⇒ Boolean
Check braked state.
-
#current ⇒ Float
The current of the actuator in A.
-
#go_home! ⇒ Actuator
Command to go to home position.
-
#idle? ⇒ Boolean
Check idle state.
-
#initialize(joint, actarray) ⇒ Actuator
constructor
A new instance of Actuator.
-
#moving? ⇒ Boolean
Check moving state.
-
#position ⇒ Float
The position of the actuator in m or rad depending on the type.
- #read_geom(msg) ⇒ Object
- #read_state(msg) ⇒ Object
-
#set_accel_config(accel) ⇒ Actuator
Set accelelarion for a joint for all subsequent movements.
-
#set_current(curr) ⇒ Actuator
Command a joint to attempt to move with the given current.
-
#set_position(pos) ⇒ Actuator
Set position for a joint.
-
#set_speed(speed) ⇒ Actuator
Set speed for a joint.
-
#set_speed_config(speed) ⇒ Actuator
Set speed for a joint for all subsequent movements.
-
#speed ⇒ Float
The speed of the actuator in m/s or rad/s depending on the type.
-
#stalled? ⇒ Boolean
Check braked state.
Constructor Details
#initialize(joint, actarray) ⇒ Actuator
Returns a new instance of Actuator.
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/ruby-player/actuator.rb', line 41 def initialize(joint, actarray) @joint, @actarray = joint, actarray @state = { position: 0.0, speed: 0.0, acceleration: 0.0, current: 0.0, state: 0 } @geom = { type: 0, length: 0.0, proll: 0.0, ppitch: 0.0, pyaw: 0.0, px: 0.0, py: 0.0, pz: 0.0, min: 0.0, centre: 0.0, max: 0.0, home: 0.0, config_speed: 0.0, hasbreaks: 0 } end |
Instance Attribute Details
#geom ⇒ Object (readonly)
Geometry of actuator
39 40 41 |
# File 'lib/ruby-player/actuator.rb', line 39 def geom @geom end |
#joint ⇒ Integer (readonly)
Number in actarray
23 24 25 |
# File 'lib/ruby-player/actuator.rb', line 23 def joint @joint end |
#state ⇒ Object (readonly)
State of actuator
:position - The position of the actuator in m or rad depending on the type.
:speed - The speed of the actuator in m/s or rad/s depending on the type.
:acceleration - The acceleration of the actuator in m/s^2 or rad/s^2 depending on the type.
:current - The current of the actuator in A.
:state - The current state of the actuator. @see #idle?, #moving?, #braked?, #stalled?
36 37 38 |
# File 'lib/ruby-player/actuator.rb', line 36 def state @state end |
Instance Method Details
#acceleration ⇒ Float
The acceleration of the actuator in m/s^2 or rad/s^2 depending on the type.
69 70 71 |
# File 'lib/ruby-player/actuator.rb', line 69 def acceleration state[:acceleration] end |
#braked? ⇒ Boolean
Check braked state
141 142 143 |
# File 'lib/ruby-player/actuator.rb', line 141 def braked? state[:state] & PLAYER_ACTARRAY_ACTSTATE_BRAKED > 0 end |
#current ⇒ Float
The current of the actuator in A.
76 77 78 |
# File 'lib/ruby-player/actuator.rb', line 76 def current state[:current] end |
#go_home! ⇒ Actuator
Command to go to home position
114 115 116 117 |
# File 'lib/ruby-player/actuator.rb', line 114 def go_home! @actarray.(PLAYER_MSGTYPE_CMD, PLAYER_ACTARRAY_CMD_HOME, [@joint].pack("N")) self end |
#idle? ⇒ Boolean
Check idle state
129 130 131 |
# File 'lib/ruby-player/actuator.rb', line 129 def idle? state[:state] & PLAYER_ACTARRAY_ACTSTATE_IDLE > 0 end |
#moving? ⇒ Boolean
Check moving state
135 136 137 |
# File 'lib/ruby-player/actuator.rb', line 135 def moving? state[:state] & PLAYER_ACTARRAY_ACTSTATE_MOVING > 0 end |
#position ⇒ Float
The position of the actuator in m or rad depending on the type.
55 56 57 |
# File 'lib/ruby-player/actuator.rb', line 55 def position state[:position] end |
#read_geom(msg) ⇒ Object
156 157 158 159 |
# File 'lib/ruby-player/actuator.rb', line 156 def read_geom(msg) data = msg.unpack("NgG6g5N") fill_hash!(@geom, data) end |
#read_state(msg) ⇒ Object
151 152 153 154 |
# File 'lib/ruby-player/actuator.rb', line 151 def read_state(msg) data = msg.unpack("g4N") fill_hash!(@state, data) end |
#set_accel_config(accel) ⇒ Actuator
Set accelelarion for a joint for all subsequent movements
91 92 93 94 |
# File 'lib/ruby-player/actuator.rb', line 91 def set_accel_config(accel) @actarray.(PLAYER_MSGTYPE_REQ, PLAYER_ACTARRAY_REQ_ACCEL, [@joint, accel].pack("Ng")) self end |
#set_current(curr) ⇒ Actuator
Command a joint to attempt to move with the given current
122 123 124 125 |
# File 'lib/ruby-player/actuator.rb', line 122 def set_current(curr) @actarray.(PLAYER_MSGTYPE_CMD, PLAYER_ACTARRAY_CMD_CURRENT, [@joint, curr].pack("Ng")) self end |
#set_position(pos) ⇒ Actuator
Set position for a joint
99 100 101 102 |
# File 'lib/ruby-player/actuator.rb', line 99 def set_position(pos) @actarray.(PLAYER_MSGTYPE_CMD, PLAYER_ACTARRAY_CMD_POS, [@joint, pos].pack("Ng")) self end |
#set_speed(speed) ⇒ Actuator
Set speed for a joint
107 108 109 110 |
# File 'lib/ruby-player/actuator.rb', line 107 def set_speed(speed) @actarray.(PLAYER_MSGTYPE_CMD, PLAYER_ACTARRAY_CMD_SPEED, [@joint, speed].pack("Ng")) self end |
#set_speed_config(speed) ⇒ Actuator
Set speed for a joint for all subsequent movements
83 84 85 86 |
# File 'lib/ruby-player/actuator.rb', line 83 def set_speed_config(speed) @actarray.(PLAYER_MSGTYPE_REQ, PLAYER_ACTARRAY_REQ_SPEED, [@joint, speed].pack("Ng")) self end |
#speed ⇒ Float
The speed of the actuator in m/s or rad/s depending on the type.
62 63 64 |
# File 'lib/ruby-player/actuator.rb', line 62 def speed state[:speed] end |
#stalled? ⇒ Boolean
Check braked state
147 148 149 |
# File 'lib/ruby-player/actuator.rb', line 147 def stalled? state[:state] & PLAYER_ACTARRAY_ACTSTATE_STALLED > 0 end |