SlideShare uma empresa Scribd logo
1 de 75
A Survey of Robotics
in Ruby
Josh Adams | @knewter
Adam Dill | @adamdill
Saturday, June 15, 13
A
This is Josh Adam from Isotope 11
I am Adam DIll from Inside.com
And how can it not be fun, were talking about robots!
This talk has two parts
• Survey / knowledge dump
• Project narrative
Saturday, June 15, 13
J:
This talk has a couple of parts. The first one is really just a braindump - lots of good information on the library landscape.
After that, we’ll dig into building a project together
Part the first
A Survey of Robotics with Ruby
Saturday, June 15, 13
A
So lets dive into the survey so you guys can see what is out there
Robots?
• A machine capable of carrying out a complex series of actions
automatically.
• (esp. in science fiction) A machine resembling a human being
and able to replicate certain human movements and
functions.
• Robotics: The branch of technology that deals with the
design, construction, operation, and application of robots.
Saturday, June 15, 13
A:
What is a robot?
a robot is a force multiplier, it lets you take a simple action and cause a cascade of more complex decisions and actions
JOSH
Robots?
• A machine capable of carrying out a complex series of actions
automatically.
• (esp. in science fiction) A machine resembling a human being
and able to replicate certain human movements and
functions.
• Robotics: The branch of technology that deals with the
design, construction, operation, and application of robots.
LAM
ESaturday, June 15, 13
ROBOTS!!!1!!!one!
http://www.flickr.com/photos/torek/3788181603/
Saturday, June 15, 13
J
We all know what robots are, right? They’re awesome
State of Hobby Robotics
• Growing rapidly
• lots of good mags
• My 3 favorites =>
• Costs have fallen
• Getting really approachable
Saturday, June 15, 13
A
mass production of sensors for phones has made this affordable
while the maker movement has made this approachable approachable
great references are available, make first among them
State of Hobby Robotics
with Ruby
• http://artoo.io/ - Sinatra for Robots
• https://github.com/hparra/ruby-serialport/
• http://www.rock-robotics.org - heavily c based, wired
together with Ruby
• right now, Python is better, and certainly more active, and
more mature
• long term, Ruby is a great choice
Saturday, June 15, 13
A
Artoo is like sinatra for Robotics. It’s definitely leading the pack right now.
Serialport is an easy way to use serial devices, but there are some baud rate issues.
Rock robotics is mostly C-based, but wired together with Ruby
Python’s presently outpacing us in robots, but Ruby is the future.
J
Why is Ruby such a good choice, Adam?
Why is Ruby a great choice?
• All the normal reasons Ruby is great
• DSLs
• Metaprogramming
• Developer happiness
Saturday, June 15, 13
A
All the normal reasons:
DSLs, Metaprogramming, and you can have fun *writing* your robots, not just playing with them.
Artoo.io Example
Saturday, June 15, 13
J
So we aren’t going to dig into artoo too much, but it’s definitely worth checking out.
Artoo’s awesome and provides a common interface for various
devices. It’s really made for controlling toys, which is fun and
an easy way to start.
It also gives you an easy way to roll a web API interface for your system.
(It also uses Celluloid, which is easily my favorite Ruby library)
Where to start?
• Get easy wins early:
• Sphero - about $130
• Parrot ARDrone - about $150 refurb
Saturday, June 15, 13
A
Don’t start with a giant project
It’s very easy to get bogged down in a small hardware problem (resistor values, etc)
J
When should I learn Ohm’s Law, etc?
A
Right. So make sure to get some easy wins up front to help keep yourself motivated.
I suggest you buy either a sphero or a Parrot ARDrone and just play with it.
Sphero
• http://www.gosphero.com/
• Bluetooth enabled ball
• drives itself around
• best dog toy ever
• waterproof
Saturday, June 15, 13
A
This is a sphero. It’s basically just a ball with a motor inside of it.
It’s bluetooth-controlled (via serialport), it’s a lot of fun and really simple.
These are great for someone just learning to program to see real-world results of the code they’re typing, so it’d be good for
teaching kids and keeping them engaged.
There are some great KidsRuby Artoo resources for the Sphero
Sphero with Ruby
Saturday, June 15, 13
A
Cool Sphero gems, and artoo supports it.
You can see we’re just giving it a speed and a direction. It doesn’t get much simpler than this.
(DEMO)
Saturday, June 15, 13
A
Here’s an example of using Artoo to control an armada (fleet?) of spheros
What’s cool here is you can see how multitasking works with this evented architecture.
Parrot ARDrone
• http://ardrone2.parrot.com/
• Acts as its own wifi AP
• Connect to it over wifi, it’s
just a device with an IP
• Send UDP packets to it
• Stream video from 2
cameras
Saturday, June 15, 13
J
So the other easy toy is the Parrot ARDrone. This guy creates his own WiFi access point that you connect to, then you can just
send him UDP packets to control him. He’s also got a couple of video cameras.
Like we said, it’s $150 for a refurb and you can get a new one for around $250
Parrot ARDrone
Saturday, June 15, 13
J
Jim Weirich wrote the `argus` gem to control it via Ruby
Artoo supports it
(DEMO)
Rolling your own
• What if you don’t want a ball or a quadcopter? What if you
want to be master of your own fate?
Saturday, June 15, 13
J
So now you’ve got your easy wins and you’re still interested. What’s next?
Microcontrollers
A microcontroller is a small computer on
a single IC containing a processor,
memory, and programmable I/O. -
wikipedia
Saturday, June 15, 13
A
Microcontrollers are essentially tiny computers. The real keys are they are on a single board, and have I/O.
Microcontrollers!!!!!11!!!
wtfbbqhax
Saturday, June 15, 13
J
The arduino showed up right around the same time Make magazine did, and they had a huge impact on hobbyists (though people
that were doing microcontrollers before that will hate me for saying that). Still, it’s only a 16MHz device with virtually no storage,
no networking, and it had to be programmed in C. Now we have a whole range of options, from the Beaglebone Black to the
PCDuino, which offers a 1GHz chip, 1GB of RAM, a Mali 400 GPU, and an Arduino-compatible pinout (so you can take advantage
of existing shields). Those are both far more expensive and power hungry than the almighty Raspberry Pi, though. With a RasPi,
you get 700MHz, 512MB RAM, and networking for $35, as well as lots of GPIO to hook into. It just really hits a sweet spot.
Microcontrollers!!!!!11!!!
wtfbbqhax
Arduino
Saturday, June 15, 13
J
The arduino showed up right around the same time Make magazine did, and they had a huge impact on hobbyists (though people
that were doing microcontrollers before that will hate me for saying that). Still, it’s only a 16MHz device with virtually no storage,
no networking, and it had to be programmed in C. Now we have a whole range of options, from the Beaglebone Black to the
PCDuino, which offers a 1GHz chip, 1GB of RAM, a Mali 400 GPU, and an Arduino-compatible pinout (so you can take advantage
of existing shields). Those are both far more expensive and power hungry than the almighty Raspberry Pi, though. With a RasPi,
you get 700MHz, 512MB RAM, and networking for $35, as well as lots of GPIO to hook into. It just really hits a sweet spot.
Microcontrollers!!!!!11!!!
wtfbbqhax
Beaglebone
Black
Arduino
Saturday, June 15, 13
J
The arduino showed up right around the same time Make magazine did, and they had a huge impact on hobbyists (though people
that were doing microcontrollers before that will hate me for saying that). Still, it’s only a 16MHz device with virtually no storage,
no networking, and it had to be programmed in C. Now we have a whole range of options, from the Beaglebone Black to the
PCDuino, which offers a 1GHz chip, 1GB of RAM, a Mali 400 GPU, and an Arduino-compatible pinout (so you can take advantage
of existing shields). Those are both far more expensive and power hungry than the almighty Raspberry Pi, though. With a RasPi,
you get 700MHz, 512MB RAM, and networking for $35, as well as lots of GPIO to hook into. It just really hits a sweet spot.
Microcontrollers!!!!!11!!!
wtfbbqhax
Beaglebone
Black
Arduino
PCDuino
Saturday, June 15, 13
J
The arduino showed up right around the same time Make magazine did, and they had a huge impact on hobbyists (though people
that were doing microcontrollers before that will hate me for saying that). Still, it’s only a 16MHz device with virtually no storage,
no networking, and it had to be programmed in C. Now we have a whole range of options, from the Beaglebone Black to the
PCDuino, which offers a 1GHz chip, 1GB of RAM, a Mali 400 GPU, and an Arduino-compatible pinout (so you can take advantage
of existing shields). Those are both far more expensive and power hungry than the almighty Raspberry Pi, though. With a RasPi,
you get 700MHz, 512MB RAM, and networking for $35, as well as lots of GPIO to hook into. It just really hits a sweet spot.
Microcontrollers!!!!!11!!!
wtfbbqhax
Beaglebone
Black
Arduino
PCDuino
Raspberry Pi
Saturday, June 15, 13
J
The arduino showed up right around the same time Make magazine did, and they had a huge impact on hobbyists (though people
that were doing microcontrollers before that will hate me for saying that). Still, it’s only a 16MHz device with virtually no storage,
no networking, and it had to be programmed in C. Now we have a whole range of options, from the Beaglebone Black to the
PCDuino, which offers a 1GHz chip, 1GB of RAM, a Mali 400 GPU, and an Arduino-compatible pinout (so you can take advantage
of existing shields). Those are both far more expensive and power hungry than the almighty Raspberry Pi, though. With a RasPi,
you get 700MHz, 512MB RAM, and networking for $35, as well as lots of GPIO to hook into. It just really hits a sweet spot.
Raspberry Pi
The Raspberry Pi is a credit-
card sized computer that plugs
into your TV and a keyboard.
It’s a capable little PC which
can be used for many of the
things that your desktop PC
does, like spreadsheets, word-
processing and games. It also
plays high-definition video.
Saturday, June 15, 13
A
Josh will go ahead and pass around the Pi
[run through ports]
RaspberryPi Setup
• dd image to memory card
• plug it all up (power last)
• about a dozen setup questions
• Debian LXDE setup (lightweight x11)
• can also run Arch
• straight console if that's all you want
Saturday, June 15, 13
A
setup is really easy, dd takes about 30 min, but other than that your running in under 15 min
RaspberryPi:
Running Ruby
• install RVM normally
• install  ruby via rvm
• takes a long time to compile
• 1.9.3 seems to work better, mostly due to compile times and
gem compatibility
• expect this to change in the coming months
Saturday, June 15, 13
((Josh setup RC car))
A
Getting ruby running is about as easy, I used RVM, compile takes a few hours
1.9.3 seems to be the best right now, I expect this will change soon
RaspberryPi GPIO and Tips
• be careful with the Pi, need buffering, grab some transistors
or a ULN2003 to protect it.
• limited hardware PWM out of the box (1, shared with audio).  
We’ll get you around that limitation a little later.
• You need at least a 1-amp power supply, and you probably
want a powered USB hub if you want more than kb/mouse.
Saturday, June 15, 13
A
RaspberryPi Tips (cont)
• Get a Pi Cobbler breakout board to make your life easier
• Cirago wifi/bluetooth dongle for $11, works great
• Buy a nice case (or 3d print one :D :D :D)
• Use a class 10 SD card if you can. dd is *slooooow* on a bad
card.
• There’s a camera module for $25.
Saturday, June 15, 13
A
explain pi cobbler is the ribbon cable attached to the one going around, it makes breadboarding easier
cirago wifi/bluetooth seems to work great for basic IO and is low powered
cases keep you from shorting it out, i put some heatsinks so i can overclock mine a bit
class 10 sd cards are great, makes dd faster, and UX faster
GPIO Examples
using pi_piper gem, see: https://github.com/jwhitehorn/pi_piper
Event driven Raspberry Pi GPIO programming in Ruby
Saturday, June 15, 13
J
Input
Saturday, June 15, 13
J
Output
Saturday, June 15, 13
J
Control schemes
• Serial Ports
• Connection Types
• Bluetooth
• USB
• GPIO
• Or my favorite, straight DRb over the network
Saturday, June 15, 13
A
lots of ways to control hardware, serial ports you ust write too like appending to a text file, can attach over bluetooth usb or gpio
(J interupts)
DRB
Part the second
Building something neat
Saturday, June 15, 13
J
Rubotnik
(This slide intentionally
left dumb)
Saturday, June 15, 13
J
So you have a RasPi
• We made it blink earlier with `pi_piper`
• What’s the next quick win we can get?
• (note: most of the upcoming code is super quick-n-dirty)
• Our goal is just to demystify this stuff - none of this code is
beyond a Ruby Nuby.
Saturday, June 15, 13
A
So we got some easy wins with the toys earlier, and we took a microcontroller and made an LED blink
What is our next steps?
Going forward we have a lot of quick code, goal isn’t to provide code examples but to demystify how this works. No magic here.
Twitter-powered blinkenlights
Saturday, June 15, 13
J
Saturday, June 15, 13
J
That was cool. Now what?
• How’s about some more direct control?
• Android -> JRuby <- DRb -> MRI -> RasPi -> Blinkenlight
Saturday, June 15, 13
A
So all this is cool, but how can we get into some more direct control of robots?
talk through adding android and DRB
J
Something about how awful writing custom protocols is
compared to DRb
Saturday, June 15, 13
J
This is the pickaxe example of DRb objects basically, completely standard...talk through class briefly
So now android?
• Eww, java
• Not the worst thing in the world
• Tiny code
Saturday, June 15, 13
J
You came to this conference looking for Java code and we know it.
Saturday, June 15, 13
J
This interface is literally just a button
Saturday, June 15, 13
J
I don’t think this is scary Java code, but it has lots of things I learned about jruby that will be helpful
Use JRuby jars from ruboto project
Saturday, June 15, 13
J
...or JRuby asplode
Saturday, June 15, 13
J
if you don’t add stdlib to loadpath
you spend three days crying
Saturday, June 15, 13
J
AsyncTask because no network
on main thread (also, you need
the INTERNET permission for DRb)
Saturday, June 15, 13
J
Cat’ing ruby strings together.
With globals for control flow.
Nothing unusual here.
Move along.
Saturday, June 15, 13
J
Saturday, June 15, 13
RGB LED
Saturday, June 15, 13
A
What’s the next obvious step past a single red led?
A single RGB LED. Let’s make it happen
RGB LED
• So now we have an LED, so what’s the next simplest way to
ratchet up?
Saturday, June 15, 13
A
What’s the next obvious step past a single red led?
A single RGB LED. Let’s make it happen
RGB LED
• So now we have an LED, so what’s the next simplest way to
ratchet up?
• RGB LED, controlled by a color picker on the android device,
that changes color in realtime.
Saturday, June 15, 13
A
What’s the next obvious step past a single red led?
A single RGB LED. Let’s make it happen
RGB LED
• So now we have an LED, so what’s the next simplest way to
ratchet up?
• RGB LED, controlled by a color picker on the android device,
that changes color in realtime.
• Problem: RGB LED requires analog levels, but we only have
digital with pi_piper.
Saturday, June 15, 13
A
What’s the next obvious step past a single red led?
A single RGB LED. Let’s make it happen
Pulse Width Modulation
Saturday, June 15, 13
A
So you can use PWM to simulate analog levels, but you’re really just switching them on and off. If an output is switched on 10% of
the time, evenly distributed, then it makes an LED look like it’s been sent a 10% max output signal.
Later we’ll use them for logic level stuff, but for now we’ll just treat PWM like fake-analog.
Pulse Width Modulation
• RasPi only has one hardware PWM pin, and it’s shared with
the audio output (so you can’t use PWM and play sound at the
same time)
• So you can run pi-blaster to get 8 PWM outputs. It’s a
userland driver that hooks into the true PWM pin’s interrupt
and uses it to drive any GPIO pin like it’s PWM
• https://github.com/sarfata/pi-blaster/
Saturday, June 15, 13
J
pi-blaster, up to 8 PWM
Pulse Width Modulation
• To completely turn off pin1:
echo "1=0" > /dev/pi-blaster
• To completely turn on pin1:
echo "1=1" > /dev/pi-blaster
• To set pin1 to a PWM of 20%
echo "1=0.2" > /dev/pi-blaster
Saturday, June 15, 13
A
Here’s how you use pi-blaster - everything’s just a file, and you write commands to it
Saturday, June 15, 13
J
Here’s a really basic class representing our rgb led. I’m just showing the red channel code here.
This class is actually
like 200 lines long :-
Saturday, June 15, 13
J
If we’d used any metaprogramming at all here, it’d have been much smaller. I promised quick-n-dirty code right?
Buuuuut
• Turns out that most RGB LEDs expect the common leg to be
high, and the channel-specific legs to be a modulated ground
(our code assumed the common leg would be ground)
• Luckily, Ruby’s awesome so when I ran into this when testing
it took all of three seconds to fix it up. NOTE: I also had to
run the 3.3V line to the common leg, then you’re just
modulating the difference (so 100% duty cycle for a given leg
means no voltage potential difference, or ‘off’)
Saturday, June 15, 13
J
ZOMG
Saturday, June 15, 13
J
Hey hey, object oriented programming is awesome.
Anyway, let’s go ahead and see what the android interface for this project looks like
Saturday, June 15, 13
A
Just a basic color picker, nothing fancy here. As you change the slider, we want the led updating in real time
Saturday, June 15, 13
J
More java code. Last time we ran code each time you hit a button, but now we have a slider. At first I ran code on each change
event from the slider, but it turns out DRb can’t handle 200 messages/second and it would get laggy.
Timer Task that fires 20 times
per second. That seems to be
a sweet spot.
Saturday, June 15, 13
J
So my solution to this is to sample the UI 20x/second and send a message over DRb each time
If you’re going this route, have a single
method that accepts the state of the
User Interface. Then handle it on
the server side (rather than multiple
messages, one per user interface
component)
Saturday, June 15, 13
J
I found out later that apparently that’s what RC Controllers in the real world do anyway, so that was serendipitous. So there’s
basically all the code, how well does it work?
Saturday, June 15, 13
J
Pretty darn well....
So what’s next?
• Let’s finish this project up with something
fun.
• You go to the thrift store, and you buy one
of these bad boys for $2. This is the way
to go for this stuff by the way - there’s a
TON of old toys waiting to be awesome
again.
• Tank steering R/C base - this is the RAD2.
Saturday, June 15, 13
A
Alright, so we’ve got PWM control of a ruby process from android now. What next?
Let’s finish up by building an RC Tank steering thingie...
bullet points...
Speed Construction
• Take a Sabertooth 2x12RC ($65)
• Add a RasPi
• Add a 12V battery
• Add a cirago wifi/bt stick
• Mutilate a usb micro cable
Saturday, June 15, 13
J
Put all this stuff together aaaand
Saturday, June 15, 13
J
This is what you end up with
PWM and the Sabertooth
• So to control the Sabertooth,
you send a PWM signal per-
motor.
• 2000us pulse width: 100%
forward
• 1500us pulse width: idle
• 1000us pulse width: 100%
reverse
Mapped
to 0..1
values for
pi-blaster
Saturday, June 15, 13
J
Explain sabertooth logic levels, and show how we’re mapping them to pi-blaster levels
-1.0
1.0
Saturday, June 15, 13
A
Here’s the interface. Just two sliders, mapped from -1 to 1. Your standard tank steering controls
Map those values from the last
slide into our pwm output values
for pi-blaster
Saturday, June 15, 13
J
This all looks
familiar by now
Saturday, June 15, 13
J
This is
familiar
too
Saturday, June 15, 13
J
Demo
Saturday, June 15, 13
Advance to the next slide if the demo fails...
Thank you for coming
Saturday, June 15, 13
J
Thanks for being so attentive. As a rather generous thanks for attending our talk, we’ve provided free iPads under everyone’s
seats.
OMG THAT GUY ACTUALLY LOOKED of course we didn’t do that
A
Once again, thanks for coming. Any questions?
Saturday, June 15, 13
J
Thanks for being so attentive. As a rather generous thanks for attending our talk, we’ve provided free iPads under everyone’s
seats.
OMG THAT GUY ACTUALLY LOOKED of course we didn’t do that

