Hi everyone and welcome to how to program your NAO robot with Python tutorial video number 5.
On this week’s tutorial, we’re looking in to how to control the joint angles using Python. So if you want your robot to nod to the beat, then please stay tuned!
Hi guys! I’m Philip English from robophil.com, and on this video we’re looking to teach you on how to program your NAO robot to use his head and head pitch to control the robot neck with python. So instead of using the drag and drop box system in Choregraphe, we will implement a Python behaviour.
Hi guys! And welcome to head nodding tutorial, so he can nod his head to the beat, or get in to say yes or no. So what we’re going to do, first of all is, just to let you know I upgraded my NAO to the new version of OS and new version of Choregraphe, so it looks a little bit different with the behaviour side, and there are few extra functions here and extra buttons, and I will make an extra tutorial jus to cover the new feature, I think a lot of you will probably using the new version.
Jumping straight in to this.
* Right click and we will “Create a new box”,
* Create a Box (as you can see in the new Choregraphe we can now get full options, before we use to go in there and saw the option inside the box but now it is put directly).
* Click Python (so click python, as we are doing python tutorials)
And same again, we want to just put a name in there. so I’m going to put this
* Name : Nod Yes
* Hit the OK Button
and then we have our little python box as before, what I’ve actually done is I already made one over here, because you have to Jot in a lot of code here, what we can do is to simply pulls the video and jot in the code. This video is not minutes minutes long, and there should be a fast way doing things, so I’m just going to delete this one.
* Delete the selection
Here is the one i made earlier, I’m Going to connect the noodle up, as we always do,there we go, and click in to it. So if you pulls the video now and if you can write this in to the Python box
*Write the code from the video
And give it a few minutes and then if you restart the video and then we can carry on because I need to write it and test how it goes. With the virtual NAO, as it works today I have to plug it to the main one, but because we have to see if it is nodding his head up and down or right to left on the virtual NAO. I can’t understand or maybe it is unnecessary.
to go over what I have done, assuming that you have done it (Write the code). So again as I said before we are using the head and we are using the head pitch, the head your is what turns the robot from left to right, and head pitch is what turns the robot head up and down
Now the angle interpolation, we have i here and here “notion.Proxy.angleInterpolation(names, [0.0,1.0], times,True)” this interpolate the NAO’s joints and it works by using four parameters.
Starting with the name of the joint, again it is looking if it’s head your or head pitch, and it is looking for the angles in radians, they actually want to move the right way of the ead, we will just put 1 in here.
it is looking for the time, again the time is right here, it’s 0.5 seconds is how fast that we want
our NAO robot to shake his head.
also the joints position, whether they are absolute or relative, lets have him absolute, so we set
TRUE function here.
now the variables in the parameters, are basically lists of angles,
so what the robot is going to do is to face his head straight forward, and then he’s going to go UP,
and then he is going to face his head down, and then he is going to set his head straight forward again.
We are controlling the head pitch joint for this one, to get this robot move UP and DOWN,
then we quickly try the head yaw so we get to move left and right.
the “for i in range(3)” is the increment for the variable for the “i”,
basically if we got 3 here, so he is going to nod his head 3 times, so it is going to go from 0-1,1-2, and 2-3.
and you can see he’s shaking his head 3 times.
you can increase the mount here.
so what are we going to do, is we are going to give it a go.
it is already scripted there.
we hit the play button, and we should have our robot nodding YES.
[actual nodding of the robot]
so there we go, we can quite clearly see it, and that’s working perfectly.
play it again.
yes,brilliant,it is perfect.
so the reason why went in to this python box instead of doing it in Choregraphe,
is that the less boxes you have in Choregraphe the faster the robot will run,
and the smoother it run as well.
everything is in coded format rather than the box format, you got nice and smoother program working faster,
and of course that is what we want for our faster robots.
so what we are going to do is,
now we have done heads nodding yes or no, I am just going to copy this and paste it.
then go to the edit box and call going to call it “Nod No”
*Click Edit Box
*Name : Nod No
then we going to get rid of the noodle there, cut that.
and connect it up to this noodle.
then we click on the box and copy the code across
so what we are going to do now is we want to get the robot to shift his head from left to right.
so we change the head yaw instead of the head pitch.
so what we do is we come here we make that 1, and make that 0,
and then we make this -1,and make this 0 here.
*notionProxy.angleInterpolation(names, [1.0 , 0.0], times, True)
*notionProxy.angleInterpolation(names, [-1.0 , 0.0], times, True)
and that should be it, lets click that play button
[actual testing of the robot]
there you go he is saying No.
our robot is not agreeing,
oop a non agreement robot
so what we can do is to play with the timing as well.
so this is the section here.
if we bump this up to 1.0, and 1.0 here
* times = [[1.0] , [1.0]]
and then hit play.
as you can see it is much slower, you can increase that and decrease it
depends on what your using the nod and head for,
you can use it for music beat, quick nodding sample. that is the front
see if your using it to get his head to the beat of a certain music tune,
You can play it through tune and see if it works.
So that is it guys, thank you very much
Well done guys, you can now get you NAO robot to nod his head to the beat of any tune
by using python programming skills.
now have a play with its behaviour to not only get to nod his head but to get his arms to move
to the beat as well. have a play guys and use your imagination
If you like this and want even more fee video tutorials,news, and information.
then please visit us at robophil.com. You can download the latest free ebooks
and get insider information and techniques on how to become a robot expert.
Now if you like this tutorial, and want to see the next one in the collection,
please subscribe and keep up to date with the latest videos that will come out.
Please leave comments below, or put links relating to these videos, as well as other information about the NAO robot. If you have any questions and want to see any other related tutorials, then write your message on the comment section and let me see what I can do.
Thanks guys and see you next time!
Python Programming Your NAO Robot Tutorial Video 5 YouTube: https://youtu.be/f_zzxwOvRWA
Philip English: https://philipenglish.com
Sponsor: Robot Center: http://www.robotcenter.co.uk