My 2 cents on sharing data…

Well, its been a while since my last post due to AP exams, robotics world championships, and internship, but I was finally able to get around to thinking about my latest idea: Sharing Data (literally).

Essentially, my idea was to make a replacement for Dropbox (a popular sync utility used by my robotics team) and make something that gives us a lot of data. Well, I thought about it for a while and realized that the only thing that can be better than Dropbox is having unlimited space for free. I asked some of my friends about this thought and besides asking whether I was crazy, they emphasized that the only way I could do that was by having tons of servers.

I thought of this and realized that rather than having a ton of servers, the better approach to this would be to pool the space in our friends’ hard drives to make something that is very large.

The Game Plan:

Syncing with this program (which I will refer to as “monkeySync”) would be the same as dropbox. However, users will be able to choose any folder and tell the program to sync that folder with all their devices. Another difference is that the user will have access to unlimited data. The only catch would be that 1/3 of the amount they put into the cloud will need to be shared for this program. Essentially, the data you upload into the cloud will be fed into another user’s computer and 1/3 of that data will be used for someone else to put stuff in your computer. This way, your data can be accessed any time when their computer is on and their data can be accessed whenever your computer is on.

Some Problems:

1) What if the other person’s computer is off?

Fear not, your data will be stored in hundreds of computers around the world so anytime you need to access your data, you just need to swipe it off one of the computers.

2) What if the other person looks at my data?

In order to prevent the other person from accessing your data, every file is split apart, compressed, and encrypted using the Rijndael algorithm (a.k.a. AES). This way, they cant decrypt it in a million years…

3) What if they delete my data?

Since your data is stored in hundreds of computers, one being deleted will be automatically re-uploaded into another computer to prevent data loss.

4) What if their data speeds are like slugs?

The main “monkeySync” server will be a middle-person for your syncing, so it will make sure your data is synced with a computer that has a less than or equal to data download and upload  speed as you. This prevents any bottlenecking of the data.

More Coming Soon…

 

 

Numerical Integration on the Lego NXT

A couple of weeks ago, our FIRST team came across the problem of having slipping wheels giving bad encoder values. Since our whole autonomous runs on the idea of having accurate encoder values, I thought that it was about time to do something about it. I then suggested that we revisit the Gyroscope sensor to make our turn values using that.

Unfortunately, the gyroscope gives out values of angular velocity and we needed to use that to find the current angle of the robot. To do this, it was fairly simple to integrate the value of velocity over time to get the angle diplacement.

The mathy part (do try this in your home)…

After some thought, I saw that the gyroscope can give back velocity “v” every “t” seconds and we can use that to find the angle “A”. To do this, we simply take v*t=A.

The v will be the value of the gyroscope’s output. The “t” will be the time difference between each interval. The A will not be the angle (rather, it will be the CHANGE in angle). We simply need to add the change to a total (which will initially start at 0 degrees).

After writing some initial code, we discovered that everything was still slightly off (the angle was off non-linearly). However, I re-looked at the code and found that the time we used was a constant (which we arbitrarily chose). The best method we should have used was a timer which reset each time a cycle completed and started whenever a cycle was started (this timer measured in milliseconds).

After implementing this idea, our robot now makes perfect 90 degree turns without the influence of friction or other robots on the field. For example, if a robot were to hit us before turning 90 degrees, it will still turn until it reaches the 90 degrees we told it to.

 

 

 

Robotics Involvement video

Hi!

A few days ago, I made a video about me and my involvement with FIRST to show others and I decided that it would be best if I could share the video on my blog as well. So, with the permission of all the individuals used in my video, I am now posting it below as well.

After making this video, I did also learn a few things:
-How to use Adobe fireworks
-The impact of the community service which our team does
-The emphasis of community involvement in FIRST robotics
-The great feeling of watching something you made :)

 

Credits:

-John Pilvines (Thanks for taking awesome pictures that I could use!)

