Asked — Edited
Resolved Resolved by DJ Sures!

Using All Iphone Sensors Gps With Ez-B

I'm inches away from creating a method for us to use Iphones GPS, Acclerometer, gyro, data for our robots.

This app rapidly streams data to the PC via wireless UDP stream.

With Python 2.7 or greater installed, this Python script updates the PC with comma delimited data of telemetry data.

I've been trying for about 12 hours to make the Python script below write to the C drive so EZ-Script can read that line and split it into an array with it's split string function.

I don't know how to add that write function to the script?

Thanks in advance! Bill...

Below is info on the Iphone APP: Sensor Data Iphone App

Below is the correct format of the script above: Sensor Data PC script

Below makes me drule. The Specifications of the data the python script receives from the Iphone: App Specifications




import SocketServer

PORTNO = 10552

class handler(SocketServer.DatagramRequestHandler):
    def handle(self):
        newmsg = self.rfile.readline().rstrip()
        print "Client %s said ``%s''" % (self.client_address[0], newmsg)
        self.wfile.write(self.server.oldmsg)
        self.server.oldmsg = newmsg

s = SocketServer.UDPServer(('',PORTNO), handler)
print "Awaiting UDP messages on port %d" % PORTNO
s.oldmsg = "This is the starting message."
s.serve_forever()


// REM below is a python write function that writes over the contents of an existing file and leaves it open for other programs to read
// with open("C:\\syslog.txt", "w+") as myfile:
// myfile.write(str(s.oldmsg))


ARC Pro

Upgrade to ARC Pro

With ARC Pro, your robot is not just a machine; it's your creative partner in the journey of technological exploration.

PRO
Synthiam
#1  

That's a brilliant idea!

There is a lot of overhead with reading and writing to files - and having to install Python. I have a suggestion :)

  1. In your iPhone app, include a section for IP Address and Username. Also maybe names of the variables to configure (i.e. $AccelX and $AccelY, and $CompassDegree, etc)

  2. Have the iPhone set the variables directly in ARC. You can do so with the HTTP Server, easily. The syntax is..


http://192.168.0.1/Exec?password=admin&script=$AccelX=32

You can repeat the above URL for each parameter, $AccelY, $CompassDegree, etc...

So essentially you skip the Python step and communicate with ARC directly. It's a good start to having an app that can have additional functionality too. For example, you can even have your iPhone control direction using ...


http://192.168.0.1/Exec?password=admin&script=Forward()

Any EZ-Script commands can be sent to the HTTP Server using that URL :)

Canada
#2  

hmmmm DJ with that little bit of code could i set variables directly in ARC from other programs that are running on my computer and is it posible for ARC to send data out to another program maybe using a get command ¿¿¿ confused

United Kingdom
#3  

Yes. I used to do similar to operate Jarvis from ARC which was running some PHP which took the "event" and passed it to EventGhost.

In my cloud I believe the example is still there for the EZ-Script (this one). Somewhere I have posted the PHP code too but I'll see if I can find it if anyone wants it. Different apps will use different methods so it may not be useful other than as a reference.

The above has been scrapped now in favour of Telnet to communicate directly with ARC.

Canada
#4  

Any bit of code for that sort of thing would be something im VARY interested in :D Thank You :D

#5  

Thanks DJ and others for the rapid response.

I agree there are a lot of moving parts to this one. I didn't create the app. But Python has built in compiler so that if /when someone modifies the above code with a segment that rewrite a single line of the current comma delimited data sent, I could compile it to an .exe and you could make it available for us.

Bill

PRO
Synthiam
#6  

What's the name of the App? I'll write a control in ARC to receive the network connection.

#7  

Awsome! It's called "Sensor Data" by Wavefront Labs; https://itunes.apple.com/us/app/sensor-data/id397619802?mt=8

Sensor Data

Thanks,

Bill

Netherlands
#8  

You can mark this issue is resolved. I'm in the same room as DJ and he's working on the ARC control :D

#9  

AWSOME NIEK!

I'm giving up my file Python writing scheme now. That is a very complex language.

