2

I'm trying to run a Ruby file that enables leap motion for sphero (version 2.0.0). I'm having troubles with the loading error when I try running from cmd.

The code for the ruby file:

 require 'em-websocket' require 'sphero' Sphero.start "/dev/tty.Sphero-RWP-AMP-SPP" do |s| puts "Connected to Sphero!" sleep 1 3.times do begin s.color 'green' rescue end end keep_going 1 s.color 'black' calibration = 0 EM.run { EM::WebSocket.run(:host => "0.0.0.0", :port => 8080) do |ws| mutex_sphero = Mutex.new mutex_req = Mutex.new req = nil ws.onopen { |handshake| puts "WebSocket connection open" } ws.onclose { puts "Connection closed" } ws.onmessage { |msg| puts "Recieved message: #{msg}" if msg == 'start' mutex_sphero.synchronize { s.color 'blue', true } elsif msg == 'stop' mutex_sphero.synchronize { s.color 'black', true stop mutex_req.synchronize { req = nil } } elsif msg == 'calibrate+' or msg == 'calibrate-' mutex_sphero.synchronize { s.color 'black' s.back_led_output = 0xff calibration = (calibration + (msg == "calibrate+" ? 15 : 360-15)) % 360 puts "calibration = #{calibration}" s.roll 0, calibration } EM.cancel_timer(@calib_timer) if @calib_timer @calib_timer = EM.add_timer(3) do mutex_sphero.synchronize { s.back_led_output = 0 } end else data = msg.split(',').map {|d| d.to_i } speed = [Math.sqrt(data[0]**2 + data[1]**2)*20, 0xff].min.to_i deg = Math.atan2(data[0], data[1]) / Math::PI * 180 deg = (deg + calibration + 360) % 360 p [speed, deg.to_i] mutex_req.synchronize { req = [speed, deg.to_i] } EM.defer do mutex_sphero.synchronize do r = nil mutex_req.synchronize { r, req = req, r } s.roll *r if r end end } end } end 

Here's the error:

C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53;in 'require' cannot load such file -- C:\Ruby200\lib\ruby\gems\2.0.0\gems\em-websocket.gem <LoadError> from C:/Ruby200/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:53:in 'require' from websocket-sphero.rb:3:in '<main>' 

Can anyone help me?

4
  • do you have this file github.com/mwylde/em-websocket-client/blob/master/lib/… Commented Jan 2, 2014 at 8:56
  • Nope, I tried downloading the file and running it, but the same error from above came in. Commented Jan 2, 2014 at 9:01
  • The backtrace is using forward slash for directory delimiters, but the error shows back slash. Does this have anything to do with the error? Commented Jan 2, 2014 at 9:03
  • It still gives the same error. Commented Jan 2, 2014 at 9:08

1 Answer 1

1

I had the same issue and running this fixed it.

sudo gem install em-websocket 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.