-Team Unlimited Website (http://ftc0001.org/)

-Tony Simonetti (thank’s for the mic. and script help)

-First Robotics Team (Vivek, Manasa, Frank, Nate, Dan, Puya, Vindhya, Srinithi, and past FTC participants of 2009-2010)

-Coaches of the FIRST Robotics Team

-John Peabody and Competition Referee (for their thumb’s up shot)

 

 

Driving a cd-rom spindle motor with arduino

An innocent cd drive ready to be taken apart

An innocent cd drive ready to be taken apart

As I looked around the house for things to take apart, I came across a cd drive similar to the one above which was not being used anymore. After some research, I discovered that the center motor in the cd drive is a brushless dc motor (also caled BLDC). This is a special motor which requires a pulse width modulated wave in order to make it move. Luckily, I had a screw driver, a soldering iron, and an arduino to take it apart and use it for science (muhahahaa…)

 

I began by opening the bezel and taking out the circuit board out. Since it was an older model, it was also filled with gears I needed to remove from the motors. After salvaging everything, I ended up with 4 brushless dc motors. I decided that the spindle motor would come in handy for my next project (a mini-cnc drawing thing).

After googling for an hour, I came across various posts describing that a special transistor/ic is necessary in order to control the motor using an arduino. Unfortunately, TI doesn’t allow samples through its website anymore so I need to call them to get a sample of the specific motor driver IC (the DIP version because those are easier to solder on to).

However, I decided to make my own version of the IC using 6 transistors wired as 3 Half-H-Bridges (look up an H-Bridge in google…). Here is a nice overview on controlling BLDC motors. These things need to be controlled via PWM (pulse-width-modulated) waves, which are square waves generated from the 13 outputs coming out of an arduino microcontroller.

After wiring everything according to the schematic below and using the code posted below, it just made the motor twitch in place (rotating back and forth about 15 degrees).

Videos

Pictures

That's a giant breadboard!

 

Better Picture...

Schematics

-Coming soon…

Arduino Code

-Coming soon…

 

Converting my old computer’s power supply to a lab power supply

Background Story:

Now that midyears just ended, I thought that it might be cool to come up with something interesting to do with my pile of electronics parts in my basement. At first glance, I realized that the most valuable thing to take apart would probably be in my super-old dinosaur-age computer which used to run windows 95. I looked at the specs and at first I thought of possibly  using it as a web server of some sort but then realized that I have enough of those already. Then, I finally came to the conclusion to just take it apart and use the 20A power supply as a nice regulated power supply for my many 12v and 5v projects.

The Idea:

Interestingly, the power supply comes with a diagram which says that the red wires are for 5v+, yellow wires are for 12v+, White wires are for the 5v-, Blue wires are for 12v-, and black wires are for grounding purposes. In fact, the coolest thing was that the power supply was also connected DIRECTLY to the computer’s power switch, which gave me the opportunity to use the switch from the computer as a way to control the power supply. As an extra precautionary idea and for decorational purposes, I decided to desolder some orange led’s (yes, orange…) from an old phone and hook it up to the 5v- and ground lines on the inside of the power supply using a 90ohm resistor (I only had 2 180ohm resistors so I put them in parallel to get approx. 100 ohms). Now, whenever I turn the power supply on, it will also glow an orange led (which is pretty cool).

 

Precaution: (READ THIS!!!)

Before I opened up the power supply, I made sure to do my homework on how it works first. First of all, since the thing hasn’t been turned on in nearly 2 or 3 years, the capacitors in there are assumed to be discharged. However, I still made sure it was safe by using a multimeter to check the voltage of the capacitor before laying my hands on the circuitry of the supply’s board. Second of all, if you are doing this, you have to be absolutely sure you know how to check the capacitor’s voltage or to discharge it manually (pretty simple if you use some google action). Also, make sure not to connect the led directly to the 5v because you will fry the led (you must have a 100ohm resistor if it is a normal 3.3v led).

 

Steps:

1)Unseat the power supply from the computer. If it is relatively new, it will be pretty easy. If it is super old, you will need to remove or cut the power switch from the computer’s bezel because it is wired directly to it.

