×

Discussion Board

Page 1 of 4 1234 LastLast
Results 1 to 15 of 54
  1. #1
    Registered User
    Join Date
    Nov 2007
    Location
    Malmö, Sweden
    Posts
    10

    Demo: 2D physics using sensor module

    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

  2. #2
    Regular Contributor
    Join Date
    Sep 2003
    Location
    Finland
    Posts
    209

    Re: Demo: 2D physics using sensor module

    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)

  3. #3
    Registered User
    Join Date
    Nov 2007
    Location
    Malmö, Sweden
    Posts
    10

    Re: Demo: 2D physics using sensor module

    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.

  4. #4
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: Demo: 2D physics using sensor module

    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 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  5. #5
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: Demo: 2D physics using sensor module

    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 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  6. #6
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: Demo: 2D physics using sensor module

    @ andreas:

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

    Cyke64
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  7. #7
    Registered User
    Join Date
    Nov 2007
    Location
    Malmö, Sweden
    Posts
    10

    Re: Demo: 2D physics using sensor module

    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.

  8. #8
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: Demo: 2D physics using sensor module

    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
    Last edited by cyke64; 2007-11-30 at 13:24.
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

  9. #9
    Regular Contributor
    Join Date
    Sep 2005
    Location
    Finland, Helsinki
    Posts
    323

    Re: Demo: 2D physics using sensor module

    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.

  10. #10
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Demo: 2D physics using sensor module

    Unfortunately not for me due to the problem described here:

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

    Regards

  11. #11
    Registered User
    Join Date
    Nov 2007
    Location
    Malmö, Sweden
    Posts
    10

    Re: Demo: 2D physics using sensor module

    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.

  12. #12
    Nokia Developer Moderator
    Join Date
    May 2007
    Location
    21.46 N 72.11 E
    Posts
    3,796

    Re: Demo: 2D physics using sensor module

    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
    Pankaj Nathani
    www.croozeus.com

  13. #13
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Demo: 2D physics using sensor module

    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

  14. #14
    Registered User
    Join Date
    Nov 2006
    Posts
    568

    Re: Demo: 2D physics using sensor module

    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

  15. #15
    Registered User
    Join Date
    Feb 2005
    Location
    Belgium (Europe)
    Posts
    1,352

    Re: Demo: 2D physics using sensor module

    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
    Last edited by cyke64; 2008-01-02 at 14:56.
    pys60 1.4.5 and 2.0.0, pygame, PyS60 CE on E90 and 5800 !

    Find my pys60 extension modules on cyke64.googlepages.com

Similar Threads

  1. Replies: 4
    Last Post: 2007-06-22, 13:45
  2. Using Nokia Demo Projects with Eclipse 3.2.0
    By PionsysAtNokia in forum Mobile Java Tools & SDKs
    Replies: 5
    Last Post: 2006-10-10, 15:24
  3. Standalone Emulator Demo
    By desmondling78 in forum Mobile Java Tools & SDKs
    Replies: 0
    Last Post: 2005-02-22, 01:02
  4. Small job -> Demo Application ??
    By Tim.Myers in forum Mobile Java General
    Replies: 2
    Last Post: 2004-11-11, 07:53
  5. where can i find the demo?
    By yyy_nokia in forum PC Suite API and PC Connectivity SDK
    Replies: 1
    Last Post: 2003-11-15, 04:34

Posting Permissions

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