Hey Guys!
It's Mike from The Geek Pub.
Today we're going to give a little update
on R2-D2 and I am going to talk to you about
my control system.
OK.
So when I first went to build my R2-D2 I went
and researched all of the forums and what
I found is that most of the people building
R2-D2s are using what I would call rehashed
ten year old technology, and I don't mean
that in a bad way because what they're using
works well and its basically just a rehash
of old model airplane controllers.
I wanted my R2-D2 to be based on something
more modern so that I could control it via
software.
I wanted to be able to use things like XBOX
and Playstation controllers, and I also wanted
to be able to interface it with things like
iOS and Android apps as well as maybe even
my home automation system.
R2-D2 is going to eventually live in my theater
room and I wanted to be able to when you open
the doors to the theater room and you turn
things on I wanted R2-D2 to be able to wake
up and do things and then when you play the
movie I want him to go back to sleep.
So I wanted something a little bit more modern.
So the path that I originally went down was
simple to use a Raspberry Pi and so I thought
well the Raspberry Pi has GPIO and it can
run Python and all of these little things
that make it the perfect platform for running
R2-D2.
What I didn't really think about and as I
started doing more research I realized - so
in the dome for example there are something
like 20 plus servos just to control all of
these little bitty parts the holoprojectors
and all of those things and that doesn't even
include the LEDs, the displays and all of
the other stuff that goes on in the dome.
And so I realized quickly that I was going
to need something additional and so I decided
I was going to do a mix of Raspberry Pi as
the center brain and then Arduinos sitting
in different locations within R2-D2.
It's sort of like an octopus.
So.
If you don't know an Octopus has one kind
of single master brain and then it has these
little ancillary brains that control each
leg.
And so brain kind of sends a command if you
will to those other brains and then they figure
out how to self navigate those legs on their
own.
And so the system that I have built is very
similar to that and I am going to walk you
through it.
OK.
So let's talk about how this control system
is put together.
First we start with the Raspberry Pi.
This is where my Astromech core software runs.
It has all of the subroutines and functions
and monitors everything happening within R2-D2.
It also handles all input devices such as
the PS3 controller, my home automation system,
or a smartphone app.
Since the dome has to move, there is something
called a slip ring between it and the body.
The slip ring lets a small number of wires
pass through, and allows them rotate within
the head.
This keeps the wires from getting tangled,
but it also means I have just enough of them
for power and data.
Do to that limitation there is an Arduino
Mega 2560 in the dome.
This Arduino is responsible for controlling
all of the devices located inside the dome
and reporting their statuses back to the Raspberry
Pi.
It's connected over the I2C bus using just
two wires.
In the body is a second Arduino Mega 2560
also connected to the I2C bus.
It's responsible for controlling all of the
body servos.
Also in the body are are two motor controllers.
One for the dome, and one that controls the
two drive motors.
These are Pololu I2C motor controllers, and
hence also live on the I2C bus.
This design makes it very simple to add or
remove devices, and I have multiple options
for doing it, whether it be GPIO on the Pi,
digital IO on the Arduinos, I2C, or even wireless.
Now.
The next thing I needed to figure out was
how to make all of these devices talk to each
other in a consistent manner.
What I came up with is a simple Astromech
Command Language or ACL.
It works like this.
Every command starts with a # (or hashtag
for you young people).
Following that is a single letter that designates
something specific.
D for dome, B for body, M for media, and Z
for motor controller.
I'm sure I will add more as I go.
I've just recently added S for a sequence
of commands so I can make R2-D2 do little
shows.
Followed behind the command is a string of
parameters.
For example #DDP01OP is the command to open
dome panel one.
#DHP01CT tells holo-projector one to center
itself.
#BDD+055 tells the dome drive to turn left
at a speed setting of 55.
So all of those commands live in what is called
a mapping file within the Astromech Core and
they are all assigned to individual things
like buttons for example and this one is assigned
to a joystick which turns the astromech head.
Eventually, like I said, when I have an API,
anything - literally anything will be able
to send those commands to R2-D2.
Of course they will require authentication.
So that's a basic update on how my astromech
system works.
For those of you who are wondering (woo hoo!).
So.
For those of you who are wondering I will
eventually open source this to the public
but for now its in such a state of disarray
because it is in the early stages I am not
going to release it.
But I suspect within a few months I will have
an early version out there that everyone can
use.
So that's it for this video.
If you want to stick around during the credits
I am going to give just a little bit of 
a tour 
of R2-D2 and talk to you 
about him.
