require 'relay_board'
require 'ezservo'
require 'rover_utils'
require 'acm'
require 'control_system'

include LogHelper
#number of seconds to sleep before starting script
drop_sleep = 10
#drop_sleep = 16800
#number of seconds to sleep between moves
move_sleep = 10
#number of seconds to sleep between sequences of moves
#sequence_sleep = 600
sequence_sleep = 30

syslog "sleeping #{drop_sleep} seconds"
sleep drop_sleep

rb = RelayBoard.new nil, "/dev/relay"
rb.turn_on 0
sleep 1
ez = Ezservo.mini_rover
velocity = 500
ez.velocity = velocity
ez.log_moves = true
acm = Acm.new nil, "/dev/acm"
acm.run
cs = ControlSystem.new ez, acm

1.upto(2) do |count|
  syslog "beginning sequence #{count}"
  syslog "moving 2000 counts"
  ez.forward 2000
  velocity += 500
  ez.velocity = velocity
  sleep sequence_sleep
end

syslog "calibrating control system"
rb.turn_off 0
