Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 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 RetzRetro · Jul 20, 2016 at 06:47 PM · mobileaccelerometerlinear

Linear acceleration Mobile

I am getting slightly confused with linear acceleration. I am trying to create an AR application and need to track the linear movement of a mobile device, I have tried converting the linear force into force on the axis over time but nothing I try seems to work. It seems that the linear acceleration within unity (with gravity removed) is still recording rotation, is this correct?

Here is a little segment of the code:

 //Work out the velocity of X on the users acceleration
     fl_Vx += (v3_PrevAccel.x + Input.gyro.userAcceleration.x) / 2.0f * Time.deltaTime; 
     fl_Vx = fl_Vx * Time.deltaTime; 

This is just for getting the X axis it is later added to the gameobject via a translate, although it has been added as a transform.position as well but to no avail either way.

I have searched around a bit before putting this code together.

I am aware that any solution will not be perfect but if I could just have a hand sorting something out, even if there are some inaccuracies, it would be truly appreciated.

Comment
Add comment · Show 3
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 RetzRetro · Aug 09, 2016 at 09:04 AM 0
Share

Heya Dave,

Firstly, I apologise if I post this reply in the wrong place. I tried to add a comment but don't have permissions and so have hit 'Add Reply'.

I have tried Vuforia myself already and to be honest, it's terrible. It's extremely restrictive and only works via image recognition and nothing else. Even if you manage to remove the Image Target (which I did) it just causes everything to drift as it tries to recognise the area and fails to do it accurately. I moved onto writing the AR app without Vuforia or Image Recognition as it is more suited to the company I work for (and their clients) purpose.

So, would I be correct in stating then that the input.gyroUserAcceleration is used to calculate the speed in which the device is rotated? Whilst the input.Gyro is used to calculate the current rotation of the device? Is there nothing else within the device that can be used to calculate the linear movement?

Also, the question that was specific to Unity was about what data exactly the gyro.UserAcceleration brought back. Apart from this, is there any other call to a mobile device that might be able to bring back something more suitable? I know that a 9-axis I$$anonymous$$U designed to give people real world positioning uses 3-axis Gyroscope, 3-axis Accelerometer and 3-axis magnetometers. Is there no way to do this in mobile with Unity's calls?

avatar image Dave-Hampson ♦♦ RetzRetro · Aug 09, 2016 at 11:37 AM 0
Share

So if I understand what you are doing correctly, you are trying to calculate the position of the phone using only the gyro, no reference point from the camera? Be aware that the positional accuracy of this will be very low and the inaccuracies will increase over time. You may be able to get good rotational and velocity accuracy though.

The Google talk on sensor fusion is quite useful for this. You can get pretty good accuracy with respect to rotations and velocity by combining several sensors together. There's probably 3 readings that are useful (using Android as an example, but iOS will be similar):

ASENSOR_TYPE_GYROSCOPE ===> https://docs.unity3d.com/ScriptReference/Gyroscope-rotationRate.html ASENSOR_TYPE_ACCELERO$$anonymous$$ETER ==> https://docs.unity3d.com/ScriptReference/Gyroscope-userAcceleration.html ASENSOR_TYPE_$$anonymous$$AGNETIC_FIELD ==> https://docs.unity3d.com/ScriptReference/Compass-magneticHeading.html

Since we do expose all of that information, so you may be able to use sensor fusion techniques to improve the accuracy. This project looks quite interesting (not Unity specific, but maybe the code will be helpful): http://x-io.co.uk/open-source-ahrs-with-x-imu/

Here's another link which seems to have talk on this: https://groups.google.com/forum/#!topic/android-developers/GOm9yhTFZa$$anonymous$$

avatar image RetzRetro Dave-Hampson ♦♦ · Aug 09, 2016 at 02:55 PM 0
Share

Thank you Dave for the information. I will look into this and comment again if there are any further questions. Also, if this proves to be the information required then I shall vote your answer as correct :)

Thanks again for the help :)

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Dave-Hampson · Aug 08, 2016 at 05:03 PM

What you are describing, integrating motion using only the gyro, is very difficult. If you want something to search for try the term 'dead reckoning' which describes what you are trying to do.

The reason why this will be very inaccurate is because by converting force into velocity, and then velocity into position you are integrating twice, and any inaccuracies will be magnified.

It's a very complex topic but this is a good talk on it, Sensor Fusion / Google Tech Talks: https://www.youtube.com/watch?v=C7JQ7Rpwn2k

This is a related topic: https://en.wikipedia.org/wiki/Simultaneous_localization_and_mapping

And you might also want to check out http://www.vuforia.com/ , which is a popular augmented reality SDK.

Also, I don't think that anything in the question is specific to Unity, so you could try searching or asking on StackExchange.

Comment
Add comment · Share
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

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

6 People are following this question.

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

Related Questions

Moving object with tilting the device. 1 Answer

How to disable idle timer in Unity game? (mobile screen-saver) 4 Answers

How to calibrate my accelerometer data 2 Answers

Need GUIDANCE On Mobile Accelerometer Input Applied to Rigidbody 1 Answer

Rotate object with accelerometer? 0 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