adjusting for changes in skynet protocol

pull/2/head
TimEvWw 2014-03-04 20:33:42 -01:00
parent 550cda8675
commit 64aeedc9b9
9 changed files with 168 additions and 241 deletions

View File

@ -15,15 +15,15 @@ class Controller
def runFarmBot def runFarmBot
check = @bot_dbaccess.checkRefresh check = @bot_dbaccess.check_refresh
while $shutdown == 0 do while $shutdown == 0 do
# keep checking the database for new data # keep checking the database for new data
puts 'checking schedule' puts 'checking schedule'
command = @bot_dbaccess.getCommandToExecute command = @bot_dbaccess.get_command_to_execute
@bot_dbaccess.saveRefresh @bot_dbaccess.save_refresh
if command != nil if command != nil
@ -38,7 +38,7 @@ class Controller
puts 'execute command' puts 'execute command'
process_command( command ) process_command( command )
@bot_dbaccess.setCommandToExecuteStatus('FINISHED') @bot_dbaccess.set_command_to_execute_status('FINISHED')
else else
@ -55,7 +55,7 @@ class Controller
sleep 1 sleep 1
refresh_received = @bot_dbaccess.checkRefresh refresh_received = @bot_dbaccess.check_refresh
puts 'refresh received' if refresh_received != false puts 'refresh received' if refresh_received != false
end end
@ -76,7 +76,7 @@ class Controller
sleep 1 sleep 1
refresh_received = @bot_dbaccess.checkRefresh refresh_received = @bot_dbaccess.check_refresh
puts 'refresh received' if refresh_received != false puts 'refresh received' if refresh_received != false
end end
@ -90,17 +90,17 @@ class Controller
cmd.commandlines.each do |command_line| cmd.commandlines.each do |command_line|
case command_line.action.upcase case command_line.action.upcase
when "MOVE ABSOLUTE" when "MOVE ABSOLUTE"
$bot_hardware.moveAbsolute(command_line.coord_x, command_line.coord_y, command_line.coord_z) $bot_hardware.move_absolute(command_line.coord_x, command_line.coord_y, command_line.coord_z)
when "MOVE RELATIVE" when "MOVE RELATIVE"
$bot_hardware.moveRelative(command_line.coord_x, command_line.coord_y, command_line.coord_z) $bot_hardware.move_relative(command_line.coord_x, command_line.coord_y, command_line.coord_z)
when "HOME X" when "HOME X"
$bot_hardware.moveHomeX $bot_hardware.move_home_x
when "HOME Y" when "HOME Y"
$bot_hardware.moveHomeY $bot_hardware.move_home_y
when "HOME Z" when "HOME Z"
$bot_hardware.moveHomeZ $bot_hardware.move_home_z
when "SET SPEED" when "SET SPEED"
$bot_hardware.setSpeed(command_line.speed) $bot_hardware.set_speed(command_line.speed)
end end
end end
else else

View File

@ -1,81 +0,0 @@
require 'bson'
require 'mongo'
require 'mongoid'
require './app/models/command.rb'
# This class is dedicated to retrieving and inserting commands into the command
# queue for the farm bot
class CommandQueue
def initialize
Mongoid.load!("config/mongo.yml", :development)
@last_command_retrieved = nil
@refresh_value = 0
@refresh_value_new = 0
@new_command = nil
end
def create_new_command(scheduled_time)
@new_command = Command.new
@new_command.scheduled_time = scheduled_time
end
def add_command_line(action, x = 0, y = 0, z = 0, speed = 0, amount = 0)
if @new_command != nil
line = Commandline.new
line.action = action
line.coord_x = x
line.coord_y = y
line.coord_z = z
line.speed = speed
line.amount = amount
if @new_command.commandlines == nil
@new_command.commandlines = [ line ]
else
@new_command.commandlines << line
end
end
end
def save_new_command
if @new_command != nil
@new_command.status = 'test'
@new_command.save
end
increment_refresh
end
def get_command_to_execute
@last_command_retrieved = Command.where(
:status => 'test',
:scheduled_time.ne => nil
).order_by([:scheduled_time,:asc]).first
@last_command_retrieved
end
def set_command_to_execute_status(new_status)
if @last_command_retrieved != nil
@last_command_retrieved.status = new_status
@last_command_retrieved.save
end
end
def check_refresh
r = Refresh.where(:name => 'FarmBotControllerSchedule').first_or_initialize
@refresh_value_new = r.value.to_i
return @refresh_value_new != @refresh_value
end
def save_refresh
@refresh_value = @refresh_value_new
end
def increment_refresh
r = Refresh.where(:name => 'FarmBotControllerSchedule').first_or_initialize
r.value = r.value.to_i + 1
r.save
end
end

