Well, two things: you probably want to define your variables using the
RAD syntax like this:
@left_direction = "1, byte"
@right_direction = "1, byte"
@left_motor_speed = "0, long"
@right_motor_speed = "0, long"
However, in general, what you are doing with flying_robot would be
best implemented as an autopilot routine. Here is a tiny example of
how to modify the flying_robot_blimpduino sketch to do what it looks
like you wanted from your test routine:
First modify the autopilot method as follows:
def autopilot
if current_command_autopilot == '0'
# autopilot cancel, so we should shutoff motors
throttle_speed = 0
set_thrusters
serial_println "Autopilot Is Off"
end
if current_command_autopilot == '1'
# follow motor pattern
autopilot_on
serial_println "Autopilot 1 On"
end
end
Next, modify the handle_autopilot_update method like this:
def handle_autopilot_update
if is_autopilot_on && millis() - @last_autopilot_update >
@autopilot_update_frequency
if current_command_autopilot == '1'
navigate_using_motor_pattern
end
@last_autopilot_update = millis()
end
end
Last, add a method called navigate_using_motor_pattern like this:
def navigate_using_motor_pattern
if @left_direction == @forward
@left_motor_speed = @left_motor_speed + 2
if @left_motor_speed > MAX_SPEED / AUTOPILOT_THRUST_FACTOR
@left_direction = @reverse
@left_motor_speed = 0
end
end
if @left_direction == @reverse
@left_motor_speed = @left_motor_speed + 2
if @left_motor_speed > MAX_SPEED / AUTOPILOT_THRUST_FACTOR
@left_direction = @forward
@left_motor_speed = 0
end
end
activate_thrusters
end
Hopefully you find this example helpful. Please let me know if can be
of further assistance.
Regards,
Ron
--
Ron Evans
310-597-1013
ron....@gmail.com