Hi everyone and welcome to how program your NAO robot with Python tutorial video number 1. On this tutorial we are looking into the first basic steps on how to use Python to program your robot. So if you want to learn the first steps to being a programming robot genius, then stay tuned.
Hi guys! I’m Philip English from robophil.com. Now on this video we are looking to teach you how to begin programming your NAO with Python. The NAO can be programmed using several programming languages, including C++, MATLAB, JAVA, LabVIEW and Python. So instead of using the drag and drop boxes in the Choreograph, we are now going to get our NAO robot to do some speech using coding.
Right, hi guys. Today we are looking at how to do some python coding. So we are going to get our NAO robot to speak using Python.
So the way we do this, jumping straight into it.
First of all, we are going to check our NAO. So let me just lift up his arm to make sure he is connected. Yeah, there we go. He is connected. That is what we want.
Now we see in the main robot section as well, he is all connected.
So Python. So what we want to do is we first want to create a box that we could put our python code into. This box will make our robot speak in. Speak “Hello”. “Hello I am a robot”.
- Right click the main section box and go to “add new box”
- Create a name for the box
- Input main image
- Select the type of box
So this time we are having a look at the script. So we go into the scripts and we click ok. And there we have our NAO little box. Now if we click into it, we have the python code. So this is what we are going to change. You can see it has already popped out there. So obviously, it is one of the features of the Choreograph is that you don’t have to be… It doesn’t have to be separate. It can be any kind of little box. I do actually want to separate which is quite nice. There we go. So just drag it out so it separates just so I could show what is going on. If you pick it up and hover over a particular part of the Choreograph window is it will just pop in there so you can have a bit more space if you are using the main panel. So what we are going to do is we are going to change some of the codes and we are going to get our robot to speak.
- Double click the box
- Select the piece of code you need to alter to get our robot to speak(“def onInput_onStart(self)”)
- Take out the pass section
- Type in “ttsproxy = ALProxy(“ALTextToSpeech”)”. (Make sure you get the comment in there).
- Underneath that, we are going to put “ttsproxy.say” and add the comment “Hello, I am a robot”.
Right! So there we have I just taught you in there. It is a very easy basic tutorial to start with. And the first line could create an object that gives us access to the robot’s text to speech capabilities. This object is assigned to the variable ttsProxy. We can access the object later through the name ttsProxy. So the top line here which I am going to mount which and the alspeech is there. The second line calls a different function site. Got to say that, long is the object we just created. This function takes an argument “Hello, I am a robot” and then he uses a string or sequence of characters between two double quoted marks. The robot will speak the string that will pass to the say message aloud. So obviously this is what we want to get our robot to say down upon. So, there are your simple first steps into python and choreograph.
Now if we click out this. It is in there. If we connect up to our robot as normal, we haven’t gotten the modes on could we are just speaking here. It should pop up here as well and if we hit play. “Hello, I am a robot” (robot speech). So there we go perfectly working. So if I hit it again. “Hello, I am a robot”(robot speech). So again if you want to go back in here and change it, you can extend it out here. “I’m a robot called Philip”. And it would come out again. “Hello, I am a robot called Philip”(robot speech). There we go. So we see we sort of drag it in the normal say boxes and type in into there. Instead of having lots of other boxes in there, you can just simply have one box. This is what the programming python is all about. Instead of having lots of drag and drop boxes in there, you just have one box that has all the codes you need so it makes things tidy and neat and obviously it makes the robot work a little bit faster as well.
Brilliant! That’s it guys. Thanks very much.
Well done guys. You can now get your NAO robot to talk by using your python programming skills. Now have a play with it’s behavior to see if you can get your NAO to say a longer sentence or maybe even sing a song. Have a play guys and use your imagination.
If you liked this and want even more free videos, tutorials, news and information, then please us at robophil.com where you can download the latest free ebooks and get insider information and techniques on how to become a robot expert.
Now if you liked this tutorial and you want to see the next one in the collection then please hit the subscribe button and keep up to date with the latest videos that come out. Please have a look below as well where I put the related links of this video as well as other information about the NAO robot. If you have any questions or you want to see any other related tutorials then please write me a message in the comment section and I’ll see what I can do.
Thanks guys and I will see you next time!
Python Programming your NAO Robot Tutorial Video 1 YouTube: https://youtu.be/Djzb8c41qbk
Philip English: https://philipenglish.com
Sponsor: Robot Center: http://www.robotcenter.co.uk