My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
Home  
Home of Accelerometer Simulator
Updated Feb 4, 2010 by otto.chr...@gmail.com

Introduction

Accelerometer Simulator is an iPhone/iPod Touch application that transfers accelerometer data from the device to your computer using UDP protocol.

Use cases

The main use case for the application is to allow iPhone application developers to create applications that require accelerometer, without having to do all the debugging on the actual device. By inserting two files into their project, they can use the Accelerometer Simulator to provide accelerometer data to their application when debugging on the iPhone simulator.

Second use case is to use your iPhone accelerometer to control something else on another device (such as your MacBook or PC).

Finally you can use the receiver part and write your own data generation application to, for example, execute predefined accelerometer datasets on your application.

Usage

  1. Check-out a copy of the source into your XCode development environment
  2. Open the AccSim.xcodeproj project file
  3. Make changes to Info.plist bundle identifier to match your development certificate. This step is required to install the application on your own iPhone/iPod touch device
  4. Build the application, targeting iPhone device
  5. Run the application on the device.

The application has two views: Accelerometer and Network. The Accelerometer view looks like this

Here you can switch between the actual sensor and manual operation modes. The sliders show the current accelerometer values. In the manual mode you can slide these yourself, generating accelerometer data manually. Note that in the manual mode you can generate data that would not be possible to generate with the HW sensor.

In the second view (tap the bottom tap bar to activate) you can configure network settings.

When the application starts, network is set to OFF and no data is being sent. Switching it to ON opens the gates and the application begins sending UDP packets to the network. By feault it uses broadcast mode, which means that all devices in the same network (such as your WLAN) will receive the packets. In case you plan to run multiple simulators in the same network, you should switch to unicast mode and specify the target IP address manually. You may also change the port to something else if you wish (remember to change it on the receiving end as well).

Now that AccSim is sending accelerometer data, it's time to setup someone receiving it.

Embedding into your application

To embed Accelerometer Simulator capabilities into your own application, simply add the AccelerometerSimulation.h and AccelerometerSimulation.m files from the Simulator classes directory into your project. Then in the source file where you configure UIAccelerometer, simply add

#import "AccelerometerSimulation.h"

This will override the default behaviour of UIAccelerometer when run on the iPhone simulator. When building for device, nothing is changed in your application.

After compiling and running your application on the simulator, it should now be receiving accelerometer data from the AccSim application running on your device.

Should you need to use a different UDP port, you have to edit the AccelerometerSimulaton.m file and change the line

#define kAccelerometerSimulationPort 10552

Other usages

If you want to use the AccSim application for other purposes, check out the testaccsim.py Python-example. It prints out the messages sent by AccSim. The format of messages is following:

ACC: <deviceid>,<timestamp>,<x>,<y>,<z>

The deviceid is the unique device id of iPhone, used to identify different sources if there are many (think of a crowd of iPhone users controlling a single game on a big screen...) Next is timestamp and acceleration values for x,y and z. These are derived directly from UIAcceleration.

Comment by helt...@gmail.com, Dec 5, 2008

Hello,

Please, can you put this app in the apple store?

Comment by karanvas...@gmail.com, Dec 29, 2008

It'd be great to have this in the app store!

Comment by karanvas...@gmail.com, Jan 6, 2009

Hey,

Thanks for sharing your code! I hooked this up to my macbook's internal accelerometer (using UniMotion?):

http://ifiddling.blogspot.com/2009/01/dummy2.html

Best, Karan

Comment by dumitrescu@gmail.com, Jan 9, 2009

This is way too cool! I can finally provide decent looking movies for my accelerometer based games! Thanks a bunch, man!

Comment by ste...@gmail.com, Jan 10, 2009

Thanks for sharing! Is anyone aware of an equivalent for multitouch, sending touches from the device to the simulator? (I need more than the pinch and drag that are available on the simulator)

Comment by des...@gmail.com, Feb 17, 2009

I made a TCP client that handles accelerometer and multi-touch. The only problem is that it is designed to work with SIO2, so it would need a bit of tweaking to work for general programs.

Comment by tom.w.el...@gmail.com, Mar 11, 2009

This is fantastic! Thanks for sharing such a useful tool, I had it all hooked up and running on my apps within a few minutes.