I would be more than delighted to beta test it. I have that app on a iphone 5, 3gs and an ipad?

Netherlands
#10  

@EEGbiofeedback No need to beta test it, I've seen it work! As a matter of fact, I've tried it myself :D

PRO
Synthiam
#11  

Here you go: https://synthiam.com/Community/Questions/4133

#12  

You guys are UNREAL!

Here's a video of the simplest application of using the phone to move a bot:

Yet the real power will come from the GPS, detecting smacks, telling how fast it's going before trying to turn, and the thing I'm playing with tomorrow, I'll call take that hill. I'll teach it how to autonomously best climb hills and avoiding obstacles.

The video is below: Click To Watch Video


:top



if ($AccelerometerY<-0.8)
reverse(200,300)
$direction=$TrueHeading
endif

if ($AccelerometerY>-0.1)
forward(200,300)
$direction=$TrueHeading
endif

if ($TrueHeading<$direction)
Left(200,300)
$direction=$TrueHeading
endif

if ($TrueHeading>$direction)
Right(200,300)
$direction=$TrueHeading
endif
#sleep(1000)
Print("Dir " + $Direction + "Heading " + $TrueHeading)

goto(top)


United Kingdom
#13  

You Tube link didn't work found it here

#14  

Yea that's some awesome sauce right there. This is what excites me about ez- robot

#15  

Here's a video and code of the Iphone in the robot finding the correct inclination to climb a hill.



:topA

if ($AccelerometerX<-0.05 or $AccelerometerX>0.05) 
if ($AccelerometerX<-0.1)
Left(200,300)
endif


if ($AccelerometerX>0.1)
Right(200,300)
endif
endif
sleep(300)
Print("Dir " + $Direction + "Heading " + $TrueHeading)

goto(topA)





United Kingdom
#16  

I know what I'm doing with my old iPhone :)

Canada
#17  

I have not installed the app yet not sure it will work for me as i only have an old ipod lol

PRO
Synthiam
#18  

Wow EEGbiofeedback, you have done a lot in the short time of this control:) Nice work!

PRO
Canada
#19  