Mais conteúdo relacionado

Semelhante a A survey of robotics in Ruby

How to make_your_first_robot
How to make_your_first_robotHow to make_your_first_robot
How to make_your_first_robotLanka Praneeth
 
Raspberry Pi Hacks
Raspberry Pi HacksRaspberry Pi Hacks
Raspberry Pi HacksImad Rhali
 
How to make your first robot report
How to make your first robot reportHow to make your first robot report
How to make your first robot reportRamki M
 
When a robot is smart enough?
When a robot is smart enough?When a robot is smart enough?
When a robot is smart enough?Tomáš Jukin
 
Rust is for Robots!
Rust is for Robots!Rust is for Robots!
Rust is for Robots!Andy Grove
 
Museum of Computing Newsletter May 2013
Museum of Computing Newsletter May 2013Museum of Computing Newsletter May 2013
Museum of Computing Newsletter May 2013Donald Jones
 
Small Electronics for Your Makerspace (CLC Trendspotting - September 2014)
Small Electronics for Your Makerspace (CLC Trendspotting - September 2014)Small Electronics for Your Makerspace (CLC Trendspotting - September 2014)
Small Electronics for Your Makerspace (CLC Trendspotting - September 2014)ariannaschlegel
 
WebRTC: What? How? Why? - ClueCon 2013
WebRTC: What? How? Why? - ClueCon 2013WebRTC: What? How? Why? - ClueCon 2013
WebRTC: What? How? Why? - ClueCon 2013Mojo Lingo
 