Comment by mgrin...@gmail.com, Mar 16, 2009

Does anybody know why this stops streaming when the iPhone goes into "sleep" mode? Even if it's setup to run in the background via jailbreaking, the data still stops.

Comment by David.Aa...@gmail.com, Mar 19, 2009

I am having an issue with the timestamps coming over to the python script. When I average them, I am getting a 10% reduction on the frequency of the accelerometer update that is coded in. Also, it occasionally will lose a record.

Comment by alex.she...@gmail.com, Apr 20, 2009

Is this not working anymore?

I'm using iPhone SDK 3.1.2, iPhone Simulator running iPhone OS 2.2.1

I've got the AccSim? application running on an iPhone 3G and iPod Touch 16GB 1st Gen just fine, and included the simulator .h and .m files in my project(s) just fine, and I can see the "getAccelerometer" function get called by placing a NSLog statement there in the simulator, but the delegate never makes any callbacks in the simulator at all

Switching to the device(s) works just fine...

Comment by litzoma...@gmail.com, May 22, 2009

Works great! Thanks for the code.

Comment by sol...@gmail.com, May 23, 2009

Nice and easy, worked the very first time. Thanks a bunch. As others have pointed out, the only logical extension to this project is to add touchesBegin/touchesEnd support, then it'll be perfect. Also, the ability to save network preferences would be nice. But hey, it's open source, so I might contribute these changes if I ever put them in myself.

Thanks alot. Beers on me.

Comment by sfl...@gmail.com, Jun 14, 2009

Very clever, here some suggestions how it could evolve even better (if only apple picked up): http://fraggle.squarespace.com/blog/2009/6/14/doing-game-using-accelerometer-on-the-iphone-dont-miss-that.html

Comment by paperpro...@gmail.com, Jul 10, 2009

Thank you very much. I think that this is going to prove a life saver for me.

Comment by jeremypjoseph@gmail.com, Aug 13, 2009

Anyone know how many bytes are in each portion of the message. ie. it sends a 76 byte array across udp and it's split into those 5 messages. id, timestamp, x,y,z

how many bytes make up each portion?

Also anyone made a windows server for accepting this? I'm working on that now in c#.

Comment by jbergh...@gmail.com, Sep 8, 2009

Has anybody been able to get this to work with PhoneGap?? I'm not having any luck. Thanks.

Comment by baggyrab...@gmail.com, Oct 24, 2009

I'm just wondering how exactly i download this. I've followed the link etc. but it doesn't take me to any sort of page... Is the link dead? Is it actually possible to download this?

Comment by Tralor...@charter.net, Dec 13, 2009

To Download it just open a terminal window and type (or paste): svn checkout http://accelerometer-simulator.googlecode.com/svn/trunk/ accelerometer-simulator-read-only

Comment by mickeyla...@gmail.com, Jan 8, 2010

Awesome project, using this w/ cocos2d. Thanks a lot! :M:

Comment by brod...@gmail.com, Jan 25, 2010

Anyone got this working with OS 3.x.x?

Comment by brod...@gmail.com, Jan 25, 2010

never mind, it works!

Comment by bamb...@gmail.com, Apr 5, 2010

thank u

Comment by bhpr...@gmail.com, Apr 9, 2010

Just in case anyone is interested, I put this on the App Store (for free download): http://itunes.apple.com/us/app/accelerometer-simulator/id336476721?mt=8

Thanks for the code!

Comment by solidus...@gmail.com, Apr 28, 2010

For those of you interested in getting the data from this tool into a Processing sketch, check out a simple code snippet here.

Comment by ltg...@gmail.com, May 4, 2010

Does it only work via Wifi?

Comment by blaackj...@hotmail.com, May 18, 2010

Thanks Mr, this is working like a charm! And it's so easy to implement. And i don't thx Apple who could have planned an accelerometer input in the sim. :)

Comment by bolchisb...@gmail.com, Sep 15, 2010

Thanks, worked great!

Comment by hugomc.s...@gmail.com, Nov 24, 2010

Thanks, works. But, how i can get values of accelerometer with simulator? can i shake the simulator to change the values?

Comment by vchang7...@gmail.com, Nov 30, 2010