View File

@ -1,25 +0,0 @@
# command message class that is put into the queue to execute by the farmbot
class ControlCommand
def initialize
commandid = "NOP"
end
attr_accessor :lines, :commandid
end
class ControlCommandLine
attr_accessor :action
attr_accessor :xCoord, :xHome
attr_accessor :yCoord, :yHome
attr_accessor :zCoord, :zHome
attr_accessor :quantity, :speed
def parseText( text )
params = text.split(',')
@action = params[0].to_s
@xCoord = params[1].to_i
@yCoord = params[2].to_i
@zCoord = params[3].to_i
end
end

View File

@ -6,6 +6,7 @@ require 'mongoid'
# This class is dedicated to retrieving and inserting commands into the schedule # This class is dedicated to retrieving and inserting commands into the schedule
# queue for the farm bot Mongo is used as the database, Mongoid as the # queue for the farm bot Mongo is used as the database, Mongoid as the
# databasemapper # databasemapper
class Command class Command
include Mongoid::Document include Mongoid::Document
@ -65,12 +66,12 @@ class DbAccess
end end
end end
def createNewCommand(scheduled_time) def create_new_command(scheduled_time)
@new_command = Command.new @new_command = Command.new
@new_command.scheduled_time = scheduled_time @new_command.scheduled_time = scheduled_time
end end
def addCommandLine(action, x = 0, y = 0, z = 0, speed = 0, amount = 0) def add_command_line(action, x = 0, y = 0, z = 0, speed = 0, amount = 0)
if @new_command != nil if @new_command != nil
line = Commandline.new line = Commandline.new
line.action = action line.action = action
@ -87,15 +88,15 @@ class DbAccess
end end
end end
def saveNewCommand def save_new_command
if @new_command != nil if @new_command != nil
@new_command.status = 'test' @new_command.status = 'test'
@new_command.save @new_command.save
end end
incrementRefresh increment_refresh
end end
def getCommandToExecute def get_command_to_execute
@last_command_retrieved = Command.where( @last_command_retrieved = Command.where(
:status => 'test', :status => 'test',
:scheduled_time.ne => nil :scheduled_time.ne => nil
@ -103,24 +104,24 @@ class DbAccess
@last_command_retrieved @last_command_retrieved
end end
def setCommandToExecuteStatus(new_status) def set_command_to_execute_status(new_status)
if @last_command_retrieved != nil if @last_command_retrieved != nil
@last_command_retrieved.status = new_status @last_command_retrieved.status = new_status
@last_command_retrieved.save @last_command_retrieved.save
end end
end end
def checkRefresh def check_refresh
r = Refresh.where(:name => 'FarmBotControllerSchedule').first_or_initialize r = Refresh.where(:name => 'FarmBotControllerSchedule').first_or_initialize
@refresh_value_new = r.value.to_i @refresh_value_new = r.value.to_i
return @refresh_value_new != @refresh_value return @refresh_value_new != @refresh_value
end end
def saveRefresh def save_refresh
@refresh_value = @refresh_value_new @refresh_value = @refresh_value_new
end end
def incrementRefresh def increment_refresh
r = Refresh.where(:name => 'FarmBotControllerSchedule').first_or_initialize r = Refresh.where(:name => 'FarmBotControllerSchedule').first_or_initialize
r.value = r.value.to_i + 1 r.value = r.value.to_i + 1
r.save r.save

View File

@ -18,7 +18,7 @@ class HardwareInterfaceAxis
# set the pins for one motor with sensors # set the pins for one motor with sensors
# #
def setPinMode() def set_pin_mode()
# set the pins for motor control to output # set the pins for motor control to output
@board.set_pin_mode(pin_enb, Firmata::Board::OUTPUT) @board.set_pin_mode(pin_enb, Firmata::Board::OUTPUT)
@ -38,45 +38,45 @@ class HardwareInterfaceAxis
end end
def disableMotor() def disable_motor()
@board.digital_write(@pin_enb, Firmata::Board::HIGH) @board.digital_write(@pin_enb, Firmata::Board::HIGH)
end end
def enableMotor() def enable_motor()
@board.digital_write(@pin_enb, Firmata::Board::LOW) @board.digital_write(@pin_enb, Firmata::Board::LOW)
end end
def setDirectionLow() def set_direction_low()
@board.digital_write(pin_dir, Firmata::Board::LOW) @board.digital_write(pin_dir, Firmata::Board::LOW)
sleep @sleep_after_pin_set sleep @sleep_after_pin_set
enableMotor() enable_motor()
end end
def setDirectionHigh() def set_direction_high()
@board.digital_write(pin_dir, Firmata::Board::HIGH) @board.digital_write(pin_dir, Firmata::Board::HIGH)
sleep @sleep_after_pin_set sleep @sleep_after_pin_set
enableMotor() enable_motor()
end end
# set the direction and enable pins to prepare for the move to the home position # set the direction and enable pins to prepare for the move to the home position
# #
def moveHomeSetDirection() def move_home_set_direction()
if (invert_axis ^ reverse_home) == false if (invert_axis ^ reverse_home) == false
setDirectionLow() set_direction_low()
else else
setDirectionHigh() set_direction_high()
end end
end end
# move the motor until the end stop is reached # move the motor until the end stop is reached
# #
def moveHome() def move_home()
moveHomeSetDirection() move_home_set_direction()
start = Time.now start = Time.now
home = 0 home = 0
@ -90,23 +90,27 @@ class HardwareInterfaceAxis
if span > @move_home_timeout if span > @move_home_timeout
home = 1 home = 1
puts 'move home #{@name} timed out' puts "move home #{@name} timed out"
end end
if (@board.pins[@pin_min].value == 1 and @reverse_home == false) or if @board.pins[@pin_min].value == 1 and @reverse_home == false
(@board.pins[@pin_max].value == 1 and @reverse_home == true )
home = 1 home = 1
puts 'end stop home #{@name} reached' puts "end stop home min #{@name} reached"
end
if @board.pins[@pin_max].value == 1 and @reverse_home == true
home = 1
puts "end stop home max #{@name} reached"
end end
if home == 0 if home == 0
setPulseOnPin(@pin_stp) set_pulse_on_pin(@pin_stp)
end end
end end
# disable motor driver # disable motor driver
disableMotor() disable_motor()
@pos = 0 @pos = 0
@ -114,7 +118,7 @@ class HardwareInterfaceAxis
# set a pulse on a pin with enough sleep time so firmata kan keep up # set a pulse on a pin with enough sleep time so firmata kan keep up
# #
def setPulseOnPin(pin) def set_pulse_on_pin(pin)
@board.digital_write(pin, Firmata::Board::HIGH) @board.digital_write(pin, Firmata::Board::HIGH)
sleep @sleep_after_pin_set sleep @sleep_after_pin_set
@board.digital_write(pin, Firmata::Board::LOW) @board.digital_write(pin, Firmata::Board::LOW)
@ -124,17 +128,17 @@ class HardwareInterfaceAxis
# prepare the move by setting the direction and enable # prepare the move by setting the direction and enable
# #
def moveStepsPrepare(steps) def move_steps_prepare(steps)
@steps = steps @steps = steps
@nr_steps = steps.abs @nr_steps = steps.abs
if (@steps < 0 and @invert_axis == false) or (@steps > 0 and @invert_axis == true) if (@steps < 0 and @invert_axis == false) or (@steps > 0 and @invert_axis == true)
setDirectionLow() set_direction_low()
end end
if (@steps > 0 and @invert_axis == false) or (@steps < 0 and @invert_axis == true) if (@steps > 0 and @invert_axis == false) or (@steps < 0 and @invert_axis == true)
setDirectionHigh() set_direction_high()
end end
end end
@ -142,16 +146,20 @@ class HardwareInterfaceAxis
# move one motor a step if needed, while checking the end stops # move one motor a step if needed, while checking the end stops
# #
def moveSteps() def move_steps()
# check end stops # check end stops
if (@board.pins[@pin_min].value == 1 and @steps < 0) or if @board.pins[@pin_min].value == 1 and @steps < 0
(@board.pins[@pin_max].value == 1 and @steps > 0)
@nr_steps = 0 @nr_steps = 0
@pos = @min if @steps < 0 @pos = @min
@pos = @max if @steps > 0 puts "end stop min #{@name} reached"
puts "end stop #{@name} reached" end
if @board.pins[@pin_max].value == 1 and @steps > 0
@nr_steps = 0
@pos = @max
puts "end stop max #{@name} reached"
end end
# check minimum and maximum position # check minimum and maximum position
@ -164,7 +172,7 @@ class HardwareInterfaceAxis
# send the step pulses to the motor drivers # send the step pulses to the motor drivers
if @nr_steps > 0 if @nr_steps > 0
setPulseOnPin(@pin_stp) set_pulse_on_pin(@pin_stp)
@pos += 1.0 / @steps_per_unit * (@steps<=>0.0) @pos += 1.0 / @steps_per_unit * (@steps<=>0.0)
@nr_steps -= 1 @nr_steps -= 1
@ -189,16 +197,16 @@ class HardwareInterface
@axis_z = HardwareInterfaceAxis.new @axis_z = HardwareInterfaceAxis.new
loadConfig() load_config()
connectBoard() connect_board()
setPinNumbers() set_pin_numbers()
setBoardPinMode() set_board_pin_mode()
end end
# set the hardware pin numbers # set the hardware pin numbers
# #
def setPinNumbers def set_pin_numbers
@pin_led = 13 @pin_led = 13
@ -227,7 +235,7 @@ class HardwareInterface
# connect to the serial port and start communicating with the arduino/firmata protocol # connect to the serial port and start communicating with the arduino/firmata protocol
# #
def connectBoard def connect_board
@boardDevice = "/dev/ttyACM0" @boardDevice = "/dev/ttyACM0"
@board = Firmata::Board.new @boardDevice @board = Firmata::Board.new @boardDevice
@ -241,7 +249,7 @@ class HardwareInterface
# load the settings for the hardware # load the settings for the hardware
# these are the timeouts and distance settings mainly # these are the timeouts and distance settings mainly
def loadConfig def load_config
@axis_x.move_home_timeout = 15 # seconds after which home command is aborted @axis_x.move_home_timeout = 15 # seconds after which home command is aborted
@axis_y.move_home_timeout = 15 @axis_y.move_home_timeout = 15
@ -271,42 +279,42 @@ class HardwareInterface
# set motor driver and end stop pins to input or output output and set enables for the drivers to off # set motor driver and end stop pins to input or output output and set enables for the drivers to off
# #
def setBoardPinMode def set_board_pin_mode
@axis_x.setPinMode() @axis_x.set_pin_mode()
@axis_y.setPinMode() @axis_y.set_pin_mode()
@axis_z.setPinMode() @axis_z.set_pin_mode()
end end
# move the bot to the home position # move the bot to the home position
# #
def moveHomeX def move_home_x
@axis_x.moveHome() @axis_x.move_home()
@axis_x.disableMotor() @axis_x.disable_motor()
end end
# move the bot to the home position # move the bot to the home position
# #
def moveHomeY def move_home_y
@axis_y.moveHome() @axis_y.move_home()
@axis_y.disableMotor() @axis_y.disable_motor()
end end
# move the bot to the home position # move the bot to the home position
# #
def moveHomeZ def move_home_z
@axis_z.moveHome() @axis_z.move_home()
@axis_z.disableMotor() @axis_z.disable_motor()
end end
def setSpeed( speed ) def set_speed( speed )
end end
# move the bot to the give coordinates # move the bot to the give coordinates
# #
def moveAbsolute( coord_x, coord_y, coord_z) def move_absolute( coord_x, coord_y, coord_z)
puts '**move absolute **' puts '**move absolute **'
@ -320,13 +328,13 @@ class HardwareInterface
puts "y steps #{steps_y}" puts "y steps #{steps_y}"
puts "z steps #{steps_z}" puts "z steps #{steps_z}"
moveSteps(steps_x, steps_y, steps_z ) move_steps(steps_x, steps_y, steps_z )
end end
# move the bot a number of units starting from the current position # move the bot a number of units starting from the current position
# #
def moveRelative( amount_x, amount_y, amount_z) def move_relative( amount_x, amount_y, amount_z)
puts '**move relative **' puts '**move relative **'
@ -340,19 +348,19 @@ class HardwareInterface
puts "y steps #{steps_y}" puts "y steps #{steps_y}"
puts "z steps #{steps_z}" puts "z steps #{steps_z}"
moveSteps( steps_x, steps_y, steps_z ) move_steps( steps_x, steps_y, steps_z )
end end
# drive the motors so the bot is moved a number of steps # drive the motors so the bot is moved a number of steps
# #
def moveSteps(steps_x, steps_y, steps_z) def move_steps(steps_x, steps_y, steps_z)
# set the direction and the enable bit for the motor drivers # set the direction and the enable bit for the motor drivers
@axis_x.moveStepsPrepare(steps_x) @axis_x.move_steps_prepare(steps_x)
@axis_y.moveStepsPrepare(steps_y) @axis_y.move_steps_prepare(steps_y)
@axis_z.moveStepsPrepare(steps_z) @axis_z.move_steps_prepare(steps_z)
# loop until all steps are done # loop until all steps are done
@ -367,16 +375,16 @@ class HardwareInterface
@board.read_and_process @board.read_and_process
# move the motors # move the motors
done_x = @axis_x.moveSteps() done_x = @axis_x.move_steps()
done_y = @axis_y.moveSteps() done_y = @axis_y.move_steps()
done_z = @axis_z.moveSteps() done_z = @axis_z.move_steps()
end end
# disable motor drivers # disable motor drivers
@axis_x.disableMotor() @axis_x.disable_motor()
@axis_y.disableMotor() @axis_y.disable_motor()
@axis_z.disableMotor() @axis_z.disable_motor()
end end
end end

View File

@ -1,5 +1,6 @@
require 'json' require 'json'
require './lib/database/commandqueue.rb' #require './lib/database/commandqueue.rb'
require './lib/database/dbaccess.rb'
# Get the JSON command, received through skynet, and send it to the farmbot # Get the JSON command, received through skynet, and send it to the farmbot
# command queue Parses JSON messages received through SkyNet. # command queue Parses JSON messages received through SkyNet.
@ -8,7 +9,7 @@ class MessageHandler
attr_accessor :message attr_accessor :message
def initialize def initialize
@command_queue = CommandQueue.new @dbaccess = DbAccess.new
@last_time_stamp = '' @last_time_stamp = ''
end end
@ -32,10 +33,22 @@ class MessageHandler
# "delay" : 6 # "delay" : 6
# } # }
# } # }
def handle_message(channel, message)
@message = message def handle_message(message)
requested_command = message["message_type"].to_s.downcase
puts 'handle_message'
#puts message
#puts message['message']
@message = message['message']
#fromUuid = message['fromUuid']
#puts fromUuid
requested_command = message['message']["message_type"].to_s.downcase
#puts requested_command
if whitelist.include?(requested_command) if whitelist.include?(requested_command)
#puts 'sending'
self.send(requested_command, message) self.send(requested_command, message)
else else
self.error(message) self.error(message)
@ -49,7 +62,11 @@ class MessageHandler
end end
def single_command(message) def single_command(message)
time_stamp = message['time_stamp']
puts 'single_command'
#puts message
time_stamp = message['message']['time_stamp']
sender = message['fromUuid'] sender = message['fromUuid']
if time_stamp != @last_time_stamp if time_stamp != @last_time_stamp
@ -57,21 +74,21 @@ class MessageHandler
# send the command to the queue # send the command to the queue
delay = message['command']['delay'] delay = message['message']['command']['delay']
action = message['command']['action'] action = message['message']['command']['action']
x = message['command']['x'] x = message['message']['command']['x']
y = message['command']['y'] y = message['message']['command']['y']
z = message['command']['z'] z = message['message']['command']['z']
speed = message['command']['speed'] speed = message['message']['command']['speed']
amount = message['command']['amount'] amount = message['message']['command']['amount']
delay = message['command']['delay'] delay = message['message']['command']['delay']
puts "[new command] received at #{Time.now} from #{sender}" puts "[new command] received at #{Time.now} from #{sender}"
#puts "[#{action}] x: #{x}, y: #{y}, z: #{z}, speed: #{speed}, amount: #{amount} delay: #{delay}" puts "[#{action}] x: #{x}, y: #{y}, z: #{z}, speed: #{speed}, amount: #{amount} delay: #{delay}"
@command_queue.create_new_command(Time.now + delay.to_i) @dbaccess.create_new_command(Time.now + delay.to_i)
@command_queue.add_command_line(action, x.to_i, y.to_i, z.to_i, speed.to_s, amount.to_i) @dbaccess.add_command_line(action, x.to_i, y.to_i, z.to_i, speed.to_s, amount.to_i)
@command_queue.save_new_command @dbaccess.save_new_command
$skynet.confirmed = false $skynet.confirmed = false

View File

@ -37,15 +37,19 @@ class Skynet
# Acts as the entry point for message traffic captured from Skynet.im. # Acts as the entry point for message traffic captured from Skynet.im.
# This method is a stub for now until I have time to merge into Tim's # This method is a stub for now until I have time to merge into Tim's
# controller code. Returns a MessageHandler object (a class yet created). # controller code. Returns a MessageHandler object (a class yet created).
def handle_message(channel, message) #def handle_message(channel, message)
def handle_message(message)
puts "> message received at #{Time.now}"
#puts message
if message.class.to_s == 'Hash' if message.class.to_s == 'Hash'
@message_handler.handle_message(channel, message) @message_handler.handle_message(message)
end end
if message.class.to_s == 'String' if message.class.to_s == 'String'
message_hash = JSON.parse(message) message_hash = JSON.parse(message)
@message_handler.handle_message(channel, message_hash) @message_handler.handle_message(message_hash)
end end
rescue rescue

View File

@ -22,8 +22,11 @@ module WebSocket
### Routes all skynet messages to handle_event() for interpretation. ### Routes all skynet messages to handle_event() for interpretation.
def create_message_event def create_message_event
@socket.on :message do |channel, message| #@socket.on :message do |channel, message|
$skynet.handle_message(channel, message) # $skynet.handle_message(channel, message)
#end
@socket.on :message do |message|
$skynet.handle_message(message)
end end
end end

54
menu.rb
View File

@ -71,41 +71,41 @@ while $shutdown == 0 do
# read the file # read the file
#TestFileHandler.readCommandFile #TestFileHandler.readCommandFile
when "Z" # Move to home when "Z" # Move to home
$bot_dbaccess.createNewCommand(Time.now + $command_delay) $bot_dbaccess.create_new_command(Time.now + $command_delay)
$bot_dbaccess.addCommandLine('HOME Z', 0, 0, 0, 0, 0) $bot_dbaccess.add_command_line('HOME Z', 0, 0, 0, 0, 0)
$bot_dbaccess.saveNewCommand $bot_dbaccess.save_new_command
when "X" # Move to home when "X" # Move to home
$bot_dbaccess.createNewCommand(Time.now + $command_delay) $bot_dbaccess.create_new_command(Time.now + $command_delay)
$bot_dbaccess.addCommandLine('HOME X', 0, 0, 0, 0, 0) $bot_dbaccess.add_command_line('HOME X', 0, 0, 0, 0, 0)
$bot_dbaccess.saveNewCommand $bot_dbaccess.save_new_command
when "C" # Move to home when "C" # Move to home
$bot_dbaccess.createNewCommand(Time.now + $command_delay) $bot_dbaccess.create_new_command(Time.now + $command_delay)
$bot_dbaccess.addCommandLine('HOME Y',0 ,0 ,-$move_size, 0, 0) $bot_dbaccess.add_command_line('HOME Y',0 ,0 ,-$move_size, 0, 0)
$bot_dbaccess.saveNewCommand $bot_dbaccess.save_new_command
when "W" # Move forward when "W" # Move forward
$bot_dbaccess.createNewCommand(Time.now + $command_delay) $bot_dbaccess.create_new_command(Time.now + $command_delay)
$bot_dbaccess.addCommandLine('MOVE RELATIVE',0,$move_size, 0, 0, 0) $bot_dbaccess.add_command_line('MOVE RELATIVE',0,$move_size, 0, 0, 0)
$bot_dbaccess.saveNewCommand $bot_dbaccess.save_new_command
when "S" # Move back when "S" # Move back
$bot_dbaccess.createNewCommand(Time.now + $command_delay) $bot_dbaccess.create_new_command(Time.now + $command_delay)
$bot_dbaccess.addCommandLine('MOVE RELATIVE',0,-$move_size, 0, 0, 0) $bot_dbaccess.add_command_line('MOVE RELATIVE',0,-$move_size, 0, 0, 0)
$bot_dbaccess.saveNewCommand $bot_dbaccess.save_new_command
when "A" # Move left when "A" # Move left
$bot_dbaccess.createNewCommand(Time.now + $command_delay) $bot_dbaccess.create_new_command(Time.now + $command_delay)
$bot_dbaccess.addCommandLine('MOVE RELATIVE', -$move_size, 0, 0, 0, 0) $bot_dbaccess.add_command_line('MOVE RELATIVE', -$move_size, 0, 0, 0, 0)
$bot_dbaccess.saveNewCommand $bot_dbaccess.save_new_command
when "D" # Move right when "D" # Move right
$bot_dbaccess.createNewCommand(Time.now + $command_delay) $bot_dbaccess.create_new_command(Time.now + $command_delay)
$bot_dbaccess.addCommandLine('MOVE RELATIVE', $move_size, 0, 0, 0, 0) $bot_dbaccess.add_command_line('MOVE RELATIVE', $move_size, 0, 0, 0, 0)
$bot_dbaccess.saveNewCommand $bot_dbaccess.save_new_command
when "R" # Move up when "R" # Move up
$bot_dbaccess.createNewCommand(Time.now + $command_delay) $bot_dbaccess.create_new_command(Time.now + $command_delay)
$bot_dbaccess.addCommandLine('MOVE RELATIVE', 0, 0, $move_size, 0, 0) $bot_dbaccess.add_command_line('MOVE RELATIVE', 0, 0, $move_size, 0, 0)
$bot_dbaccess.saveNewCommand $bot_dbaccess.save_new_command
when "F" # Move down when "F" # Move down
$bot_dbaccess.createNewCommand(Time.now + $command_delay) $bot_dbaccess.create_new_command(Time.now + $command_delay)
$bot_dbaccess.addCommandLine("MOVE RELATIVE", 0, 0, -$move_size, 0, 0) $bot_dbaccess.add_command_line("MOVE RELATIVE", 0, 0, -$move_size, 0, 0)
$bot_dbaccess.saveNewCommand $bot_dbaccess.save_new_command
end end
end end