2)Make sure everything is disconnected (you should probably do this before…)

3)Make sure you leave the power supply off for like a few days in order to drain the capacitors. If not, you need to ground the capacitors to release the charge in them (this can potentially kill you).

4)Unscrew the power supply

5)Solder the positive terminal of the led into the 5v+ line via a 100ohm resistor in the middle. (Make sure to look up which side is positive).

6)Solder the negative terminal to the ground connection of the power supply

7)Store the led in a safe area inside the power supply near the holes (to be visible from outside)

8)Screw everything back in

9)Plug in the cable into the power supply and press the power button (if you have one…)

10)Enjoy your fancy lab power supply with a cool indicator light.

Now, if you want, you can also cut the tips off the cables and connect them to a fancy connector you can get at radioshack. Next time you need it, you can just hook up a cable to the connector and the other end to a breadboard and you have a regulated power supply for good use :)

 

Here are some pictures:

My workbench

Cool stuff...

Arial view of workbench

Arial view of my stuff...

 

 

The power supply taken apart

Oh look! it's a capacitor...

 

 

Everything's connected again...It works!Super cool trigger switchIt's alive! (proof)

 

It's alive! (proof)

 

Everything's connected again...

It works!

Super cool trigger switch

 

 

Neural Networks for FIRST robotics – Part 2

In my previous post, I made a fairly thorough post detailing what a neural network was. Now, I was to share some of my insight into possibly using this technology with FIRST robotics (which I am currently a lead programmer for).

Some thoughts

Path finding algorithm

automatic creation of autonomous program

learn to use sensors to find other robots (and react to other robots)

 

Since the field is a 12′ by 12′ mat with numerous obstacles, it is slightly difficult to even imagine a path finding algorithm for that, also, for FIRST, there is only a 30sec. autonomous routine, so there isn’t much time to make something that learns from neural networks. Regarding the automatic autonomous program, our team implemented something similar which I will discuss in another article but if neural networks were to be used, there would need to be hundreds of tests and reruns in order to make it work the way it is supposed to. Unfortunately, the FIRST field is composed of field elements which need to be reset every round (such as a crate of balls). Needless to say, this would most definitely be an inefficient way of making a program. However, the last option (to make something which learns to use sensors) would be very useful while in the autonomous AND tele-operated mode of the game. For example, when robotA approaches robotB, it would be useful if robotB knew that something was heading in its direction using an ultrasonic sensor and then using another ultrasonic sensor to find which way to move in order to avoid the collision. This is just one use of the sensor and the same process can be applied for other sensors as well.

Final Choice: Using neural networks to “teach” robot to use the sensors efficiently

 

 

Part 3 (implementation of idea) coming soon….

 

 

Neural Networks for FIRST Robotics?

For the past week or so, I’ve developed an interest in understanding the workings of neural networks and their application in terms of robots. As the programmer for a FIRST Robotics team, I am currently delved into possibly using the idea of “self learning robots” to make our own robot a bit “smarter”.

How It Works (in layman’s terms)…

Firstly, before getting too complicated and talking about its application in our team’s robot, I will describe how it works…

In some articles I found in google (sources below), they made a robot which learns to drive by stopping whenever it hits an obstacle and then turning away. This is similar to the kinesis/taxis motion in biology (which I learned thanks to AP Bio in school). However, the most interesting part is that without any user involvement, the robot was able to learn the correct method to driving.

In a neural network, a robot will have a few sensors and a few outputs (such as motors). Then, the brain of the robot will take in the inputs and calculate using pretty simple math, the correct outputs. In the robot above, when it reaches a wall, the robot will initially get a sensor triggered telling the cpu that there is a wall in front of it. Then, the cpu will continue to go forward at first until it realizes that it is not going anywhere (using another sensor such as an odometer) and it will learn to not make the same mistake again. Eventually, the robot will be smart enough to not even go near the wall (using possibly another sensor). This is the elegance of neural networks and seems to be the reason for my further googling of it…

