Skip to content
This repository has been archived by the owner on Feb 29, 2020. It is now read-only.

Commit

Permalink
Browse files Browse the repository at this point in the history
Added #position, #speed, #acceleration and #current attributes for Ac…
…tor class
  • Loading branch information
atimin committed Mar 11, 2012
1 parent 0d22c69 commit 5404b2f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
3 changes: 2 additions & 1 deletion NEWS.md
Expand Up @@ -2,7 +2,8 @@

* Log level by default :notice is removed. Use :info.
* Added ActArray#power? method
* Added #beams and #stored attributes for Gripper
* Added #beams and #stored attributes for Gripper class
* Added #position, #speed, #acceleration and #current attributes for Actor class

## 2012-03-06 0.4.1

Expand Down
28 changes: 28 additions & 0 deletions lib/ruby-player/actuator.rb
Expand Up @@ -49,6 +49,34 @@ def initialize(joint, actarray)
}
end

# The position of the actuator in m or rad depending on the type.
# @see #state
# @return [Float]
def position
state[:position]
end

# The speed of the actuator in m/s or rad/s depending on the type.
# @see #state
# @return [Float]
def speed
state[:speed]
end

# The acceleration of the actuator in m/s^2 or rad/s^2 depending on the type.
# @see #state
# @return [Float]
def acceleration
state[:acceleration]
end

# The current of the actuator in A.
# @see #state
# @return [Float]
def current
state[:current]
end

# Set speed for a joint for all subsequent movements
# @param speed - speed setting in rad/s or m/s
# @return [Actuator] self
Expand Down
20 changes: 20 additions & 0 deletions spec/actuator_spec.rb
Expand Up @@ -28,6 +28,26 @@
)
end

it 'should have #position attr' do
@act.should_receive(:state).and_return(position: 1.2)
@act.position.should eql(1.2)
end

it 'should have #speed attr' do
@act.should_receive(:state).and_return(speed: 1.8)
@act.speed.should eql(1.8)
end

it 'should have #acceleration attr' do
@act.should_receive(:state).and_return(acceleration: 0.2)
@act.acceleration.should eql(0.2)
end

it 'should have #current attr' do
@act.should_receive(:state).and_return(current: 3.2)
@act.current.should eql(3.2)
end

it 'should set speed config ' do
should_send_message(PLAYER_MSGTYPE_REQ, PLAYER_ACTARRAY_REQ_SPEED, [0, 0.2].pack("Ng"))
@act.set_speed_config(0.2)
Expand Down

0 comments on commit 5404b2f

Please sign in to comment.