×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Oct 2008
    Posts
    24

    Filtering data from accelerometer

    Hello! I´m developing an app in Python for my n95 and I need to filter some data because the accelerometer gives so much noise, does anyone know a code to solve my problem? Thanks!

  2. #2
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Re: Filtering data from accelerometer

    Quote Originally Posted by BAM8 View Post
    Hello! I´m developing an app in Python for my n95 and I need to filter some data because the accelerometer gives so much noise, does anyone know a code to solve my problem? Thanks!
    Well, teorically, you need to get the current x value (or whatever axis you are using) and the last x value and subtract them

    Then, compare with the value you want (e.g. 90). If the subtraction of the last and current value is bigger than the comparison value, trigger the action (in case of a shake)



    Hope you understood,

    Rafael.
    Last edited by Rafael T.; 2009-01-18 at 23:19.

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

    Re: Filtering data from accelerometer

    Much depends on the type of shake you want to employ.

    I recommend logging the values of the axis to a file by modifying the sample axyz script provided with the extension. On the basis of the logged data manipulate the required values of the axis.

    Otherwise, consider updating your firmware to the latest, to use the sensor module.

    Best Regards,
    Croozeus
    Pankaj Nathani
    www.croozeus.com

  4. #4
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Re: Filtering data from accelerometer

    Quote Originally Posted by croozeus View Post
    Much depends on the type of shake you want to employ.

    I recommend logging the values of the axis to a file by modifying the sample axyz script provided with the extension. On the basis of the logged data manipulate the required values of the axis.

    Otherwise, consider updating your firmware to the latest, to use the sensor module.

    Best Regards,
    Croozeus
    Yes, this would be an extended way for that, which is very cool

    Anyway, here is a simple shake example I did using axyz module and it worked well in N95 8GB:

    Code:
    import e32
    import appuifw
    import axyz
    
    last_x = last_y = last_z = 0
    
    def reduce_noise(x, y, z):
        global last_x
        global last_y
        global last_z
    
        cur_x, cur_y, cur_z = x - last_x, y - last_y, z - last_z
        last_x, last_y, last_z = x, y, z
        f = cur_x + cur_y + cur_z
        if f > 150:
            appuifw.note(u"Shake Detected!")
    
    axyz.connect(reduce_noise)
    app_lock = e32.Ao_lock()
    app_lock.wait()

    Hope it helps,

    Rafael.

  5. #5
    Registered User
    Join Date
    Dec 2005
    Location
    Recife Pernambuco
    Posts
    40

    Re: Filtering data from accelerometer

    Hi all,

    Do you have any samples of shaking movement (left and right), i am trying to interpret the Next and Back of a music player that i am developing with accelerometers. Thanks,

    Marcel

  6. #6
    Super Contributor
    Join Date
    Feb 2008
    Location
    Belo Horizonte, Brazil
    Posts
    744

    Re: Filtering data from accelerometer

    Quote Originally Posted by marcelcaraciolo View Post
    Hi all,

    Do you have any samples of shaking movement (left and right), i am trying to interpret the Next and Back of a music player that i am developing with accelerometers. Thanks,

    Marcel
    Well, this is quite simple: if x<0, it means the phone is tilted to the left, and if x>0, it's tilted to the right.



    Hope it helps,

  7. #7
    Registered User
    Join Date
    Dec 2005
    Location
    Recife Pernambuco
    Posts
    40

    Re: Filtering data from accelerometer

    Thanks Rafael for your answer.

    But i am facing the problem that when i tilt the phone to the left, since the callback sensor is called everytime, it checks the phone is in the left, and makes the music forward two times or more than one time. And it's not what i want. I want that after a tilt to left and back to the normal, this correspond to the event (Next()) of my application.

    =)
    i saw your code below, but i think it's only for shakes in general, not specific (for left or for right).

    Thanks,
    Marcel

  8. #8
    Super Contributor
    Join Date
    Mar 2003
    Location
    Espoo, Finland
    Posts
    976

    Re: Filtering data from accelerometer

    Quote Originally Posted by marcelcaraciolo View Post
    But i am facing the problem that when i tilt the phone to the left, since the callback sensor is called everytime, it checks the phone is in the left, and makes the music forward two times or more than one time. And it's not what i want. I want that after a tilt to left and back to the normal, this correspond to the event (Next()) of my application.
    This is really simple, but have to mention anyway: you have to remember, whether you have responded to the "left" event already or not. You still receive dozens (hundreds) of "left" events, but after the first event just happily ignore the rest. Wait until you get back to "normal" or "right", until you except any more lefts..

    Like I said, so simple I was hesitating whether I even dare to mention it... but did, because I just gave up on listbox icons and moved to the next item on todo list: update Sensor Analyzer. Got to get into mood

    Shaking head or was it nodding,

    --jouni

Similar Threads

  1. Replies: 3
    Last Post: 2008-09-09, 04:53
  2. Replies: 2
    Last Post: 2008-07-03, 15:29
  3. Replies: 1
    Last Post: 2007-04-17, 10:47
  4. Replies: 4
    Last Post: 2006-08-30, 10:15
  5. Unicode Song Title In NSM Ringtone
    By mcai7db3 in forum Smart Messaging
    Replies: 3
    Last Post: 2002-08-28, 06:58

Posting Permissions

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