You Are Here:

Community: Developer Discussion Boards

Reply « Previous Thread | Next Thread »

#1 Old Demo: 2D physics using sensor module - 2007-11-30, 00:57

Join Date: Nov 2007
Posts: 10
Location: Malmö, Sweden
Send a message via MSN to Andreas Blixt
Andreas Blixt
Offline
Registered User
Hi there,

I've made a small application that'll make use of the accelerometer in a mobile with PyS60 installed. You'll need the Python shell installed to be able to run it (I have not made it into a .sis file.)

Here it is: http://projects.mezane.org/verlet.py

What you should see is a box that'll move in whatever direction that the phone is tilted. So if you tilt it right, it'll slide to the right of the screen, and the velocity will vary depending on the amount of tilt. In addition to this, it also applies forces from the acceleration of your phone. So if you hold your phone upright so that the box falls to the bottom of the screen, then move your phone quickly upwards and stop abruptly, the box will fly upwards as you'd expect.

This has only been tested on an N95 8GB and since this is the first Python script I've attempted I'd appreciate input on my code.

I'm positively surprised at the simplicity of developing applications using Python and also at the responsiveness of the accelerometer!

Regards,
Andreas
Reply With Quote

#2 Old Re: Demo: 2D physics using sensor module - 2007-11-30, 08:33

Join Date: Sep 2003
Posts: 209
Location: Finland
otsov
Offline
Regular Contributor
Quote:
Originally Posted by Andreas Blixt View Post
This has only been tested on an N95 8GB and since this is the first Python script I've attempted I'd appreciate input on my code.

