filmov
tv
NAO Tactile Head Python Tutorial

Показать описание
NAO Tactile Head Python Tutorial
Alright hi guys! And let’s have a look at this tutorial a python tutorial for the tactile heads and the colors the eyes color for the NAOs.
So and what we are going to do is a ignore this box here this is one of mine earlier so we can speed things up so lets create a brand new python box so right click and then create new and python ok so were gonna name this box Eye Light Blend and then what we need to do is we need to create a three new inputs for this box and they will have to be on bangs type so we click the come down here inputs and hit the plus sign and the first one we are going to have red all lower case make sure the type in bang ok then all box in click again we need a green one and make sure its bang again ok and hit plus sign and we need a blue one and make sure there’s the bangs on that then we hit ok and we have our python box all setup and ready to go on the inputs so the red, green and blue now we are using a tactile head so were just gonna bring this down here and the tactile head button were looking for is in sensing and there is tactile head drag it out there?
Now, we wanna connect up like so so we wanna put one here and left needle here and then we’ll see from the needles from the top of tactile head so we see this is the top a the front tactile head and this is the middle one and this is the back one so we see each one is connected we choose different color for it.
Now what I’m gonna do is I’m actually just gonna delete this and I’m actually gonna put the one I’ve made earlier so we can copy the code so this tut Isn’t hours and hours long just me writing out code for you so lets put that in there so again the top, the middle and the bottom button or should I say the front, the back ah the front the middle and the back button which should as go in the red the green and the blue input we just made on the python box.
So if we click into the box the script editor phase and what I want you to do is I want you to pause the video and input all of the text so we can get our python code and then I’ll quickly run through what it means so I’ll pause it now guys and type that all in.
So guys I’m guessing that you’ve had time and you have put in the code and written into your python history box.
So to put you guys through it the script contains the state consisting of three Boolean variables so this is the red, the green and the blue that we’ve input into it.
Boolean variables can either be true or false. So when you hit their buttons on the top of the NAO so the tactile head buttons ah we can toggle the corresponding variable using the not operator which performs negation so not true is false and not false is true.
So what we do is a we use the state variables to set the LED colors in the on input on the start method which continually loops and sets the eye colors. The colors are set by the normal 24 bit RGB value colors in the binary code this is done by the last 8 bits of the blue component. The proceeding 8 bits of the green component and the 8 bits before that’s on the red component. So if you have any paint programs guys you can quickly go in there and type in these variables into the color and color field and you will see the actual color appears so there in the hexadecimal it says 0XFF and four zeros is red 0x two zeros two F two 0 is green and 0x four 0 and two F is blue. You also notice there is a bitwiser or operator so this is the vertical bar here so this takes the two binary numbers for each bit if the bit is set in either number it is set in the output.
Alright hi guys! And let’s have a look at this tutorial a python tutorial for the tactile heads and the colors the eyes color for the NAOs.
So and what we are going to do is a ignore this box here this is one of mine earlier so we can speed things up so lets create a brand new python box so right click and then create new and python ok so were gonna name this box Eye Light Blend and then what we need to do is we need to create a three new inputs for this box and they will have to be on bangs type so we click the come down here inputs and hit the plus sign and the first one we are going to have red all lower case make sure the type in bang ok then all box in click again we need a green one and make sure its bang again ok and hit plus sign and we need a blue one and make sure there’s the bangs on that then we hit ok and we have our python box all setup and ready to go on the inputs so the red, green and blue now we are using a tactile head so were just gonna bring this down here and the tactile head button were looking for is in sensing and there is tactile head drag it out there?
Now, we wanna connect up like so so we wanna put one here and left needle here and then we’ll see from the needles from the top of tactile head so we see this is the top a the front tactile head and this is the middle one and this is the back one so we see each one is connected we choose different color for it.
Now what I’m gonna do is I’m actually just gonna delete this and I’m actually gonna put the one I’ve made earlier so we can copy the code so this tut Isn’t hours and hours long just me writing out code for you so lets put that in there so again the top, the middle and the bottom button or should I say the front, the back ah the front the middle and the back button which should as go in the red the green and the blue input we just made on the python box.
So if we click into the box the script editor phase and what I want you to do is I want you to pause the video and input all of the text so we can get our python code and then I’ll quickly run through what it means so I’ll pause it now guys and type that all in.
So guys I’m guessing that you’ve had time and you have put in the code and written into your python history box.
So to put you guys through it the script contains the state consisting of three Boolean variables so this is the red, the green and the blue that we’ve input into it.
Boolean variables can either be true or false. So when you hit their buttons on the top of the NAO so the tactile head buttons ah we can toggle the corresponding variable using the not operator which performs negation so not true is false and not false is true.
So what we do is a we use the state variables to set the LED colors in the on input on the start method which continually loops and sets the eye colors. The colors are set by the normal 24 bit RGB value colors in the binary code this is done by the last 8 bits of the blue component. The proceeding 8 bits of the green component and the 8 bits before that’s on the red component. So if you have any paint programs guys you can quickly go in there and type in these variables into the color and color field and you will see the actual color appears so there in the hexadecimal it says 0XFF and four zeros is red 0x two zeros two F two 0 is green and 0x four 0 and two F is blue. You also notice there is a bitwiser or operator so this is the vertical bar here so this takes the two binary numbers for each bit if the bit is set in either number it is set in the output.
Комментарии