Bytes - The Tech Magazine
Bytes - The Tech MagazineBytes - The Tech Magazine
Bytes - The Tech Magazinemareesh
 
Meet the Eclipse SmartHome powered Mars Rover
Meet the Eclipse SmartHome powered Mars RoverMeet the Eclipse SmartHome powered Mars Rover
Meet the Eclipse SmartHome powered Mars RoverMichael Vorburger
 
Top 10 robotics for beginners
Top 10 robotics for beginnersTop 10 robotics for beginners
Top 10 robotics for beginnersslulu226
 
How to build Open Hardware self-navigating car robot
How to build Open Hardware self-navigating car robotHow to build Open Hardware self-navigating car robot
How to build Open Hardware self-navigating car robotTomáš Jukin
 
Raspberry Tank - Barcamp Bournemouth 5
Raspberry Tank - Barcamp Bournemouth 5Raspberry Tank - Barcamp Bournemouth 5
Raspberry Tank - Barcamp Bournemouth 5ianrenton
 
DIY Electronics with Ruby
DIY Electronics with RubyDIY Electronics with Ruby
DIY Electronics with RubyMicah Wedemeyer
 
Building Droids with JavaScript
Building Droids with JavaScriptBuilding Droids with JavaScript
Building Droids with JavaScriptAndrew Fisher
 