Aw man! I tried to install the Sensor Streamer App on my old iphone 3GS and it said I needed IOS5.0 or newer. I guess I may have to upgrade...but all my Cydia apps :(...tough decision.

#20  

DJ, this one was gestating in me since you created the conditional logic in Ez-Script. So it was just a matter of that Iphone app coming available and you doing the heavy lifting to create this awesome interface the app. Then, it was a slow day at work and it only 12 lines of code to teach it to learn how to climb hills.

I have a Radio Shack monster truck I'm building up to with the tank chassis. I trashed a few things before getting the tank for tests first. Rather than tearing my tank apart, I'm waiting for the new EZ-Bs to become available for the truck climber.

Here's the final script that keeps it renegotiating until it climbs to the highest point of whatever it's placed on. I find it fascinating how with so few rules something with just one sense can perform such complex behaviors.



:topA
if ($AccelerometerX<-0.13)
Left(200,300)
endif

if ($AccelerometerX>0.13)
Right(200,300)
endif

if ($AccelerometerZ<0.07) 
forward(200,300)
endif

sleep(300)
goto(topA)


#21  

Skater, I've used the Sensor Stream App with the EZ-B on a 3Gs Iphone. I successfully Installed it yesterday on model MB717LL on IOS 5.5.1. Shucks re losing your Cydia apps. The 3Gs just lacks Gyros but the accelerometer, GPS, and compass work well.

Best,

Bill

PRO
Canada
#22  

Awesome, Thanks Bill!

#23  

Has anyone been able to connect their Iphone controller without an internet connection to their laptop?

When I took the tank outside for rock climbing, I realized the IP address I was connecting to 192.168.1.2 was my laptop with ARC but through my wifi network.

I've tried connecting to local host 127.0.0.1 on port 1111

When enter netstat at the cmd.exe prompt I see the local host with 8 different ports but none with port 1111.

When I run Microsoft's TCP view (which is a really cool program) I see the ARC.exe with a local IP Address at 0.0.0.0 on port 1111

I've tried entering in 0.0.0.0 on port 1111 on the Sensor Streamer Iphone app.

I've tried opening port 1111 in my windows firewall but not sure I did it right.

I'm wanting to give the tank a GPS location up a steep hill and let it navigate around until it finds a way to the top. Then I'll hook this up to a high powered 4x4 truck.

Thanks,

Bill

#24  

Here's a solution but probably not the best one for my issue where I was unable to connect the EZ-B with the iphone outdoors and away from my homes wireless network.

I powered an 5 v Asus Wireless access point from the EZ-b board. It consumes a lot of power but works.

I can't figure out why the phone can't connect directly to the wifi on the laptop. Is it a firewall issue? Network things baffle me.

Best,

Bill

#25  

You would need to set up your laptop as a router so it creates a network your iphone can connect to. As far as i know, an iPhone can o ly do Infrastructure networking, not Adhoc, but there is software available that can make Windows 7 be an infrastructure router , I'll try and post a link tomorrow, but as I recall it was a bit complicated for someone who doesn't already understand networking, so your solution is actually not a bad one. (sorry for the run on sentence.. Long day, and i am falling asleep as I type).

Couple of other options available I'll post about tomorrow when more awake.

United Kingdom
#26  

Hi if you can enter a URL and not an IP address into the Sensor Stream app then you should be able to setup port forwarding or your home router (not the laptop) using a service such as DTDNS.net

If you are lucky enough to have a fixed IP address @home then you don't need the DTDNS service but you will need to make sure the appropriate port is visible over the Internet normally say port 80 would be but is used for other services so that's why Sensor Stream uses port 1111

I stream my home CCTV (4 cameras) to my IPhone using DTDNS and I can keep an eye on the house when I out and about and connected to a WIFI internet access point

It may not be the best way to do this as Sensor Stream updates rapidly and being on the same network maybe the most efficient. It depends I guess on how you want to run your application?

If I get a chance later I may try setting the DTDNS option with the Iphone and see if it works

#27  

Hey Winstn,

The Sensor Stream and ARC are working perfectly in my home network through my access point. Sensor Stream sends to my accesspoint my laptop gets the data there through port 1111 on 192,168.1,3 which I find with cmd.exe>ipconfig

My issue is when I take it out doors, I'm having to power an 5v Asus wireless Access point via the EZ-B board. Which works but just consumes more power than I like. I was thinking there was a way to communicate with my phone out doors and conserve significant battery life.

I find the Iphone accelerometer far superior to the MMA7455 BTW.

Thanks much,

Bill...

#29  

A wireless hotspot was going to be one of my suggestions. Even one without a contract will still act as an lan router, they are battery powered, and typically charge on 5v 0.5amp or less (usb).

Bill, I have an old 3g MiFi off contract that you can have. Email me at alan at thetechguru.net with your mailing address if interested.

Alan

#30  

A little bit of an expensive solution, but this device: Roving Networks WiFi can be used as a really low power access point (among many other things). I bought one to try using as a WiFi TTL, which unfortunately is not one of the things it does, but I have plans for it.

Alan

#31  

Hey Techguru,

Thanks for the offer of your hotspot. Though, Asus wireless access point thing is working pretty well. I don't have to have it in my robot so I can power it separately so it won't be that much trouble. That Roving Networks WIFI looks powerful also.

I'm starting to build the 4wd monster truck climber now. I'll use the Iphone Data Streamer app to read GPS, compass and accelerometer to communicate with the EZ-B. I'm hooking the digital pins of the EZ-B to the remote controller for the truck. That way I won't have to make any modifications to the truck other than securely housing my Iphone.

I plan to use the phone's sensors to tell if it's trying to accelerate but it's against something. Then I'll back up, go left and resume it's uphill climbing algorithm.

When the mini is released, I'll put one of them in the truck with it's RC controller to add some addition ping or perhaps my Neato LDS unit.

Bill

#32  

Update:

We can significantly simplify this method by jailbreaking our iphones and purchasing the hotspot MyFi app.

This eliminates the need for powering a wireless access point for outdoor use.

Best,

Bill