Complicated Part (in mathy terms)…

Neural networks can be seen as just a continuously updating self-adding matrix. The matrix starts out as a bunch of 0 values and then, when the robot learns something new, a new matrix of input and output values will be added to the original matrix. Again, when it learns something new, it will add more values to the newly formed matrix (similar to a brain learning something new and adding values each time). Whenever a new input comes in from sensors, it will be given to the neuron and the neuron will spit out the optimal output for those inputs. However, this output will sometimes not be the right output; it will only be the best output that the neuron knows of.


As an example, given three inputs for two outputs, one would create an empty matrix like so:

Input 1 Input 2 Input 3 Output 1 Output 2
Input 1 0 0 0 0 0
Input 2 0 0 0 0 0
Input 3 0 0 0 0 0
Output 1 0 0 0 0 0
Output 2 0 0 0 0 0

Then, to get a result for Input1=1 and Input2=2 and Input3=3, you would multiply the brain matrix with the question matrix:

Input 1 Input 2 Input 3 Output 1 Output 2
Input 1 0 0 0 0 0 1
Input 2 0 0 0 0 0 2
Input 3 0 0 0 0 0 x 3
Output 1 0 0 0 0 0 ?
Output 2 0 0 0 0 0 ?

and the answer is (You need to ignore the ones with question marks):

(0 * 1) + (0 * 2) + (0 * 3) + (0*?) + (0*?) = 0 (First Input)

(0 * 1) + (0 * 2) + (0 * 3) + (0*?) + (0*?) = 0 (Second Input)

(0 * 1) + (0 * 2) + (0 * 3) + (0*?) + (0*?) = 0 (Third Input)

(0 * 1) + (0 * 2) + (0 * 3) + (0*?) + (0*?) = 0 (First Output)

(0 * 1) + (0 * 2) + (0 * 3) + (0*?) + (0*?) = 0 (Second Output)

So, the neural network thinks that the answer to 1,2,3,?,? is 0,0,0,0,0. Even though the robot thinks this is the right answer, this is not the answer which will make the robot do what we want. Unfortunately, if we don’t know the right answer in this case, we would not be able to get the neural network to work. However, similar to our neural networks, the computer ones rely on a “self-checking” mechanism to exist such that whenever an un-encountered situation occurs, you will need to stop and try a bunch of different answers (either randomly or through strategic randomness) and then store it if it is right.

 

 

 (More about its application with FIRST Robotics in Part 2)

Sources

http://www.generation5.org/content/2005/neuroLego.asp

http://code-spot.co.za/2009/10/08/15-steps-to-implemented-a-neural-net/

 

Building Android Ice Cream Sandwich (HTC Aria)

I am making this post as a log of my steps taken in building the Ice Cream Sandwich version of Android for the HTC Aria. This can be used for several other devices but I will be focusing mainly for the Aria (my phone). I will divide the whole post into several major steps I took.

First, you need to go to ubuntu.com and dualboot linux on your computer (make sure to get 64 bit)

Then, you need to open terminal and run the following commands:

sudo add-apt-repository "deb http://archive.canonical.com/ lucid partner" 
sudo apt-get update $ sudo apt-get install sun-java6-jdk
sudo apt-get install git-core gnupg flex bison gperf build-essential \ zip curl zlib1g-dev libc6-dev lib32ncurses5-dev ia32-libs \ x11proto-core-dev libx11-dev lib32readline5-dev lib32z-dev \ libgl1-mesa-dev g++-multilib mingw32 tofrodos python-markdown \ libxml2-utils xsltproc
sudo apt-get install libx11-dev:i386 

These commands simply install the proper pre-requisites in your computer to compile android. Just make sure to type in your password whenever it asks to do so.

