hybridgroup / artoo-raspi Goto Github PK
View Code? Open in Web Editor NEWArtoo adaptor for the Raspberry Pi
Home Page: http://artoo.io
License: Other
Artoo adaptor for the Raspberry Pi
Home Page: http://artoo.io
License: Other
Is it possible to run servo motor with raspi adapter? Artoo documentation (http://artoo.io/documentation/platforms/raspberry-pi/#Drivers) says it is. However I've got error running next code
require 'artoo'
# Circuit and schematic here: http://arduino.cc/en/Tutorial/Sweep
connection :raspi, :adaptor => :raspi
device :board, :driver => :device_info
device :servo, :driver => :servo, :pin => 3 # pin must be a PWM pin
work do
puts "Firmware name: #{board.firmware_name}"
puts "Firmata version: #{board.version}"
servo.move(0) # reset the position of the sweep (same as servo.min)
every(2) do
case servo.current_angle
when 0 then servo.center
when 90 then servo.max
when 180 then servo.min
end
end
end
Error
I, [2015-11-13T07:28:30.949952 #2363] INFO -- : Registering connection 'raspi'...
I, [2015-11-13T07:28:30.952048 #2363] INFO -- : Registering device 'board'...
I, [2015-11-13T07:28:30.953788 #2363] INFO -- : Registering device 'servo'...
I, [2015-11-13T07:28:30.955761 #2363] INFO -- : Preparing work...
I, [2015-11-13T07:28:30.969973 #2363] INFO -- : Initializing artoo::connection raspi...
I, [2015-11-13T07:28:31.114995 #2363] INFO -- : Initializing artoo::device board...
I, [2015-11-13T07:28:31.152516 #2363] INFO -- : Initializing artoo::device servo...
I, [2015-11-13T07:28:31.210104 #2363] INFO -- : Starting work...
I, [2015-11-13T07:28:31.216927 #2363] INFO -- : Connecting to 'raspi' on port 'none'...
I, [2015-11-13T07:28:31.267642 #2363] INFO -- : Starting driver 'Artoo::Drivers::DeviceInfo'...
I, [2015-11-13T07:28:31.269770 #2363] INFO -- : Starting driver 'Artoo::Drivers::Servo'...
Firmware name: Raspberry Pi
Firmata version: 0.6.1
E, [2015-11-13T07:28:31.374009 #2363] ERROR -- : Actor crashed!
NoMethodError: undefined method `servo_write' for nil:NilClass
/home/pi/.rvm/gems/ruby-head/gems/artoo-raspi-0.6.1/lib/artoo/adaptors/raspi.rb:109:in `method_missing'
/home/pi/.rvm/gems/ruby-head/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in `public_send'
/home/pi/.rvm/gems/ruby-head/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in `dispatch'
/home/pi/.rvm/gems/ruby-head/gems/celluloid-0.16.0/lib/celluloid/calls.rb:63:in `dispatch'
/home/pi/.rvm/gems/ruby-head/gems/celluloid-0.16.0/lib/celluloid/cell.rb:60:in `block in invoke'
/home/pi/.rvm/gems/ruby-head/gems/celluloid-0.16.0/lib/celluloid/cell.rb:71:in `block in task'
/home/pi/.rvm/gems/ruby-head/gems/celluloid-0.16.0/lib/celluloid/actor.rb:357:in `block in task'
/home/pi/.rvm/gems/ruby-head/gems/celluloid-0.16.0/lib/celluloid/tasks.rb:57:in `block in initialize'
/home/pi/.rvm/gems/ruby-head/gems/celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:15:in `block in create'
Disconnecting all PWM pins...E, [2015-11-13T07:28:31.377007 #2363] ERROR -- : undefined method `servo_write' for nil:NilClass
What have I done wrong?
P.S. Thank you for the great gem!
Using artoo-raspi with my pi , I don't need the pin translation. In fact, it threw me off for a while. My pins match up correctly with their numbers. Why does this include the pin translation? Maybe it was a work around for an old issue that is no longer around?
I have a pi running raspbian, ruby 2.2.2 and Rails 4.2.3
I have artoo-raspi installed and can run code that reads thermo and switches leds from the consol.
ruby raspi_therm.rb does just what i expect reading and writing to pi pins.
When i try to do the same thing from within Rails
Bundler installs with out error and lists the gems
artoo 1.8.1
artoo-gpio 0.4.1
artoo-i2c 0.5.0
artoo-raspi 0.6.0
Starting rails s results in Load error: require cannot load such file -- lib/artoo/adaptors/raspi
Looking at the path in the message i can see artoo-raspi.rb which requires lib/artoo/adaptors/raspi on line one and i can also see lib/artoo/adaptors/raspi.rb
Any ideas about what is going on?
Cheers
Chris
Hi,
I'm trying out artoo for our makerspace based on a talk you guys gave at the Miami RubyConf last weekend.
Googling hasn't helped and I couldn't find a place to put this. I was hoping to eventually add mcp3008, and other i2c related code up here.
Just testing out the simple led example with the Pi https://github.com/hybridgroup/artoo-raspi
and I'm getting :
I, [2013-11-14T16:46:55.764633 #3044] INFO -- : Preparing work...
I, [2013-11-14T16:46:55.777544 #3044] INFO -- : Initializing connection raspi...
I, [2013-11-14T16:46:55.866557 #3044] INFO -- : Initializing device board...
I, [2013-11-14T16:46:55.898742 #3044] INFO -- : Initializing device led...
I, [2013-11-14T16:46:56.008247 #3044] INFO -- : Starting work...
I, [2013-11-14T16:46:56.016834 #3044] INFO -- : Connecting to 'raspi' on port 'none'...
I, [2013-11-14T16:46:56.069279 #3044] INFO -- : Starting driver 'Artoo::Drivers::DeviceInfo'...
Starting driver 'Artoo::Drivers::Led'...
Firmware name: Raspberry Pi
E, [2013-11-14T16:46:56.119757 #3044] ERROR -- : Artoo::Adaptors::Raspi crashed!
NameError: uninitialized constant Artoo::Raspi
/var/lib/gems/1.9.1/gems/artoo-raspi-0.5.0/lib/artoo/adaptors/raspi.rb:56:in version' /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in
public_send'
/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in dispatch' /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:67:in
dispatch'
/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in block in handle_message' /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in
block in task'
/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in block in initialize' /var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in
block in create'
Disconnecting all PWM pins...E, [2013-11-14T16:46:56.123695 #3044] ERROR -- : uninitialized constant Artoo::Raspi
E, [2013-11-14T16:46:56.136144 #3044] ERROR -- : ["/var/lib/gems/1.9.1/gems/artoo-raspi-0.5.0/lib/artoo/adaptors/raspi.rb:56:in version'", "/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in
public_send'", "/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in dispatch'", "/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:67:in
dispatch'", "/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in block in handle_message'", "/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in
block in task'", "/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in block in initialize'", "/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in
block in create'", "(celluloid):0:in remote procedure call'", "/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:92:in
value'", "/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/proxies/sync_proxy.rb:33:in method_missing'", "/var/lib/gems/1.9.1/gems/artoo-1.4.1/lib/artoo/connection.rb:86:in
method_missing'", "/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in public_send'", "/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:25:in
dispatch'", "/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/calls.rb:67:in dispatch'", "/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:322:in
block in handle_message'", "/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/actor.rb:416:in block in task'", "/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks.rb:55:in
block in initialize'", "/var/lib/gems/1.9.1/gems/celluloid-0.15.2/lib/celluloid/tasks/task_fiber.rb:13:in `block in create'"]
Firmata version:
Hey,
So I have picked up that the raspi_pins are not being cleaned up along with pwm_pins in the raspi achor
see code below
def disconnect
puts "Disconnecting all PWM pins..."
release_all_pwm_pins
super
end
I believe the following should be added to sort out the error above
def disconnect
puts "Disconnecting all PWM pins..."
release_all_pwm_pins
puts "Disconnecting all Raspi pins..."
close_all_raspi_pins
super
end
# new method
def close_all_raspi_pins
pins.each_value { |pin| pin.close }
end
Hope this is all in order, please also see the error stack
/home/pi/.rvm/gems/ruby-2.2.1/gems/artoo-1.8.1/lib/artoo/adaptors/io/digital_pin.rb:16:in close
/home/pi/.rvm/gems/ruby-2.2.1/gems/artoo-1.8.1/lib/artoo/adaptors/io/digital_pin.rb:16:in open
/home/pi/.rvm/gems/ruby-2.2.1/gems/artoo-1.8.1/lib/artoo/adaptors/io/digital_pin.rb:16:in initialize
/home/pi/.rvm/gems/ruby-2.2.1/gems/artoo-raspi-0.6.1/lib/artoo/adaptors/raspi.rb:120:in new
/home/pi/.rvm/gems/ruby-2.2.1/gems/artoo-raspi-0.6.1/lib/artoo/adaptors/raspi.rb:120:in raspi_pin
/home/pi/.rvm/gems/ruby-2.2.1/gems/artoo-raspi-0.6.1/lib/artoo/adaptors/raspi.rb:87:in digital_write
/home/pi/.rvm/gems/ruby-2.2.1/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in public_send
/home/pi/.rvm/gems/ruby-2.2.1/gems/celluloid-0.16.0/lib/celluloid/calls.rb:26:in dispatch
/home/pi/.rvm/gems/ruby-2.2.1/gems/celluloid-0.16.0/lib/celluloid/calls.rb:63:in dispatch
/home/pi/.rvm/gems/ruby-2.2.1/gems/celluloid-0.16.0/lib/celluloid/cell.rb:60:in block in invoke
/home/pi/.rvm/gems/ruby-2.2.1/gems/celluloid-0.16.0/lib/celluloid/cell.rb:71:in block in task
/home/pi/.rvm/gems/ruby-2.2.1/gems/celluloid-0.16.0/lib/celluloid/actor.rb:357:in block in task
/home/pi/.rvm/gems/ruby-2.2.1/gems/celluloid-0.16.0/lib/celluloid/tasks.rb:57:in block in initialize
/home/pi/.rvm/gems/ruby-2.2.1/gems/celluloid-0.16.0/lib/celluloid/tasks/task_fiber.rb:15:in block in create
I believe the error is being caused because the pins are not being shutdown correctly when an adaptor is destroyed or discarded. But I could be wrong, if this is not a bug or issue. Please do you mind guiding me in the right direction to how one gets around this or if there is known fix already
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.