class RapiroWrapper::Command

Command class for RAPIRO

Public Class Methods

new(sequences = []) click to toggle source
# File lib/rapiro_wrapper/command.rb, line 4
def initialize(sequences = [])
  @sequences = sequences
end

Public Instance Methods

to_sequence(duration = 10) click to toggle source
# File lib/rapiro_wrapper/command.rb, line 8
def to_sequence(duration = 10)
  targets = RapiroWrapper::ServoMotor.find_servos + [RapiroWrapper::Eyes]
  seq = targets.inject([]) do |ary, servo|
    s = @sequences.find { |item| item.instance_of?(servo) }
    ary << (s ? s : servo.new)
    ary
  end

  format("#P#{seq.map(&:to_code).join}T%03d", duration)
end