I'm positively surprised at the simplicity of developing applications using Python and also at the responsiveness of the accelerometer!
Nice, it seems that the N95 8GB supports the "AccSensor" out-of-the-box - so the standard "sensor" extension can be used with the device to get acceleration data (I don't have a N95 8GB device to test it).

(ps. the "e32.ao_sleep()" can be somewhat dangerous to use - the application will panic should the user exit during the sleep call, please see the API document for more information)
Reply With Quote

#3 Old Re: Demo: 2D physics using sensor module - 2007-11-30, 09:14

Join Date: Nov 2007
Posts: 10
Location: Malmö, Sweden
Send a message via MSN to Andreas Blixt
Andreas Blixt
Offline
Registered User
Quote:
Originally Posted by otsov View Post
Nice, it seems that the N95 8GB supports the "AccSensor" out-of-the-box - so the standard "sensor" extension can be used with the device to get acceleration data (I don't have a N95 8GB device to test it).

(ps. the "e32.ao_sleep()" can be somewhat dangerous to use - the application will panic should the user exit during the sleep call, please see the API document for more information)
Hi otsov,

Thanks for your input! Doesn't the PyS60 v1.4.1 sensor module enable accelerator access equally on all mobiles with an accelerator? Is there any way for me to make my script compatible with more mobiles?

I've changed my code to use e32.Ao_timer() and to call cancel() on the timer when the application is exiting. I hope this solves the "panic" problem?

I also added friction when an atom touches the edge of the screen.
Reply With Quote

#4 Old Re: Demo: 2D physics using sensor module - 2007-11-30, 11:33

Join Date: Feb 2005
Posts: 1,353
Location: Belgium (Europe)
cyke64's Avatar
cyke64
Offline
Super Contributor
Quote:
Originally Posted by otsov View Post
Nice, it seems that the N95 8GB supports the "AccSensor" out-of-the-box - so the standard "sensor" extension can be used with the device to get acceleration data (I don't have a N95 8GB device to test it).
Hello otsov ,

Yes N95 8GB support AccSensor and RotSensor from "sensor" extension without problem I have tested this on on a N95 8GB V10.0.021 29-09-07

N95 with the new firmware released 20.0.015 has been reported working also !

BR
Cyke64


pys60 1.4.5,1.9.7,pygame,PyS60 CE on E90 , N810 with Python 2.5.2 and ... last PyS60 1.9.7 with touch ui on 5800 !

pys60 extension modules on http://cyke64.googlepages.com/
Reply With Quote

#5 Old Re: Demo: 2D physics using sensor module - 2007-11-30, 11:45

Join Date: Feb 2005
Posts: 1,353
Location: Belgium (Europe)
cyke64's Avatar
cyke64
Offline
Super Contributor
Quote:
Originally Posted by Andreas Blixt View Post
Hi otsov,

Thanks for your input! Doesn't the PyS60 v1.4.1 sensor module enable accelerator access equally on all mobiles with an accelerator? Is there any way for me to make my script compatible with more mobiles?

I've changed my code to use e32.Ao_timer() and to call cancel() on the timer when the application is exiting. I hope this solves the "panic" problem?

I also added friction when an atom touches the edge of the screen.
@andreas :

Congratulation for your cool example

"sensor" module don't work with all mobile containing an accelerator

Reported mobile 3rd edition containing an accelerator are N93i,N95,N95 8GB,N82 and 5500. If they support "sensor" (implementing sensor API from 5500) depend on firmware.
You could refer to this panel in the wiki (sensor = "sensor" module support)
But you could also for N95 < 20.0.015 use module "aXYZ" and NRC plugin (search "aXYZ" for more info)

BR
Cyke64


pys60 1.4.5,1.9.7,pygame,PyS60 CE on E90 , N810 with Python 2.5.2 and ... last PyS60 1.9.7 with touch ui on 5800 !

pys60 extension modules on http://cyke64.googlepages.com/
Reply With Quote

#6 Old Re: Demo: 2D physics using sensor module - 2007-11-30, 13:29

Join Date: Feb 2005
Posts: 1,353
Location: Belgium (Europe)
cyke64's Avatar
cyke64
Offline
Super Contributor
@ andreas:

verlet.py is a short porting of verlet made in JavaScript.
Cool engine !

Cyke64


pys60 1.4.5,1.9.7,pygame,PyS60 CE on E90 , N810 with Python 2.5.2 and ... last PyS60 1.9.7 with touch ui on 5800 !

pys60 extension modules on http://cyke64.googlepages.com/
Reply With Quote

#7 Old Re: Demo: 2D physics using sensor module - 2007-11-30, 13:52

Join Date: Nov 2007
Posts: 10
Location: Malmö, Sweden
Send a message via MSN to Andreas Blixt
Andreas Blixt
Offline
Registered User
Quote:
Originally Posted by cyke64 View Post
verlet.py is a short porting of verlet made in JavaScript.
Yep, I've always liked coding Verlet particle physics and mass-spring physics because they're easy to implement and fun to play with.

Here are a few other tests I made with my JavaScript Verlet engine (they were mainly made for Mozilla Firefox, I'm afraid):
http://projects.mezane.org/physics-e...html/test.html
http://projects.mezane.org/physics-e...ml/funnay.html (Use arrow keys)

I was thinking about how to turn Verlet physics + accelerometer into a game. One could make an obstacle course where the player has to rotate their phone to get through it.
Reply With Quote

#8 Old Re: Demo: 2D physics using sensor module - 2007-11-30, 14:05

Join Date: Feb 2005
Posts: 1,353
Location: Belgium (Europe)
cyke64's Avatar
cyke64
Offline
Super Contributor
Quote:
Originally Posted by Andreas Blixt View Post
Yep, I've always liked coding Verlet particle physics and mass-spring physics because they're easy to implement and fun to play with.

Here are a few other tests I made with my JavaScript Verlet engine (they were mainly made for Mozilla Firefox, I'm afraid):
http://projects.mezane.org/physics-e...html/test.html
http://projects.mezane.org/physics-e...ml/funnay.html (Use arrow keys)

I was thinking about how to turn Verlet physics + accelerometer into a game. One could make an obstacle course where the player has to rotate their phone to get through it.
Very funny

Yes it's a great idea !

I made a porting of your verlet.py for aXZY module for other N95 with previous firmware.
I noted that X and Y data are inverted and sign inversion is not needed in aXYZ !

Cyke64


pys60 1.4.5,1.9.7,pygame,PyS60 CE on E90 , N810 with Python 2.5.2 and ... last PyS60 1.9.7 with touch ui on 5800 !

pys60 extension modules on http://cyke64.googlepages.com/
Last edited by cyke64 : 2007-11-30 at 14:24.
Reply With Quote

#9 Old Re: Demo: 2D physics using sensor module - 2007-12-12, 22:42

Join Date: Sep 2005
Posts: 314
Location: Finland, Helsinki
aaaaapo
Offline
Regular Contributor
I got my new N82 today...
Quote:
Originally Posted by Andreas Blixt View Post
I've made a small application that'll make use of the accelerometer in a mobile with PyS60 installed. http://projects.mezane.org/verlet.py
What you should see is a box that'll move in whatever direction that the phone is tilted.
Works perfectly. Very cool. Very, very cool.
Reply With Quote

#10 Old Re: Demo: 2D physics using sensor module - 2007-12-16, 23:05

Join Date: Nov 2006
Posts: 502
neil.young
Online
Super Contributor
Unfortunately not for me due to the problem described here:

http://discussion.forum.nokia.com/fo...d.php?t=118545

Regards
Reply With Quote

#11 Old Re: Demo: 2D physics using sensor module - 2007-12-17, 12:33

Join Date: Nov 2007
Posts: 10
Location: Malmö, Sweden
Send a message via MSN to Andreas Blixt
Andreas Blixt
Offline
Registered User
Quote:
Originally Posted by neil.young View Post
Unfortunately not for me due to the problem described here:

http://discussion.forum.nokia.com/fo...d.php?t=118545

Regards
Hmmm... I think I had that problem too, but I downloaded the unsigned Python S60 Shell and signed it with my developer certificate (which has all security settings enabled) and that worked.
Reply With Quote

#12 Old Re: Demo: 2D physics using sensor module - 2007-12-17, 13:06

Join Date: May 2007
Posts: 2,739
Location: 21.46 N 72.11 E
croozeus's Avatar
croozeus
Offline
Forum Nokia Champion
Quote:
Originally Posted by Andreas Blixt View Post
(which has all security settings enabled)

Does it mean that the shell is signed with all the capabilities?

BR
Croozeus
Reply With Quote

#13 Old Re: Demo: 2D physics using sensor module - 2007-12-17, 18:31

Join Date: Nov 2006
Posts: 502
neil.young
Online
Super Contributor
Quote:
Originally Posted by Andreas Blixt View Post
Hmmm... I think I had that problem too, but I downloaded the unsigned Python S60 Shell and signed it with my developer certificate (which has all security settings enabled) and that worked.
Of course, I'm using a signed shell too. Before this I had an unsigned shell, but this e.g. leads to the result NONE while querying location.gsm_location().

Location and positioning is working.

Simply "import sensor" crashes with permission fault.

Hell
Reply With Quote

#14 Old Re: Demo: 2D physics using sensor module - 2007-12-17, 18:38

Join Date: Nov 2006
Posts: 502
neil.young
Online
Super Contributor
Quote:
Originally Posted by Andreas Blixt View Post
Hmmm... I think I had that problem too, but I downloaded the unsigned Python S60 Shell and signed it with my developer certificate (which has all security settings enabled) and that worked.
Of course, I'm using a signed shell too. Before this I had an unsigned shell, but this e.g. leads to the result NONE while querying location.gsm_location().

Location and positioning is working.

Simply "import sensor" crashes with permission fault.

Maybe this doesn't work because Sensor is _not_ an option in Application Capabilities!?!. Seems that the Symbian DevCertificate Request Center has to provide a means to add Sensor-Capabilities? (Just a guess). Doing that they also could rewrite their terrible, completely unreadable CAPTCHA-stuff... Brrr... Took me hours to come over it...

Hell
Reply With Quote

#15 Old Re: Demo: 2D physics using sensor module - 2008-01-02, 15:42

Join Date: Feb 2005
Posts: 1,353
Location: Belgium (Europe)
cyke64's Avatar
cyke64
Offline
Super Contributor
Quote:
Originally Posted by Andreas Blixt View Post
Yep, I've always liked coding Verlet particle physics and mass-spring physics because they're easy to implement and fun to play with.

I was thinking about how to turn Verlet physics + accelerometer into a game. One could make an obstacle course where the player has to rotate their phone to get through it.
Hello Andreas ,

Happy new year 2008 to every PyS60 forumer !
I have a cool idea for a game with verlet : implementing a similar game to Crayon Physics

Somebody has already ported this game to iPhone : iPhysics !

You can download and try on your PC too : Crayon Physics and Marker World (a clone !)

View Crayon Physics on YouTube !

BR
Cyke64


pys60 1.4.5,1.9.7,pygame,PyS60 CE on E90 , N810 with Python 2.5.2 and ... last PyS60 1.9.7 with touch ui on 5800 !

pys60 extension modules on http://cyke64.googlepages.com/
Last edited by cyke64 : 2008-01-02 at 15:56.
Reply With Quote
Reply « Previous Thread | Next Thread »
Display Modes
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules

You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump
Similar Threads
Thread Thread Starter Forum Replies Last Post
Bluetooth netbeans demo fails on symbian emulator (and in the mobile phone) backspace Mobile Java Tools & SDKs 4 2007-06-22 14:45
Using Nokia Demo Projects with Eclipse 3.2.0 PionsysAtNokia Mobile Java Tools & SDKs 5 2006-10-10 16:24
Standalone Emulator Demo desmondling78 Mobile Java Tools & SDKs 0 2005-02-22 02:02
Small job -> Demo Application ?? Tim.Myers Mobile Java General 2 2004-11-11 08:53
where can i find the demo? yyy_nokia PC Suite API and PC Connectivity SDK 1 2003-11-15 05:34

Rate This

 
Bookmark this page: DeliciousDiggFacebookGoogleYahooStumbleUponRedditDiigoTechnocratiTwitter  Share this page Share this page Print this Page Print this page Invite a friend Invite a friend
京ICP备05048969号    Email Newsletters Press Terms & Conditions Privacy Policy Sitemap Contact Us © 2009 Nokia