Nerds Do Cool Things?

Tutorial 1: pyOSC + TouchOSC Tutorial

Hey there!

I’m going to be posting a series of tutorials on how to build / program a drone. I’ve been working on a few quadrocopters and a RC Car drone. So I’m going to take you through the steps of how I got it up and running.

Lesson 1: pyOSC + TouchOSC

GOAL:

To be able to get values from touchOSC (or any OSC software) from a cell phone to your computer. It’s simple and makes for interesting interactive programs. 

Requirements: 

1. An Android or iOS cellphone with touchOSC or comparable software.

Notes: I really like touchOSC because I just know it works, but if you can’t get past the $5 price tag, try out other free ones like Control for (Android/iOS).

2. Lastest release of python 2.x find it for your operating system here:
http://www.python.org/download/

I tested this small program on Mac OSX with no problems, then moved it over to the Raspberry Pi, which of course comes with Python preinstalled.

3. The pyOSC library, found here: https://pypi.python.org/pypi/pyOSC

4. If you don’t want to make the touchOSC template, then download mine that works specifically for this tutorial here: https://db.tt/bnxa0JkM

Tutorial:

Once you’ve got everything set up, we’re ready to go. 

First, make a folder for your OSC test program. Put it wherever you’d like. 

Next, copy the file “OSC.py” from your pyOSC download location to this folder. 

Finally, open up whichever application you use to write code (I use TextWrangler for Python and Xcode for other languages) and make a new file, call it something like “oscTest.py” and paste the following code into it:

You’ll need to modify a few lines to get it to work for your computer. First off, we need to modify lines 13 & 14. In 13, put the IP address of your computer. 

On windows this is found in: Control Panel < Network and Internet < Network Connections < (Your Connected Network) < View Status < Details

Yeah I know, windows makes it hard. 
On a Mac simply go to: Apple < System Preferences < Network 

On line 14 you need to put the IP of your phone. If using touchOSC it automatically listed on the settings page as “Local IP address”, if not find it under: Settings < Wi-FI

Last Step! Make sure that touchOSC has all the same settings. Host is the IP address of your computer (line 13) and the ports should be set to what it says in lines 13 & 14 respectively. (For this example it’s 7000 and 9000). 

Now just run the application!

If you installed python as listed above, then it comes with an application named Python Launcher. While it isn’t necessary to use it, I recommend it to start out with. So simply right mouse click on our code file “oscTest.py” and open it with Python Launcher. This should open up the command line and print “Starting OSCServer. Use ctrl-C to quit.” Then press buttons on your phone! The XY fader prints decimal values from 0 to 1 of where the cursor is, so you’l see something like: “X Value Is: .67898” and “Y Value Is: .34567”. When you get bored, hit “ctrl + c” and the application will close in the command line. 

What’s Happening?:

So this code may look intimidating, but it’s a nice example of python code, including a few functions that we call and some loops. 

First off, in lines 27-29 we create a client and a server, right there on the computer. 

When we press a button on the phone it is literally sending over the network the line “basic/joystick/<data>” So we want to be listening for just that message! 

This is done in lines 61-67. We simply add the functions that we want to listen to. If you want to build your own custom interface in touchOSC all you need to do is create the object and name it, then add another line similar to “s.addMsgHandler("/basic/joystick", moveJoystick_handler)” where the first element is replacement by what the object is called and the second is replaced by the name of the function you want to call. 

So again, what happens is this: we press a button, it sends that network message over Wi-Fi. Then since we are listening to it, it calls the function we defined above in lines 50-59. All we are doing there is simple taking the array called “Stuff” and printing it’s individual elements. 

Lastly line 74-84 simply create a loop that runs until we close it ourselves. Not too shabby! 

Now your ready to make your own templates in touchOSC and get your code to do cool things. 

Raspberry Pi VNC/WiFi Issues Resolved!

Wow! It’s been about 8-9 hours in the making but I finally got VNC up and running on my Pi so that I don’t have to kludge around with a monitor, keyboard and mouse. 

I had gotten stuck for 7 hours because:
1) My Pi is a public device from a Computer Engineering club so it already had some engine problems when I got it. 
2) I didn’t have a keyboard, so I was limited to setting up my WiFi through command line, which as I’ve seen from wayyyy too many forum posts is not the best option. Really, I would call it a last resort after how many posts I’ve seen. 

