EzDevInfo.com

artoo

artoo.js - the client-side scraping companion. artoo.js · The client-side scraping companion.

Timers is not a class when trying to use artoo-ardrone with rails

It appears to be breaking our celluloid gem causing us to uninstall all artoo gems and reinstall them in the order: celluloid, artoo, artoo-ardrone, artoo-keyboard. The actual error in rails is Timers is not a class on timers.rb line 2 (where its declared)

exact error:

$ rails s
D, [2015-05-08T20:17:54.722854 #2716] DEBUG -- : Terminating 4 actors...
/Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/artoo-1.6.4/lib/artoo/ext/timers.rb:2:in `<top (required)>': Timers is not a class (TypeError)
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/artoo-1.6.4/lib/artoo/robot.rb:4:in `require'
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/artoo-1.6.4/lib/artoo/robot.rb:4:in `<top (required)>'
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/artoo-1.6.4/lib/artoo.rb:2:in `require'
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/artoo-1.6.4/lib/artoo.rb:2:in `<top (required)>'
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:76:in `require'
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:72:in `each'
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:72:in `block in require'
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:61:in `each'
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.7.4/lib/bundler/runtime.rb:61:in `require'
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/bundler-1.7.4/lib/bundler.rb:133:in `require'
    from /Users/apprentice/Desktop/artoo/iago/config/application.rb:7:in `<top (required)>'
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:in `require'
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:78:in `block in server'
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `tap'
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:75:in `server'
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /Users/apprentice/.rbenv/versions/2.0.0-p353/lib/ruby/gems/2.0.0/gems/railties-4.2.1/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:8:in `require'
    from bin/rails:8:in `<main>'

GEMs in gemfile in order:

gem 'timers'

gem 'thor'

gem 'artoo'

gem 'artoo-ardrone'

gem 'artoo-keyboard'

gem 'rails', '4.2.1'

gem 'celluloid'

trying to run code in controller:

class DroneController < ApplicationController

  def index

  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 :keyboard, adaptor: :keyboard
  device :keyboard, driver: :keyboard, connection: :keyboard

  work do
    # on drone, :ready => :fly

    on keyboard, :key => :keypress


    drone.start(nav) # pass the nav object into the start method

  end

  def keypress(sender, key)
      #bunch of if statements for flight control here
  end

end

  end

end

Source: (StackOverflow)

How do I connect my sphero ollie to my Mac OSX?

I'm trying to play with the ruby artoo gem. To do this, I need to first register the device with my bluetooth adapter on my Mac. I've opened the system bluetooth settings, my bluetooth is on, but scanning produces no results.

I'm unsure if I need to do something to my ollie first to turn it on and make it discoverable.

I've tried playing with the node cylon-ble-scan tools and poked around at some other projects, but nothing has worked so far.

Any clues?


Source: (StackOverflow)

Advertisements

How to properly shutdown artoo?

I'm using the below code snippet to shutdown my artoo application when the user hits the q key. This often leaves orphaned celluloid threads and the process still running after shutdown. I end up having to locate the pid and kill the ruby process manually most times.

Is there some other way to properly shutdown artoo or to kill off the celluloid processes nicely at shutdown?

require 'artoo'

connection :sphero, :adaptor => :sphero, :port => '/dev/tty.Sphero-YBB-AMP-SPP'
device :sphero, :driver => :sphero

connection :keyboard, adaptor: :keyboard
device :keyboard, driver: :keyboard, connection: :keyboard

def keypress(sender, key)
  case key
  when 'q'
    exit
  end
end

work do
  on keyboard, :key => :keypress
end


celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:34:in `terminate'"
"/Users/me/.rvm/gems/ruby-2.2.1@artoo/gems/cellulo[1349/1349] ib/celluloid/actor.rb:345:in `each'",
"/Users/me/.rvm/gems/ruby-2.2.1@artoo/gems/celluloid-0.16.0/lib/celluloid/actor.rb:345:in `cleanup'",
"/Users/me/.rvm/gems/ruby-2.2.1@artoo/gems/celluloid-0.16.0/lib/celluloid/actor.rb:329:in `shutdown'"
"/Users/me/.rvm/gems/ruby-2.2.1@artoo/gems/celluloid-0.16.0/lib/celluloid/actor.rb:164:in `run'"
"/Users/me/.rvm/gems/ruby-2.2.1@artoo/gems/celluloid-0.16.0/lib/celluloid/actor.rb:130:in `block in start'"
"/Users/me/.rvm/gems/ruby-2.2.1@artoo/gems/celluloid-0.16.0/lib/celluloid/thread_handle.rb:13:in `block in initialize'"
"/Users/me/.rvm/gems/ruby-2.2.1@artoo/gems/celluloid-0.16.0/lib/celluloid/actor_system.rb:32:in `block in get_thread'"
"/Users/me/.rvm/gems/ruby-2.2.1@artoo/gems/celluloid-0.16.0/lib/celluloid/internal_pool.rb:1 30:in `call'"
"/Users/me/.rvm/gems/ruby-2.2.1@artoo/gems/celluloid-0.16.0/lib/celluloid/internal_pool.rb:130:in `block in create'"]
[2015-03-12T19:49:42.550844 #79970]  WARN -- : Terminating task: type=:call meta={:method_name=>:get_char}
status=:callwait
Celluloid::TaskFiber backtrace unavailable. Please try `Celluloid.task_class = Celluloid::TaskThread` if you need backtraces here.
E, [2015-03-12T19:49:42.550978 #79970] ERROR -- : task was terminated

Source: (StackOverflow)