Semelhante a A survey of robotics in Ruby (20)

How to make_your_first_robot
How to make_your_first_robotHow to make_your_first_robot
How to make_your_first_robot
 
Mag pi18 Citation "PhotoReportage"
Mag pi18 Citation "PhotoReportage"Mag pi18 Citation "PhotoReportage"
Mag pi18 Citation "PhotoReportage"
 
Raspberry Pi Hacks
Raspberry Pi HacksRaspberry Pi Hacks
Raspberry Pi Hacks
 
MagPi49
MagPi49MagPi49
MagPi49
 
How to make your first robot report
How to make your first robot reportHow to make your first robot report
How to make your first robot report
 
When a robot is smart enough?
When a robot is smart enough?When a robot is smart enough?
When a robot is smart enough?
 
Rust is for Robots!
Rust is for Robots!Rust is for Robots!
Rust is for Robots!
 
The Internet of Things (IoT)
The Internet of Things (IoT)The Internet of Things (IoT)
The Internet of Things (IoT)
 
Museum of Computing Newsletter May 2013
Museum of Computing Newsletter May 2013Museum of Computing Newsletter May 2013
Museum of Computing Newsletter May 2013
 
Small Electronics for Your Makerspace (CLC Trendspotting - September 2014)
Small Electronics for Your Makerspace (CLC Trendspotting - September 2014)Small Electronics for Your Makerspace (CLC Trendspotting - September 2014)
Small Electronics for Your Makerspace (CLC Trendspotting - September 2014)
 
WebRTC: What? How? Why? - ClueCon 2013
WebRTC: What? How? Why? - ClueCon 2013WebRTC: What? How? Why? - ClueCon 2013
WebRTC: What? How? Why? - ClueCon 2013
 
Bytes - The Tech Magazine
Bytes - The Tech MagazineBytes - The Tech Magazine
Bytes - The Tech Magazine
 
Bytes_final
Bytes_finalBytes_final
Bytes_final
 
ibm featureIbm ppt
ibm featureIbm pptibm featureIbm ppt
ibm featureIbm ppt
 
Meet the Eclipse SmartHome powered Mars Rover
Meet the Eclipse SmartHome powered Mars RoverMeet the Eclipse SmartHome powered Mars Rover
Meet the Eclipse SmartHome powered Mars Rover
 
Top 10 robotics for beginners
Top 10 robotics for beginnersTop 10 robotics for beginners
Top 10 robotics for beginners
 
How to build Open Hardware self-navigating car robot
How to build Open Hardware self-navigating car robotHow to build Open Hardware self-navigating car robot
How to build Open Hardware self-navigating car robot
 
Raspberry Tank - Barcamp Bournemouth 5
Raspberry Tank - Barcamp Bournemouth 5Raspberry Tank - Barcamp Bournemouth 5
Raspberry Tank - Barcamp Bournemouth 5
 
DIY Electronics with Ruby
DIY Electronics with RubyDIY Electronics with Ruby
DIY Electronics with Ruby
 
Building Droids with JavaScript
Building Droids with JavaScriptBuilding Droids with JavaScript
Building Droids with JavaScript
 

Último

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Paola De la Torre
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 

Último (20)

08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101Salesforce Community Group Quito, Salesforce 101
Salesforce Community Group Quito, Salesforce 101
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 