Thank you for posting this! But I'm still so confused. Is there any way I can directly download the accsim project? I think I'm creating files incorrectly.

Do I create two viewcontrller files for the networkinfo and accelerometerviewcontroller, and then a regular objective c file for the accelerometerinfo.h and .m? when should i add in the accelerometer simulator files?

thank you for your help!!

Comment by plandw...@gmail.com, Dec 5, 2010

Hey just stopping by to say thanks for this project. Worked great for my team in assisting in capturing video of our iOS project without needing a camcorder.

If you ever make updates it'd be double cool if you could add the ability to send touch input from the Acc-Sim running device to the simulator.

vchang7190:

To get the files you'll need to use svn. This contains the full project which you use to build the app to your iOS device.

To add support to your simulator project, copy the AccelerometerSimulation?.h and AccelerometerSimulation?.m files to it, add them using Add Existing Files, and then include AccelerometerSimulation?.h wherever you use accelerometer input in your project.

If you're having issues with it make sure any firewalls you have aren't blocking it since in broadcast mode it's just spamming UDP packets (iirc).

Comment by dfin...@ira.uka.de, Jan 28, 2011

Hey, thank you for that great developer helping app! Works perfectly fine and is absolutely easy to integrate!

Comment by afshi...@gmail.com, Feb 10, 2011

Hi I need to get the accelerometer data in MATLAB and the do some filtering on them. does anybody have any idea on how I can do this via UDP packets??? I really need help. please

Comment by samuli.v...@gmail.com, Mar 2, 2011

What a great and easy-to-use utility even for a total xcode newbie like me! This makes my dev practising on the iPhone simulator so much more sensible and enjoyable. Thanks a million!

Comment by leeprob...@gmail.com, Mar 15, 2011

I'm using iOS 4.3 in xcode 4 and get a warning that the class AccelerometerSimulation? does not implement the 'NSMachPortDelegate' protocol. Compiles ok but I don't get any data.

Comment by florian....@gmail.com, Apr 4, 2011

Any idea if it is possible to recive the data in Flash?

Comment by joe.thom...@gmail.com, Apr 27, 2011

I get the same NSMachPortDelegate warning with no data. Anyone find a solution to this?

Comment by shashirb...@gmail.com, May 26, 2011

can i get the sample cod for the pedometer .Anyone can help me for this

Comment by javi.aba...@gmail.com, Jun 1, 2011

Hi,

I'm getting an EXC_BAD_ACCESS error at line 121 processNotification:notification?; in handleMachMessage method. Any ideas?

Thank you!

Comment by rwolf.me...@gmail.com, Jun 29, 2011

Great work man! Thanks!

Comment by smenon1...@gmail.com, Jul 21, 2011

where are the downloads

Comment by marcir...@gmail.com, Aug 4, 2011

where are the files to download?

Comment by jeronimo...@gmail.com, Aug 24, 2011

Excelent! thanks

Comment by IanD...@gmail.com, Nov 4, 2011

Anyone updating this?? I would love to have shake and swipe/multitouch. Support and since I'm asking for the moon. what about a cute little <popup> Debug console window..

ahh the dream !!! thanks

Comment by hayes...@gmail.com, Jan 17, 2012

this is in the app store for those who don't have the ios dev account (search accelerometer simulator and search? button, it does not show up in the quick search results). I really can't part with $100 for the dev account so this really helped me being I just got to the accelerometer part of the nerd ranch book.

Comment by hayes...@gmail.com, Jan 17, 2012

WHERE'S THE SOURCE/DOWNLOAD? I can't find it.

Comment by exi...@exilia.se, Feb 1, 2012

I just downperiod the app. But it is interacting very slow. It takes up to minutes after pressing "network" before it sows that page. Same with slow updating of XYZ data. Im using at Iphone 3GS. Anyone got any idea how to solve?

Comment by michaelk...@gmail.com, Feb 6 (6 days ago)

I have suggestion. From what I understand this app only works with UIAccelerometer, in the more recent iOS versions CMMotionManager is now the more used accelerometer access api so. If someone could integrate it for CMMotionManager. I would try my self but I'm not a very experienced iOS developer. I'm sure a lot of people would appreciate this.


Sign in to add a comment
Powered by Google Project Hosting