Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by byurocks23 · Nov 29, 2014 at 07:56 PM · rotationmobileaccelerometeraccelerationgyroscope

Get absolute acceleration data from accelerometer/gyroscope but neglect rotational acceleration

So I want to be able to get data where if I move my phone from point A to point B I would get the acceleration (absolute acceleration). Obviously the answer would be to either use the accelerometer and subtract gravity or to use the gyroscopes useracceleration method. However these readings also give me rotational acceleration, the data I want to ignore. Here are three ways I tried to accomplish this. I am using boo to script this. However I am just as fluent in javascript so I can accept answers in that code. I also can understand c# so you can answer in any language you are comfortable with and I should be fine.

         rawGravity = Input.gyro.gravity
         rawAcceleration = Input.acceleration
 
         gravity = Vector3(rawGravity.x, rawGravity.z, rawGravity.y)
         acceleration = Vector3(rawAcceleration.x, rawAcceleration.z, rawAcceleration.y)
 
         linearAccel = acceleration - gravity

Or you can do this

         rawUserAcceleration = Input.gyro.userAcceleration
         userAcceleration = Vector3(rawUserAcceleration.x, rawAcceleration.z, rawAcceleration.y)

Or if you don't want to use the gyroscope and only use the accelerometer you can do this. (Initially pass in (0,0,0) for gravity so It can run in the first frame).

         rawAcceleration = Input.acceleration
         acceleration = Vector3(rawAcceleration.x, rawAcceleration.z, rawAcceleration.y)
         gravity = 0.9*gravity + 0.1*acceleration       
         linearAccel = acceleration - gravity

All of these give about the same readings. But when I rotate the device, I get huge acceleration readings from these methods when I want to ignore acceleration due to rotation. Basicly if I am rotating my phone, I should get the values (0,0,0). The only way I've think could work would be by taking those values and subtracting gyro.rotationRate from them. Since rotationRate is basically rotational acceleration. However when I do this, the data must not match up correctly and I don't get any better readings.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image fergie77 · Jan 24, 2017 at 04:31 PM 1
Share

Did you ever figure this out? Sorry for not providing an answer but I'm also struggling with this

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

28 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

I have used this code to move my player in x direction, so how i can increase it's speed in x direction? 1 Answer

Android Z Axis 0 Answers

Get Accelerometer to rotate 360 degrees 2 Answers

Accelerator.x rotating camera.z - problems with intermediate values 0 Answers

Is Gyroscope supported on all mobile Android iOS devices with a gyroscope? 3 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges