"Forknife" - the Android G1 controlled robot.

Search This thread

macpod

Member
Oct 23, 2008
17
0
Columbia, MD
macpod.net
Since I got my G1 I have been thinking of interesting ways to talk with my arduino prototyping board since there is no USB support yet (my next software/hardware project?.. it would be handy to use a G1 as a serial console)

I ended up using DTMF tones and to see how well it worked, I quickly built a simple robot for testing. You can take a look at a video, pictures, overview of how it works, and the GPL-ed source code/schematics to build your own or improve it here:
http://macpod.net/misc/android_robot/android_robot.php

robot_back.jpg

Enjoy!
 
Last edited:

belding

Member
Jan 5, 2009
20
0
Could someone make a quick program for the Dream to output all of its sensor data (GPS, Compass, accelerometer)?

It would save money from having to buy these parts for the arduino...
 

macpod

Member
Oct 23, 2008
17
0
Columbia, MD
macpod.net
Yep, you could do this pretty easily. If you did it via dtmf you could send 1 nibble of data per tone without checksumming it. If you modified the kernel and made you own ttl level cable (I'm waiting on parts to make mine) you might be able to do two way communications up to 115Kbps!
 

belding

Member
Jan 5, 2009
20
0
I do not have a dtmf decoder to do this yet, so I am looking into alternate means to send the data.

It looks that I will have it set up opposite of the Forknife robot, with Android sending data over wifi (via a modified Gmote program) through the serial monitor in the Arduino Environment.
I'm also gonna try to grab the sensor data from the Tricorder app on my phone.

Time to see if I can get the Source code for these two.

-Brian
 

macpod

Member
Oct 23, 2008
17
0
Columbia, MD
macpod.net
If you have wifi avaliable why would you need to reverse how this is done? I would just setup a server socket on the arduino, connect to it via the arduino and talk.

What wifi module will you use?

Oh, if you have a light sensor you could try sending out the G1's data by blinking the LED (you even have multiple colors so if you had a color sensor you could perform flow control!) :D

edit: check out bluetooth solutions too.

edit2: I guess it would make sense to reverse the flow.. I was thinking you were suggesting that there would be only one way communications from the arduino --> phone
 
Last edited:

belding

Member
Jan 5, 2009
20
0
My arduino doesnt have wifi, Android and my computer do.

At this point the Arduino isn't going anywhere, its plugged in with USB.

Would Android's Bluetooth API's allow for serial communication? as I was considering getting bluetooth modules for the Arduino.

Blinking the tricolor LED would be fun, but i have no experience coding Android, I am still working on setting up Eclipse for it.
 
Last edited:

macpod

Member
Oct 23, 2008
17
0
Columbia, MD
macpod.net
Oh! Sorry, I didn't look at how the gmote setup worked.

If computer is in the picture this is really easy. You already have server code on the computer and client network code on the G1. All you would have to do is change what data is sent (and also send to the server as opposed to the server sending data to the client.. that's a trivial change).

On the server side you would need to forward the data you recieve from the G1 to your arduino.. and I'm sure the gmote code already shows how to work with serial ports.

On the client side, you would just need to rewrite the data in the thread to write out values from the sensors. :)


Edit: I'm not sure about bluetooth setups with the arduino as I have never worked with them. Something tells me that the communication protocols could be proprietary (i.e. both sender and recievers just work as serial ports.. they can't actually connect to other real bluetooth devices)
 
Last edited:

belding

Member
Jan 5, 2009
20
0
Hm, I cannot get the souce code for either the gmote.apk nor the server. I found a PICaxe based color sensor on sparkfun.com for $35, could that be used with the ardiuno to read the rgb notification LED on the G1? I would need a program to encode sensor data to the rgb.

I feel it would be easier to make a photo resistor read IO from the g1, and input directly into the RX on the arduino.
 

macpod

Member
Oct 23, 2008
17
0
Columbia, MD
macpod.net
Using a photo sensor is a very hackish way to do this.. and would also cost more than just using wifi. It would also require significantly more code. Not to mention it only allows one way communication.

Just use the wifi method! It's the simplest method :)

I'm sure there is example code for how to read the sensors in android.

On the client side I'm sure there is code that discusses how to read sensor values

and on the computer side, all you need to do is implement code to talk to the serial port the arduino is associated with.. for linux/unix/os x it's just opening up a device in /dev/ for reading/writing!
 
Last edited:

belding

Member
Jan 5, 2009
20
0
Okay, i have eclipse set up for android, but still cannot get source code for the gmote.apk, I tried adb pulling it, but it is encrypted, so I cannot edit it's settings.

could i use "ghost" programs to control my input through these programs. I can easily place the cursor in the Serial Monitor for Arduino, but could I use a program to copy the serial data, then Paste the input into the gmote program to be sent to the serial monitor on the computer's side.

How easy would a code like this be? it would have to run on top (or underneath another program).
 