Next, open terminal and run the following command:
sudo gedit /etc/udev/rules.d/51-android.rules

This will open up a text editor with nothing in it. Just copy in the following text in it and press save and quit out.

# adb protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e12", MODE="0600", OWNER=""
# fastboot protocol on passion (Nexus One)
SUBSYSTEM=="usb", ATTR{idVendor}=="0bb4", ATTR{idProduct}=="0fff", MODE="0600", OWNER=""
# adb protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e22", MODE="0600", OWNER=""
# fastboot protocol on crespo/crespo4g (Nexus S)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e20", MODE="0600", OWNER=""
# adb protocol on stingray/wingray (Xoom)
SUBSYSTEM=="usb", ATTR{idVendor}=="22b8", ATTR{idProduct}=="70a9", MODE="0600", OWNER=""
# fastboot protocol on stingray/wingray (Xoom)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="708c", MODE="0600", OWNER=""
# adb protocol on maguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="04e8", ATTR{idProduct}=="6860", MODE="0600", OWNER=""
# fastboot protocol on maguro/toro (Galaxy Nexus)
SUBSYSTEM=="usb", ATTR{idVendor}=="18d1", ATTR{idProduct}=="4e30", MODE="0600", OWNER=""
# adb protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d101", MODE="0600", OWNER=""
# fastboot protocol on panda (PandaBoard)
SUBSYSTEM=="usb", ATTR{idVendor}=="0451", ATTR{idProduct}=="d022", MODE="0600", OWNER=""

This will make ubuntu know that your phone is actually a phone and not a virus.

Then, run the following in terminal:
mkdir ~/bin
PATH=~/bin:$PATH
curl https://dl-ssl.google.com/dl/googlesource/git-repo/repo > ~/bin/repo
chmod a+x ~/bin/repo
cd ~
mkdir android
cd android
mkdir system
cd system
repo init -u git://github.com/CyanogenMod/android.git -b ics
repo sync -j20

Then you will need to wait for about 2 hours (in my comcast internet connection) for it to finish downloading the necessary files. If it freezes or dies in the middle, I would try a direct wired connection because wifi didn’t work for my when I did it.

Then Run:
cd vendor/cm/
./get-prebuilts

Then you wait for about 15 minutes to download the pre-built aria files (such as the kernel) into the right folder.

Then run:
cd ../../device
mkdir htc cd htc
git clone git://github.com/WinSuk/android_device_htc_liberty.git liberty
git clone git://github.com/CyanogenMod/android_device_htc_common.git common

Then you wait for about 30 minutes for the files to download (more HTC Aria stuff…). Once this is done, you will need to connect your phone to the computer and run the following commands:

cd liberty
sudo adb kill-server
sudo adb start-server
./extract-files.sh
cd ../../..

Then you need to copy the boot animation (feel free to replace the zip with another of the same resolution from another device if you wish).

cp device/htc/liberty/prebuilt/bootanimation.zip vendor/cm/prebuilt/common/bootanimation.zip

Then you are ready to compile. Just run this:

source build/envsetup.sh

Then run this:
lunch

Then press the appropriate number to compile the cm-liberty-debug version (it was 6 on mine)

Then run this:
make otapackage -j4

This will run for about 8-12 on a decent machine (the first time, after which it will take about 10 minutes) and generate a zip file in ~/android/system/Out/product/liberty

Please post below if you have any questions or concerns regarding the instructions or your build.

If you would like to re-compile android after making some changes in ~/android/system, just open up terminal again and type in the following:cd ~/android/system

source build/envsetup.sh

lunch

Then press the appropriate option, then run:

make otapackage -j4

 

Special Thanks to:
-Winsuk (his repository for git)
-Android (for providing similar instructions)
-Cyanogen Mod (your rom and git)
-Everyone else I forgot (for everything else I forgot)

Google Maps vs. Camera – Third Eye Part 3

