welcome to Morpheus chair the program
where you learn how to build robots like
these from your comfy chairs first of
all I would like to talk about seriously
about Anki robot so that the company
Anki has closed their doors or at least
they are doing so it's a really sad
topic because I really loved Cozmo and
vector and I think they were the best
commercial robots are very available
really for development and also for
their personalities
let's send Anki a positive message with
a hashtag #WeLoveYouANKI and telling
them what you have done how you really
loved their robots because of they really
deserve it another thing so in this
season 3 we're going to work with this
little bad boy so this little bad boy is
a pan tilt so you can move it you can do
your and you can do pitch and you can
control it with the Raspberry Pi so
what we're going to build with this is
we're going to control it with ROS
through the Raspberry Pi and we're going
to try to do face tracking face
recognition and more and more things in
this first episode what we're going to
do is set up Raspberry Pi so that we can
use it and move the servos and create a
simple Python class that moves the
servos and gives us a whole control for
for moving it and that way we will have
a perfect pan and tilt yeah
very cheap
and with a camera mounted on top without
further ado do not to do to the
workbench
so here we are in in this part I'm going
to show you how to set up your Raspberry
Pi so that you you can use this pan
until hat made by wave share if you want
to know more about the code and more
examples please have a look at their
github
it has examples for C++ for JavaScript
and so on so it's quite interesting but
here we're going to talk about how to
set up the system and how to execute a
program to move it to move the pan and
tilt and with Python yep
so let's go so the first thing is I've
generated this get public get for
everyone that you can download and here
you will find all the code that we
generate throughout this new season 3
yeah ok so the first thing is we have to
connect to our Raspberry Pi if you can't
do SSH then you have to set up the your
Raspberry Pi to be able to do SSH for
that I have the code here so let's have
a look so here in the repo basically we
have a setup folder and inside we have
this Ubuntu mate raspberry prices up and
here you have all the commands that you
have to execute to be able to do SSH to
the Raspberry Pi through your computer
and not and you you won't have to
connect a keyboard and connect the
Raspberry Pi to an external monitor and
someone so this is the bare minimum that
you have to install manually and with a
keyboard and screen connected to the
Raspberry Pi after that I think you we
won't need any more to be connected
physically to a screen I'll leave a link
to
some videos that I explained more in
depth and I show you how to do this
exactly okay the next thing is you you
can execute this once you have SSH
capabilities so first thing we connect
through SSH so there we go you have to
put the username and the IP and then the
password okay once you have it you're
inside the Raspberry Pi and here is
where the Ross setup comes into place
so we won't need it for this episode but
we'll need it
in the next episode so it's good to have
it already so you'll have to execute
this the script that installs ROS
kinetic and and it generates this
workspace so that you can put that the
code there yeah okay so we go to a can
workspace and inside here into source
and here I've downloaded the code from
the git repo
yeah you just clone it and you have
there so things that we have to do in
order to make this work so here I have a
tiny script that shows you how you can
set the Raspberry Pi to be able to use
the pan and tilt hat yeah so the first
thing is you have to edit this file
there you go and inside this file we
have to look for this parameter so we go
here I'm sorry there you go so you can
see there some so we are looking for
this eye to see arm so there you go so
we have only these two and what we have
to do is uncomment it and put on yeah
because normally you'll find it as so
very important this another thing that
we have to edit is this far here modules
and we have to add this eye to see
developer yeah doing these two things
and executing this command which
installs the i2c tools which normally
its installed pre-installed in Ubuntu
mate but just in case I put it here the
the rest the raspberry pie pan and tilt
should work I highly recommend that you
do a sudo reboot just in case and then
it should work okay so now I'm going to
show you the code to make it work so as
I told you in the official web page you
can find the github and inside it you
have code that you can use to test it
and I've extracted that code for Python
and I've placed it in this package pan
and tilt control in scripts main and
this is the original script which was
very very basic basically made it's it's
a good way to see
if it works you just have to execute it
and that's it yeah so if we go to until
and until control and we go to scripts
you see here we have the main you just
have to do Python main and it should
remove the penitent and there you go
yeah the only problem about this program
is that it's basic and also it doesn't
clean the connections yeah so what we're
going to do is create a class that
encapsulate everything and also add this
cleanup function and other testing
functions yeah so here we go let me just
I'm going to execute there you go
because otherwise I would have the
parent ill working and buzzing all the
time so let's have a look so I've
created this class which uses this same
method that the main example uses that
basically implements the communication
for this chipset a PC a 96 85 which is
chipset that basically encapsulates a
way of generating Peter PWM for
electronics it was four legs but also
it's used for servos so this class we do
the following we have an int method and
an delete method the delete method is
called when the this class is deleted is
destroyed the object of this class yeah
the instance of this class so here we
are cleaning up and this is really
important if you want
your pan until to stop buzzing and when
you're not using it okay otherwise the
first time that you execute this code
then it will keep on buzzing until use
you power off your Raspberry Pi so we
have the in it and in the init we
initialize this class for communication
with a chipset we set the frequency
which is 15 and don't change it it works
like that
that's it but this chipset in theory
supports 1600 but for servos place 50
yeah we set it here and then we
initialize it with angle 0 and 0 yeah
and we move the pitch and go so this
class moves executes they move your own
pitch and inside each one we set the
rotation for the servo 0 and several one
which is your end page that's it so this
is the only code that makes the pan
until move but it's really really simple
the other methods that I've placed here
are for testing and it's really
important because depending on your
servos and the luck that you have the
servos will have different ranges you'll
see it in the demo part that I will do
just when we finish this explanation but
basically not all servers work the same
way and some have higher limits others
lower limits and you have to test them
so it's really neat that you we have
some testing feature so just to explain
a bit we have the pitch and your range
which executes some movement in the
range from 10 degrees to 170 I assure
you that my servos can't do this so
especially that you
if you put it at 170
it just doesn't move and the worst thing
is that if you try to go back to values
that should work sometimes it doesn't so
bear that in mind the limits are really
important and you have to test it for
your application
so here we have for the Euro the pitch
and then we have also an input which you
just place an angle that you want and
the server moves to that angle and then
this circle test which is really neat to
see exactly the dynamics of your pan
tilt and it's a perfect test to know if
it's working or not
yeah and that's it we have some
functions here that use the object and
then we have the main that calls the
test that you want yeah so let's let's
see how this works
okay so the first thing that we're going
to do is execute the pen tilt move which
by default it has the circle test so
let's have a look so there we go
it starts buzzing and then we started
there you go in this case I've set it to
three repetitions there you go
fantastic so what if we want to do other
stuff like for example let's have a look
at the pan and tilt script there you go
so I want to do for example the input
pitch or the y'all first let's put the
jaw and let's call it this point your
crates and let's execute this sorry
let's execute it it setups every time to
zero zero position
yeah as you can see it's in the maximum
and that's why it's buzzing so much so
what angle for example let's put a
hundred there we go fifty 150
25 that's as you can see it works pretty
well but let's start let's try something
for example zero now one two three four
five six it's working pretty well yeah
there you go okay so we have the pen
until more or less working yeah and we
can do the same thing and as you can see
or here you see that it stops buzzing at
the moment that we close the Python and
that's because we're doing the this
delete function that we're doing here
sorry that we're doing here so it's
really really important that you do it
yeah and for example we can do all so
let's have a look we can play with the
pitch also so I'm going to play with a
pitch there we go example 110 160 35 10
25 you see that it didn't move so you
have to be careful with the the limit so
the minimum maximum limits or because
otherwise it could get stuck there you
go normally if you ask him to move in in
a very different position it will move
there you go let's both 30 20 you see
that it doesn't really move from when
you go to thoroughly it sometimes gives
a lot of problems yeah
so from 100 for example to zeroes
and moves there a hundred to 20 it seems
exactly the same so bear that in mind
yeah there you go
and that's quite it
that's all for today I hope you liked
the video please leave a like if you did
so and consider subscribing because we
publish videos every day about Ross and
robotics related topics and in the next
video we are going to move the robot
through ruffs so we're going to do a
node that subscribes the topic and
through that topic
we are going to control the pan and tilt
yeah so until then
King building King building building
building building building building
building building secretly little too
depleted to do