belding

Member
Jan 5, 2009
20
0
Now, I heard you say that a kernel patch could enable serial communication through the USB port. A friend of mine is really good in linux and modifying kernels.

Would you have any idea of what part of the kernel I should look for, and what it has to be changed to? I have to have an idea of what to ask him.

Thanks
-Brian
 

JesusFreke

Inactive Recognized Developer
Oct 23, 2008
736
54
Dallas
Now, I heard you say that a kernel patch could enable serial communication through the USB port. A friend of mine is really good in linux and modifying kernels.

Would you have any idea of what part of the kernel I should look for, and what it has to be changed to? I have to have an idea of what to ask him.

Thanks
-Brian

It's actually supported in the kernel already, although I'm not sure if that particular configuration option is turned on in the default built. So at worst you would just have to recompile the kernel with a different configuration.
 

belding

Member
Jan 5, 2009
20
0
So I will have to ask my friend to find usb serial communicaton in the kernel, and enable it for program use?

If that is the case, how would I write programs to take advantage of this, wouldn't I need a new API?

Or since the kernel already has it, is there already an API for serial communication?

Thanks
 

JesusFreke

Inactive Recognized Developer
Oct 23, 2008
736
54
Dallas
So I will have to ask my friend to find usb serial communicaton in the kernel, and enable it for program use?

If that is the case, how would I write programs to take advantage of this, wouldn't I need a new API?

Or since the kernel already has it, is there already an API for serial communication?

Thanks

I haven't played with it, but I assume it's just a device in /dev that you can read/write
 

macpod

Member
Oct 23, 2008
17
0
Columbia, MD
macpod.net
belding, what is it about the wifi solution you don't like? It is a software only solution to your problem and alot of code is already written for you in the robot project.

Indeed the serial solution over the 11 pin connector would be best, but that requires you to buy hardware, solder tiny pins, and then modify your kernel which you don't seem to be comfortable doing. In addition, it is my understanding the modification requires you to disable adb support!


Perhaps if you told us your knowledge background I could explain it better? I kinda assumed you were computer science oriented, but I suppose if you are cpe or ee oriented I could have lost you. It would also help to know what your computer is runnng.
 

belding

Member
Jan 5, 2009
20
0
The wifi solution would work, but i cannot get source code to rewrite the gmote client or server.

I do not currently have the hardware (DTMF decoder) to implement your premade solution.

Okay, For my knowledge background: in Android, most things I can see are update.zip based, and I can change anything in the android system that is contained on the update. Looking through /system/usr I found the kernel config, but most options were enabled, and the two that were not do not seem to be related to Serial. I have basic knowledge of command prompt tools in Windows and the Android terminal.

Knowledge again, I am learning Arduino and processing, and am fairly good with electrical circuits, the ee you mentioned.

My computer is dual booting Windows XP and Windows 7.

PS, I talked to my friend, and we are looking into the Android Kernel, specifically where it is located, and where the terminal is located.

Where is the terminal in android located, inside or outside Dalvik VM?
 

JesusFreke

Inactive Recognized Developer
Oct 23, 2008
736
54
Dallas
The wifi solution would work, but i cannot get source code to rewrite the gmote client or server.

I do not currently have the hardware (DTMF decoder) to implement your premade solution.

Okay, For my knowledge background: in Android, most things I can see are update.zip based, and I can change anything in the android system that is contained on the update. Looking through /system/usr I found the kernel config, but most options were enabled, and the two that were not do not seem to be related to Serial. I have basic knowledge of command prompt tools in Windows and the Android terminal.

Knowledge again, I am learning Arduino and processing, and am fairly good with electrical circuits, the ee you mentioned.

My computer is dual booting Windows XP and Windows 7.

PS, I talked to my friend, and we are looking into the Android Kernel, specifically where it is located, and where the terminal is located.

Where is the terminal in android located, inside or outside Dalvik VM?

Well, you can get to a terminal with the terminal emulator application of course, or through adb shell.

But if you want an actual console on the phone itself, try out the recovery image from JFv1.41. It boots into the normal recovery image, but it provides an alt+x option to exit the recovery program, and go to a console.

Also, the android kernel source is here. Make sure you grab the .25 branch if you want it to work with the current official builds. The .27 branch is only for cupcake.

To download the source, make sure you have git installed, and then:

git clone git://android.git.kernel.org/kernel/msm.git
cd msm
git checkout android-msm-htc-2.6.25

to build the kernel, you can use the pre-compiled gcc cross-compiler that is provided in the android source. make sure that it is in your path, and then invoke make with the arguments ARCH=arm CROSS_COMPILE=arm-eabi-

(or you can set those variables in the Makefile, so you can just do "make").

If you have any questions about getting everything set up to compile the kernel, feel free to ask. It seems a bit daunting the first time you do it, but it's actually fairly straight forward.