One of the features I want to add to Third Eye is the ability to determine whether a user is near a street. When it comes to aiding someone with crossing the street, you need to make sure that the person is near the street first. To do this, I am confronting a dilema…

Method A – Google Maps

I was looking at the google maps app on my phone and it turns out that the GPS on it is very accurate! In fact, it was accurate down to the nearest 3-5 feet, which is very precise for a phone’s gps. Anyway, I wanted to use this feature to possibly determine the user’s displacement vector to the nearest street. The ideal situation would be to get the user’s position (X coord.,Y coord.)  and then compare it to the array of coordinates of the street. However, to do this, I need to get a list of points which lie on the street and find the closest distance from the user’s point to the street’s points.

In the picture to the left, the blue dot would represent my hypothetical location (x12,y12) and the green line would be an array of points I know the coordinates of ex. {(x1,y1),(x2,y2),(x3,y3),(x4,y4)}. Then, I would need to find the closest point to my blue dot ex. (x2,y2) and then I need to find the displacement using the Pythagorean theorem and then I would know if I am near the street if that distance is less than a specified threshold. However, to do this, I would need a completely open source map which I can find coordinates of street paths with. Also, I would need to account for the inaccuracy of my distance (which doesn’t seem to be a problem on the Android). To do this, I could use mapquest’s open library, google maps’ open library, or the open street map project. Unfortunately, google maps does not release the exact coordinates of streets…rather, they release the coordinates of HOUSES or KEYPOINTS in that street. I am looking for the dead center of that street and all the points that lie on that curve.

 

 

Method B – Open Computer Vision

My other method of doing this would be to take a live view of the street which the user is in

and try to extract the boundaries. Assuming I get a perfect picture such as the one to the left, I would need to simply extract the street’s sides by looking for straight lines. Even though this is super  inaccurate, I think it might just work in suburban/country conditions without the interference of too many cars. As for the intricacies, there are simply too many factors and lines to be used for finding roads but I think it might be a possibility. In fact, people have used Open computer vision, a piece of code given off by Intel, to find roads and signs. Unfortunately, as I said in a previous blog entry, this is difficult to accomplish using an Android phone due to the lack of support for opencv android. However, there is always the NDK route which emulates the C++ version of opencv on the Android’s Java virtual machine.

 

So…As for the final decision, I am still unsure whether either of these ideas serve the purpose of finding roads near the user.

Perhaps a combination of both ideas? Maybe using the gps to find approximate location and using the camera to find large roads in front of them….

 

More will come in Part 4 of this project…


 

 

Location Manager 1.2 – Android

Location Manager 1.2


This is my first yet-to-be-published app in the android forum so I am excited to see how it goes. I have thoroughly tested it on my HTC Aria but I would like to see the results on other phones. The idea is as follows:

IDEA

Assume that you take your phone to different to different places and you are annoyed of turning off wifi, turning on gps and placing your phone on vibrate whenever you go to certain places. This program simply lets you keep specific profiles for specific places (such as your home, school or workplace). This saves you time, patience, as well as battery.
For example, I go to school and I turn off my gps, my wifi, and my Sound. When I go to work, I normally keep my sound on, my gps off, and my wifi on. I keep this program running and it simply takes the location from gps/wifi/cell tower(whichever is on) and it lets you program locations using an address and if it sees that I am there, it will run that profile. Thankfully, it also lets my override my profiles just in case I want to use google maps in school or keep my sound on at work.

Version Control

Version 1.0 – The first version which has basic functionality with wifi and sound control. The settings page exists but does not function. The next version will have bluetooth support and full settings functionality.
Version 1.2 – This version has new icons and has functionality for settings page. Everything in the app should now work but may not 

Help

Please post on this thread whether this app works for you or if you are having difficulties.


Version 1.2 - Location Manager v1.2
Unzip the file and copy the apk file directly to your phone. You can then intall it using any file manager.

Thanks for downloading my app