Lesson: At least at setup, get a Keyboard, what took me 7 hours to get nowhere, took me 2 hours at a slow pace. 

So my method was:
1) Download Raspbian from official page, format using the Pi SD Installer Command Line Tool for the Mac. Quite helpful. 
2) Have my wifi dongle in one slot, the keyboard and mouse in a powered hub and in the second USB slot. 
3) Set up WiFi using the GUI, worked like a charm. 
4) Set up SSH and VNC using the adafruit tutorials: 
http://learn.adafruit.com/adafruit-raspberry-pi-lesson-7-remote-control-with-vnc/overview

And last notes:
1) I am using VNC Viewer and it does work pretty well. I’m curious about controlling it on my iPhone, not sure if I would try Remoter or VNC as well. We’ll see if I really need it…. 

2) Tommorow we’re going to see if the Pi is really smart when I take it back to the club at college and try to connect VNC through their network. I hope it’s this easy again: Use GUI, find IP address when at College, then simply use that IP in VNC Viewer at startup. I think that’s the only bits…… I’m hoping. 

3) Really excited about moving on. Going  to try out my Python skills and program a bit and also get some simple GPIO work going on…. 

But for now, I sleep…… because that was a killer. 
-Aaron

And….. Reinstall Raspbian!

Honestly…… the Raspberry Pi seems like an amazing device, but they really need to build in some simple auto-configure scripts. I don’t have a keyboard, so I had to ssh in and change the network file manually and now it won’t read the network file at boot up at all……

All I want to do is connect to the internet, so I can update Raspbian and install VNC and get up and running with my laptop keyboard, but now that I’ve destroyed the network config file, I’ll just have to reimage my card.

So that’s my plan. Reimage the card with Raspbian, and use my newly found method of copying letters from the Midori faq page into others apps, in this case the WiFi config so I don’t have to mess with files…. hopefully that will just make my day….

Raspberry Pi Complaint

Was really excited to borrow a Raspberry Pi from InfoSec club, but I have a huge complaint….. why do I need a keyboard? We got rid of our last desktop computer 6 years ago….. I’m trying to set up SSH, but guess what, you have to type in commands in terminal…… I have a WiFi card for it to download a virtual keyboard or something, but you have to manually TYPE the network name. I need to borrow a keyboard or something…. 

Python First Impressions

Going to edit this as I go throughout the night:
1) The simplicity is hard to get used to after C++. Instead of “String” it’s “str” and instead of “else if” it’s “elif”. I like it, but gonna get some getting used to.

2) How do you concatenate things??? I’ve figured out strings, but rather I want to print things all on one line. So used to « operator in C. 

Figured it out: you can just use the ‘+’ operator but it all has to be strings which stinks because you have to cast everything that way. This is my solution for something simple in C:

print (“a = ” + str(a))
print (“b = ” + str(b))
print (“a + b = ” + str((a + b)))

Easier way? If you know of one before I discover it on my own, let me know!

TouchOSC + Python project

Just a quick write up. I’m currently running through the basics of Python using After Hours Programming. It may not be the most comprehensive, but that’s fine. I already know several languages, so I just wanted a quick run through and they do good at that. Really simple and clean. So I’m doing all that, messing around, then I’ll dive into some books / documentation.

My goal for the end of the night is to be able to write a simple app that allows me to send data from touchOSC to my computer using the pyOSC library. I’ll show this off to the InfoSec club tomorrow and see if we can get the same code running on the Raspberry Pi, then if we can expand that to the GPIO pins of the Pi to drive a simple DC motor. So theres the idea, looks like it’s already been done over at playwithmyled.com but there isn’t much documentation, so I hope to show you that more cleary as our team goes through the proccess. 

See you on the Flip 

Welcome Home

I haven’t posted on here forever because reality few people read these posts, but I’ve been thinking about all the cool stuff that I create and decided to expand my blog to even more themes…. if that were possible. 

So the project that will now probably be consuming most of my time because I have people to impress is  a Spy Drone project my school is doing. We want to get a spy drone up and running, add a healthy list of features to it, and more than anything make it hackproof. We plan on using the Raspberry Pi as the controller, which I’m not familiar with because I’ve been using Arduino. Anyways, looks like theres lots of Python going on with the Pi so I’m going to start learning it. See the Software section of my blog to check that out. 

Then I also added a Scripture Studies Section to my blog. It has nothing right now, but I do some serious studying and analisis of the Bible and Book of Mormon, so decided I would just share those documents I’ve created on there. 

