Sha256: 9324f7916076c9eb99dbcd147adb1ab670665a5319f986ef720489cd3eb6adc3

Contents?: true

Size: 1.92 KB

Versions: 29

Compression:

Stored size: 1.92 KB

Contents

require 'artoo'

connection :ardrone, :adaptor => :ardrone, :port => '192.168.1.1:5556'
device :drone, :driver => :ardrone, :connection => :ardrone

connection :navigation, :adaptor => :ardrone_navigation, :port => '192.168.1.1:5554'
device :nav, :driver => :ardrone_navigation, :connection => :navigation

connection :arduino, :adaptor => :firmata, :port => "8023"
device :classic, :driver => :wiiclassic, :connection => :arduino, :interval => 0.1

api :host => 'localhost', :port => '8080'

work do
  init_settings

  on nav, :update => :nav_update

  on classic, :a_button => proc { drone.take_off }
  on classic, :b_button => proc { drone.hover }
  on classic, :x_button => proc { drone.land }
  on classic, :y_button => proc { 
    if @toggle_camera == 0
      drone.bottom_camera
      @toggle_camera = 1
    else
      drone.front_camera
      @toggle_camera = 0
    end
  }
  on classic, :home_button => proc { drone.emergency }
  on classic, :start_button => proc { drone.start }
  on classic, :select_button => proc { drone.stop }
  on classic, :ry_up => proc { drone.up(@altitude_pitch) }
  on classic, :ry_down => proc { drone.down(@altitude_pitch) }
  on classic, :ly_up => proc { drone.forward(@fly_pitch) }
  on classic, :ly_down => proc { drone.backward(@fly_pitch) }
  on classic, :lx_right => proc { drone.right(@fly_pitch) }
  on classic, :lx_left => proc { drone.left(@fly_pitch) }
  on classic, :reset_pitch_roll => proc {
    drone.left(0.0)
    drone.forward(0.0)
  }
  on classic, :rotate_left => proc { drone.turn_left(@rotate_pitch) }
  on classic, :rotate_right => proc { drone.turn_right(@rotate_pitch) }
  on classic, :reset_rotate => proc { drone.turn_left(0.0) }
  on classic, :reset_altitude => proc { drone.up(0.0) } 
end

def init_settings
  @rotate_pitch = 0.5
  @fly_pitch = 0.7
  @altitude_pitch = 1
  @toggle_camera = 0
end

def nav_update(*data)
  data[1].drone_state.each do |name, val|
    p "#{name}: #{val}"
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
artoo-1.6.7 examples/ardrone_nav_wiiclassic.rb
artoo-1.6.6 examples/ardrone_nav_wiiclassic.rb
artoo-1.6.5 examples/ardrone_nav_wiiclassic.rb
artoo-1.6.4 examples/ardrone_nav_wiiclassic.rb
artoo-1.6.3 examples/ardrone_nav_wiiclassic.rb
artoo-1.6.2 examples/ardrone_nav_wiiclassic.rb
artoo-1.6.1 examples/ardrone_nav_wiiclassic.rb
artoo-1.6.0 examples/ardrone_nav_wiiclassic.rb
artoo-1.5.0 examples/ardrone_nav_wiiclassic.rb
artoo-1.4.1 examples/ardrone_nav_wiiclassic.rb
artoo-1.4.0 examples/ardrone_nav_wiiclassic.rb
artoo-1.3.0 examples/ardrone_nav_wiiclassic.rb
artoo-1.2.2 examples/ardrone_nav_wiiclassic.rb
artoo-1.2.1 examples/ardrone_nav_wiiclassic.rb
artoo-1.2.0 examples/ardrone_nav_wiiclassic.rb
artoo-1.1.1 examples/ardrone_nav_wiiclassic.rb
artoo-1.1.0 examples/ardrone_nav_wiiclassic.rb
artoo-1.1.0.pre examples/ardrone_nav_wiiclassic.rb
artoo-1.0.0 examples/ardrone_nav_wiiclassic.rb
artoo-1.0.0.rc4 examples/ardrone_nav_wiiclassic.rb