A survey of robotics in Ruby

  • 1. A Survey of Robotics in Ruby Josh Adams | @knewter Adam Dill | @adamdill Saturday, June 15, 13 A This is Josh Adam from Isotope 11 I am Adam DIll from Inside.com And how can it not be fun, were talking about robots!
  • 2. This talk has two parts • Survey / knowledge dump • Project narrative Saturday, June 15, 13 J: This talk has a couple of parts. The first one is really just a braindump - lots of good information on the library landscape. After that, we’ll dig into building a project together
  • 3. Part the first A Survey of Robotics with Ruby Saturday, June 15, 13 A So lets dive into the survey so you guys can see what is out there
  • 4. Robots? • A machine capable of carrying out a complex series of actions automatically. • (esp. in science fiction) A machine resembling a human being and able to replicate certain human movements and functions. • Robotics: The branch of technology that deals with the design, construction, operation, and application of robots. Saturday, June 15, 13 A: What is a robot? a robot is a force multiplier, it lets you take a simple action and cause a cascade of more complex decisions and actions JOSH
  • 5. Robots? • A machine capable of carrying out a complex series of actions automatically. • (esp. in science fiction) A machine resembling a human being and able to replicate certain human movements and functions. • Robotics: The branch of technology that deals with the design, construction, operation, and application of robots. LAM ESaturday, June 15, 13
  • 6. ROBOTS!!!1!!!one! http://www.flickr.com/photos/torek/3788181603/ Saturday, June 15, 13 J We all know what robots are, right? They’re awesome
  • 7. State of Hobby Robotics • Growing rapidly • lots of good mags • My 3 favorites => • Costs have fallen • Getting really approachable Saturday, June 15, 13 A mass production of sensors for phones has made this affordable while the maker movement has made this approachable approachable great references are available, make first among them
  • 8. State of Hobby Robotics with Ruby • http://artoo.io/ - Sinatra for Robots • https://github.com/hparra/ruby-serialport/ • http://www.rock-robotics.org - heavily c based, wired together with Ruby • right now, Python is better, and certainly more active, and more mature • long term, Ruby is a great choice Saturday, June 15, 13 A Artoo is like sinatra for Robotics. It’s definitely leading the pack right now. Serialport is an easy way to use serial devices, but there are some baud rate issues. Rock robotics is mostly C-based, but wired together with Ruby Python’s presently outpacing us in robots, but Ruby is the future. J Why is Ruby such a good choice, Adam?
  • 9. Why is Ruby a great choice? • All the normal reasons Ruby is great • DSLs • Metaprogramming • Developer happiness Saturday, June 15, 13 A All the normal reasons: DSLs, Metaprogramming, and you can have fun *writing* your robots, not just playing with them.
  • 10. Artoo.io Example Saturday, June 15, 13 J So we aren’t going to dig into artoo too much, but it’s definitely worth checking out. Artoo’s awesome and provides a common interface for various devices. It’s really made for controlling toys, which is fun and an easy way to start. It also gives you an easy way to roll a web API interface for your system. (It also uses Celluloid, which is easily my favorite Ruby library)
  • 11. Where to start? • Get easy wins early: • Sphero - about $130 • Parrot ARDrone - about $150 refurb Saturday, June 15, 13 A Don’t start with a giant project It’s very easy to get bogged down in a small hardware problem (resistor values, etc) J When should I learn Ohm’s Law, etc? A Right. So make sure to get some easy wins up front to help keep yourself motivated. I suggest you buy either a sphero or a Parrot ARDrone and just play with it.
  • 12. Sphero • http://www.gosphero.com/ • Bluetooth enabled ball • drives itself around • best dog toy ever • waterproof Saturday, June 15, 13 A This is a sphero. It’s basically just a ball with a motor inside of it. It’s bluetooth-controlled (via serialport), it’s a lot of fun and really simple. These are great for someone just learning to program to see real-world results of the code they’re typing, so it’d be good for teaching kids and keeping them engaged. There are some great KidsRuby Artoo resources for the Sphero
  • 13. Sphero with Ruby Saturday, June 15, 13 A Cool Sphero gems, and artoo supports it. You can see we’re just giving it a speed and a direction. It doesn’t get much simpler than this. (DEMO)
  • 14. Saturday, June 15, 13 A Here’s an example of using Artoo to control an armada (fleet?) of spheros What’s cool here is you can see how multitasking works with this evented architecture.
  • 15. Parrot ARDrone • http://ardrone2.parrot.com/ • Acts as its own wifi AP • Connect to it over wifi, it’s just a device with an IP • Send UDP packets to it • Stream video from 2 cameras Saturday, June 15, 13 J So the other easy toy is the Parrot ARDrone. This guy creates his own WiFi access point that you connect to, then you can just send him UDP packets to control him. He’s also got a couple of video cameras. Like we said, it’s $150 for a refurb and you can get a new one for around $250
  • 16. Parrot ARDrone Saturday, June 15, 13 J Jim Weirich wrote the `argus` gem to control it via Ruby Artoo supports it (DEMO)
  • 17. Rolling your own • What if you don’t want a ball or a quadcopter? What if you want to be master of your own fate? Saturday, June 15, 13 J So now you’ve got your easy wins and you’re still interested. What’s next?
  • 18. Microcontrollers A microcontroller is a small computer on a single IC containing a processor, memory, and programmable I/O. - wikipedia Saturday, June 15, 13 A Microcontrollers are essentially tiny computers. The real keys are they are on a single board, and have I/O.
  • 19. Microcontrollers!!!!!11!!! wtfbbqhax Saturday, June 15, 13 J The arduino showed up right around the same time Make magazine did, and they had a huge impact on hobbyists (though people that were doing microcontrollers before that will hate me for saying that). Still, it’s only a 16MHz device with virtually no storage, no networking, and it had to be programmed in C. Now we have a whole range of options, from the Beaglebone Black to the PCDuino, which offers a 1GHz chip, 1GB of RAM, a Mali 400 GPU, and an Arduino-compatible pinout (so you can take advantage of existing shields). Those are both far more expensive and power hungry than the almighty Raspberry Pi, though. With a RasPi, you get 700MHz, 512MB RAM, and networking for $35, as well as lots of GPIO to hook into. It just really hits a sweet spot.
  • 20. Microcontrollers!!!!!11!!! wtfbbqhax Arduino Saturday, June 15, 13 J The arduino showed up right around the same time Make magazine did, and they had a huge impact on hobbyists (though people that were doing microcontrollers before that will hate me for saying that). Still, it’s only a 16MHz device with virtually no storage, no networking, and it had to be programmed in C. Now we have a whole range of options, from the Beaglebone Black to the PCDuino, which offers a 1GHz chip, 1GB of RAM, a Mali 400 GPU, and an Arduino-compatible pinout (so you can take advantage of existing shields). Those are both far more expensive and power hungry than the almighty Raspberry Pi, though. With a RasPi, you get 700MHz, 512MB RAM, and networking for $35, as well as lots of GPIO to hook into. It just really hits a sweet spot.
  • 21. Microcontrollers!!!!!11!!! wtfbbqhax Beaglebone Black Arduino Saturday, June 15, 13 J The arduino showed up right around the same time Make magazine did, and they had a huge impact on hobbyists (though people that were doing microcontrollers before that will hate me for saying that). Still, it’s only a 16MHz device with virtually no storage, no networking, and it had to be programmed in C. Now we have a whole range of options, from the Beaglebone Black to the PCDuino, which offers a 1GHz chip, 1GB of RAM, a Mali 400 GPU, and an Arduino-compatible pinout (so you can take advantage of existing shields). Those are both far more expensive and power hungry than the almighty Raspberry Pi, though. With a RasPi, you get 700MHz, 512MB RAM, and networking for $35, as well as lots of GPIO to hook into. It just really hits a sweet spot.
  • 22. Microcontrollers!!!!!11!!! wtfbbqhax Beaglebone Black Arduino PCDuino Saturday, June 15, 13 J The arduino showed up right around the same time Make magazine did, and they had a huge impact on hobbyists (though people that were doing microcontrollers before that will hate me for saying that). Still, it’s only a 16MHz device with virtually no storage, no networking, and it had to be programmed in C. Now we have a whole range of options, from the Beaglebone Black to the PCDuino, which offers a 1GHz chip, 1GB of RAM, a Mali 400 GPU, and an Arduino-compatible pinout (so you can take advantage of existing shields). Those are both far more expensive and power hungry than the almighty Raspberry Pi, though. With a RasPi, you get 700MHz, 512MB RAM, and networking for $35, as well as lots of GPIO to hook into. It just really hits a sweet spot.
  • 23. Microcontrollers!!!!!11!!! wtfbbqhax Beaglebone Black Arduino PCDuino Raspberry Pi Saturday, June 15, 13 J The arduino showed up right around the same time Make magazine did, and they had a huge impact on hobbyists (though people that were doing microcontrollers before that will hate me for saying that). Still, it’s only a 16MHz device with virtually no storage, no networking, and it had to be programmed in C. Now we have a whole range of options, from the Beaglebone Black to the PCDuino, which offers a 1GHz chip, 1GB of RAM, a Mali 400 GPU, and an Arduino-compatible pinout (so you can take advantage of existing shields). Those are both far more expensive and power hungry than the almighty Raspberry Pi, though. With a RasPi, you get 700MHz, 512MB RAM, and networking for $35, as well as lots of GPIO to hook into. It just really hits a sweet spot.
  • 24. Raspberry Pi The Raspberry Pi is a credit- card sized computer that plugs into your TV and a keyboard. It’s a capable little PC which can be used for many of the things that your desktop PC does, like spreadsheets, word- processing and games. It also plays high-definition video. Saturday, June 15, 13 A Josh will go ahead and pass around the Pi [run through ports]
  • 25. RaspberryPi Setup • dd image to memory card • plug it all up (power last) • about a dozen setup questions • Debian LXDE setup (lightweight x11) • can also run Arch • straight console if that's all you want Saturday, June 15, 13 A setup is really easy, dd takes about 30 min, but other than that your running in under 15 min
  • 26. RaspberryPi: Running Ruby • install RVM normally • install  ruby via rvm • takes a long time to compile • 1.9.3 seems to work better, mostly due to compile times and gem compatibility • expect this to change in the coming months Saturday, June 15, 13 ((Josh setup RC car)) A Getting ruby running is about as easy, I used RVM, compile takes a few hours 1.9.3 seems to be the best right now, I expect this will change soon
  • 27. RaspberryPi GPIO and Tips • be careful with the Pi, need buffering, grab some transistors or a ULN2003 to protect it. • limited hardware PWM out of the box (1, shared with audio).   We’ll get you around that limitation a little later. • You need at least a 1-amp power supply, and you probably want a powered USB hub if you want more than kb/mouse. Saturday, June 15, 13 A
  • 28. RaspberryPi Tips (cont) • Get a Pi Cobbler breakout board to make your life easier • Cirago wifi/bluetooth dongle for $11, works great • Buy a nice case (or 3d print one :D :D :D) • Use a class 10 SD card if you can. dd is *slooooow* on a bad card. • There’s a camera module for $25. Saturday, June 15, 13 A explain pi cobbler is the ribbon cable attached to the one going around, it makes breadboarding easier cirago wifi/bluetooth seems to work great for basic IO and is low powered cases keep you from shorting it out, i put some heatsinks so i can overclock mine a bit class 10 sd cards are great, makes dd faster, and UX faster
  • 29. GPIO Examples using pi_piper gem, see: https://github.com/jwhitehorn/pi_piper Event driven Raspberry Pi GPIO programming in Ruby Saturday, June 15, 13 J
  • 32. Control schemes • Serial Ports • Connection Types • Bluetooth • USB • GPIO • Or my favorite, straight DRb over the network Saturday, June 15, 13 A lots of ways to control hardware, serial ports you ust write too like appending to a text file, can attach over bluetooth usb or gpio (J interupts) DRB
  • 33. Part the second Building something neat Saturday, June 15, 13 J
  • 34. Rubotnik (This slide intentionally left dumb) Saturday, June 15, 13 J
  • 35. So you have a RasPi • We made it blink earlier with `pi_piper` • What’s the next quick win we can get? • (note: most of the upcoming code is super quick-n-dirty) • Our goal is just to demystify this stuff - none of this code is beyond a Ruby Nuby. Saturday, June 15, 13 A So we got some easy wins with the toys earlier, and we took a microcontroller and made an LED blink What is our next steps? Going forward we have a lot of quick code, goal isn’t to provide code examples but to demystify how this works. No magic here.
  • 38. That was cool. Now what? • How’s about some more direct control? • Android -> JRuby <- DRb -> MRI -> RasPi -> Blinkenlight Saturday, June 15, 13 A So all this is cool, but how can we get into some more direct control of robots? talk through adding android and DRB J Something about how awful writing custom protocols is compared to DRb
  • 39. Saturday, June 15, 13 J This is the pickaxe example of DRb objects basically, completely standard...talk through class briefly
  • 40. So now android? • Eww, java • Not the worst thing in the world • Tiny code Saturday, June 15, 13 J You came to this conference looking for Java code and we know it.
  • 41. Saturday, June 15, 13 J This interface is literally just a button
  • 42. Saturday, June 15, 13 J I don’t think this is scary Java code, but it has lots of things I learned about jruby that will be helpful
  • 43. Use JRuby jars from ruboto project Saturday, June 15, 13 J
  • 45. if you don’t add stdlib to loadpath you spend three days crying Saturday, June 15, 13 J
  • 46. AsyncTask because no network on main thread (also, you need the INTERNET permission for DRb) Saturday, June 15, 13 J
  • 47. Cat’ing ruby strings together. With globals for control flow. Nothing unusual here. Move along. Saturday, June 15, 13 J
  • 49. RGB LED Saturday, June 15, 13 A What’s the next obvious step past a single red led? A single RGB LED. Let’s make it happen
  • 50. RGB LED • So now we have an LED, so what’s the next simplest way to ratchet up? Saturday, June 15, 13 A What’s the next obvious step past a single red led? A single RGB LED. Let’s make it happen
  • 51. RGB LED • So now we have an LED, so what’s the next simplest way to ratchet up? • RGB LED, controlled by a color picker on the android device, that changes color in realtime. Saturday, June 15, 13 A What’s the next obvious step past a single red led? A single RGB LED. Let’s make it happen
  • 52. RGB LED • So now we have an LED, so what’s the next simplest way to ratchet up? • RGB LED, controlled by a color picker on the android device, that changes color in realtime. • Problem: RGB LED requires analog levels, but we only have digital with pi_piper. Saturday, June 15, 13 A What’s the next obvious step past a single red led? A single RGB LED. Let’s make it happen
  • 53. Pulse Width Modulation Saturday, June 15, 13 A So you can use PWM to simulate analog levels, but you’re really just switching them on and off. If an output is switched on 10% of the time, evenly distributed, then it makes an LED look like it’s been sent a 10% max output signal. Later we’ll use them for logic level stuff, but for now we’ll just treat PWM like fake-analog.
  • 54. Pulse Width Modulation • RasPi only has one hardware PWM pin, and it’s shared with the audio output (so you can’t use PWM and play sound at the same time) • So you can run pi-blaster to get 8 PWM outputs. It’s a userland driver that hooks into the true PWM pin’s interrupt and uses it to drive any GPIO pin like it’s PWM • https://github.com/sarfata/pi-blaster/ Saturday, June 15, 13 J pi-blaster, up to 8 PWM
  • 55. Pulse Width Modulation • To completely turn off pin1: echo "1=0" > /dev/pi-blaster • To completely turn on pin1: echo "1=1" > /dev/pi-blaster • To set pin1 to a PWM of 20% echo "1=0.2" > /dev/pi-blaster Saturday, June 15, 13 A Here’s how you use pi-blaster - everything’s just a file, and you write commands to it
  • 56. Saturday, June 15, 13 J Here’s a really basic class representing our rgb led. I’m just showing the red channel code here.
  • 57. This class is actually like 200 lines long :- Saturday, June 15, 13 J If we’d used any metaprogramming at all here, it’d have been much smaller. I promised quick-n-dirty code right?
  • 58. Buuuuut • Turns out that most RGB LEDs expect the common leg to be high, and the channel-specific legs to be a modulated ground (our code assumed the common leg would be ground) • Luckily, Ruby’s awesome so when I ran into this when testing it took all of three seconds to fix it up. NOTE: I also had to run the 3.3V line to the common leg, then you’re just modulating the difference (so 100% duty cycle for a given leg means no voltage potential difference, or ‘off’) Saturday, June 15, 13 J
  • 59. ZOMG Saturday, June 15, 13 J Hey hey, object oriented programming is awesome. Anyway, let’s go ahead and see what the android interface for this project looks like
  • 60. Saturday, June 15, 13 A Just a basic color picker, nothing fancy here. As you change the slider, we want the led updating in real time
  • 61. Saturday, June 15, 13 J More java code. Last time we ran code each time you hit a button, but now we have a slider. At first I ran code on each change event from the slider, but it turns out DRb can’t handle 200 messages/second and it would get laggy.
  • 62. Timer Task that fires 20 times per second. That seems to be a sweet spot. Saturday, June 15, 13 J So my solution to this is to sample the UI 20x/second and send a message over DRb each time
  • 63. If you’re going this route, have a single method that accepts the state of the User Interface. Then handle it on the server side (rather than multiple messages, one per user interface component) Saturday, June 15, 13 J I found out later that apparently that’s what RC Controllers in the real world do anyway, so that was serendipitous. So there’s basically all the code, how well does it work?
  • 64. Saturday, June 15, 13 J Pretty darn well....
  • 65. So what’s next? • Let’s finish this project up with something fun. • You go to the thrift store, and you buy one of these bad boys for $2. This is the way to go for this stuff by the way - there’s a TON of old toys waiting to be awesome again. • Tank steering R/C base - this is the RAD2. Saturday, June 15, 13 A Alright, so we’ve got PWM control of a ruby process from android now. What next? Let’s finish up by building an RC Tank steering thingie... bullet points...
  • 66. Speed Construction • Take a Sabertooth 2x12RC ($65) • Add a RasPi • Add a 12V battery • Add a cirago wifi/bt stick • Mutilate a usb micro cable Saturday, June 15, 13 J Put all this stuff together aaaand
  • 67. Saturday, June 15, 13 J This is what you end up with
  • 68. PWM and the Sabertooth • So to control the Sabertooth, you send a PWM signal per- motor. • 2000us pulse width: 100% forward • 1500us pulse width: idle • 1000us pulse width: 100% reverse Mapped to 0..1 values for pi-blaster Saturday, June 15, 13 J Explain sabertooth logic levels, and show how we’re mapping them to pi-blaster levels
  • 69. -1.0 1.0 Saturday, June 15, 13 A Here’s the interface. Just two sliders, mapped from -1 to 1. Your standard tank steering controls
  • 70. Map those values from the last slide into our pwm output values for pi-blaster Saturday, June 15, 13 J
  • 71. This all looks familiar by now Saturday, June 15, 13 J
  • 73. Demo Saturday, June 15, 13 Advance to the next slide if the demo fails...
  • 74. Thank you for coming Saturday, June 15, 13 J Thanks for being so attentive. As a rather generous thanks for attending our talk, we’ve provided free iPads under everyone’s seats. OMG THAT GUY ACTUALLY LOOKED of course we didn’t do that A Once again, thanks for coming. Any questions?
  • 75. Saturday, June 15, 13 J Thanks for being so attentive. As a rather generous thanks for attending our talk, we’ve provided free iPads under everyone’s seats. OMG THAT GUY ACTUALLY LOOKED of course we didn’t do that