Thanks,
-Aaron

Mission Pics

October 17, 2011

Answers to questions: 
1. No I haven`t cooked much here, a lot of the stuff is expensive like vanilla flavoring, and other things. We`re making snickerdoodles today though because one of the dying Elders in mi distrito wanted some. 
2. Besides the breakfast oatmeal, I don`t eat much. We have a very helpful ward that feeds us good meals on every day except for monday (p-day) and tuesday when we have district meetings. From them it`s usually un salada, which is rice and veggies with mayonasa, y jamon. I don`t usually eat a dinner because I putting weight just from those two. We excercise each day, but only within our apartments so it`s not much. I`m 72 kilos right now. Don`t think I`ll let myself get any bigger than that because I just don`t like the feeling, I feel physically limited, but there is no way to have energy and to not eat as much as they serve you. The awesome thing is we get U$250 ($15-ish US) reembursable of fruit and veggies each month because it will keep us healthy, so you better believe I take advantage of that and grab fresh fruit at the bigger markets once a week.
3. Package not here yet, it supposedly takes a couple of weeks, but I don`t know because we only get mail at district mettings on tuesday. 
4. Yeah, I was pretty shocked to hear that Steve Jobs died, especially considering that he asked to remain active on the board when he resigned. He truly was a vissionary, and I really hope that Apple can carry out his visions without him. Still a dream to work for them at some point in my life.
Haha. So all is well here in the Guay. I`ve learned that you just need to put your hardest into the work and find little things of home. Like the recycle bin I found outside a pet store. Yep, it`s from San Bernardino haha. A trashcan made it`s way from California to Uruguay. I tried to take a picture but I kept forgetting my camera and it wasn`t out today. Next time. 
In other news, it seems I have the luck of getting to see stuff that som missionaries never see. We decided to pass by la Familia Cuña on saturday and their abuello was there along with two of her sons, so we knew something was going on. We wanted to just have a quick lesson when I heard a pig squealing and later it`s dead body being drug out of the barn. Ha. So I asked them and they said they sold two, and they were going to cook the rest. So we watched them catch and kill the next 4 in the barn and then watch them remove the hair in the hot water (they do it with their hand), and then gut it. It was pretty interesting haha. They wanted to kill some chickens too so they killed two. Their 7-8 year old kids killed one and ripped off the head, so it was running around with no head…. then the dog got a hold of the head and enjoyed it haha. So que suerte. 
This last week has been pretty busy, but suprisingly not in the way that we wanted it. A lot of our appointments fell through so we would go finding and find less active members, which is pretty sweet. We`ve been working really hard with the less actives because there are probably 200 people on our records if not more. We met an hermana yesterday with 8 kids who were baptized and one that wasn`t, but wasn`t active for 7 or so years. So we`ll work on that. I`ve really like having the opportunity to sing the hymns a lot as well. We sing probably 6-ish times a day, and probably more. Our bishop yesterday dropped cane yesterday saying that he likes to hear the hymns and he usually hears very people worshipping the Lord in song. So he told them that if they weren`t comfortable singing, the missionaries could come by and teach them. Haha. I`m accepting that challenge. I have a small hymn book I got in the CCM that will serve me well. 
We`ve been doing a lot of service lately as well to make the members feel comfortable helping us. I`ve cut lawns with un asada, painted walls, and washed dishes. Everyone here builds their houses themselves and I really want to help one at some point. It`s making me want to build my own home too, just for the fun of it. Yep. That`s all the ridiculousness going on in Uruguay, I hope everything is well in SB and I will try to send more letters. 
Till then,
-Elder Chamberlain

October 10, 2011

So I have quite a few things to say. First off, Amanda emailed me and let me know that Steve Jobs died. How crazy! I hope I could ever live to work as hard as he did. 

So I have lot`s to share. One of the first things is my new funny stories. First, (I guess this isn`t a story) but I have started collecting alfajores. An alfajore is a candy with two chocolate crackers and dulce de leche (caramel mas o menos) in the middle (and some times other creme like peanut butter, or the bon bon creme). But they regard them as much more here and there are more than 130 (that`s the highest any missionary has ever got). I keep the wrappers and am hoping to get a bunch by the end haha. I have 16 as of today because I found some really cheap but rare-er Argentinian ones. Second, is a story that happened while we were out tracting about three days ago. We knocked this ones guys house, he didn`t answer but I knew he was there because I saw him walk back and forth twice across his open door. His dogs wanted us to play fetch them for a bit, so I did while I patiently waited for him to come out. He didn`t however so we went to the next house. As we knocked a woman coming back from her job as a teacher pulled up so we talked to her and set up a day that she would be home. While Elder Shaw was talking to here I saw the man from the other house get up on his fence, unfurl a communist flag, shake it three times, make the “I`m watching you” sign (by pulling down the bottom eyelid with your finger), and then shake it 6 more times to ensure I understood. I just laughed, waved, and then focused back on the woman. It was pretty funny. The crazy people we meet. 
Second off, a piece of advice I want you to pass on to every youth who is even remotely considering a mission. I found out that some of the missions of the church require that you have you`re seminary diploma`s. Why? Because in order to get the travel VISA more easily, some countries want you to have proof that you are truly a trained and educated minister. Thus, having a seminary diploma says “yes, this Elder studied for four years the Gospel of Jesus Christ”. I`m pretty sure this is true because Presidente George said something about it, I`ve just forgot to mention it until now. So it would be wise to get the diploma because it will give them the opportunity to go to so many more diverse places. 
Second, I`m excited to let you know that one of the investigators we are currently teaching is getting married. His name is Sebastian and he was dating a less-active member of the church. In order to get baptized he needed to get married and we continued to emphasize this in our lessons, even asking him to pray about it. So today, they went down to the court to take out a date. Here, weddings aren`t a big deal, you just go and sign a paper at the court with witnesses that you want to get married. So I`m excited and hope that I`m around when he get`s baptized. Sadly however, we still have two other investigators that also need to get married and they are going to be more difficult. They just keep saying things like, I don`t want to get married because then it brings up the possibility of divorce, as if it isn`t possible they could split without being married. No se. All I can is to continue to teach and hope they make up their mind, realizing that this is the everlasting Gospel of Jesus Christ, that it can bless them not only in this life but in the eternities. 
Also, Elder Shaw and I should be moving houses soon. We have the contract signed and the key, but we`re waiting for a better time. Mostly it is just Elder Opie who lives with us in the same appartment right now. He is dieing this change (leaving) so he wants to make sure it is a fun last change and his companion has been sick a lot lately, so we keep him company a lot.
I can`t remember what else I planned on writing before, I left my planner at the casa because we went to the Salto Exhibition today as a district for p-day. I suppose I`ll just reconfirm that I`m in an awesome ward. Obelisco is a really good ward, of the 70-ish is fairly active members we do have, they all have strong testimonies. During this Sunday this was quite obvious and nearly 40 or so of them got up and bore their testimony, one right after another. There is however, a lot of old people that can`t make it to church or simply inactive members. Elder Shaw and I are working on it though, we find one or two inactive families each day that weren`t recorded in the Area Book. 
I`d just like to share my testimony of the divinity of this Gospel. As Christ taught in Matthew to the pharises and scribes that sat by, there is no way that he could cast out Devils in the name of the Devil, because then the kingdom would be divided against itself. In the same way, this Church brings forth many great and marvelous works that testify of this Gospel. This restored gospel could have come from none other than God himself because otherwise, like unto the story, the kingdom is divided against itself. It is either right or wrong, and there are millions of members that will all testify of the same thing, that this is the true and everlasting Gospel. There is no doubt who will win in the end and people simply need to decide where they want to lay up thir treasures, on the earth, or in heaven (3 Nephi 13). Decide now what this Gospel is, what side you are on, find out by reading The Book of Mormon and following it`s invitation at the end of the Introduction (or Moroni 10) to pray about it`s truthfullness. I know that doing this will bring the spirit so fully as a witness that it is true, that this gospel was restored by the hands of Joseph Smith and that Christ`s kingdom is now once again upon the Earth. I bear testimony of these things, as I bear to everyone I teach, that this is the only true and complete gospel on this earth, that it has eternal consequences for choosing to follow it. Yeah, even the recieving of Eternal Life, the greatest gift afforded to all the children of men. 
Thanks for everything, 
-Elder Chamberlain. 
P.S. I remembered I wanted to share real fast how much it has been raining. Ridiculousness! I keep letting my shoes dry, and as soon as both are dry, another pair gets wet, so I`m stuck with one all the time. It`s been great. I`m thankful for that jacket the Stewart`s gave me. Pass that along.Gracias.