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 odriewgib · Apr 13, 2016 at 11:51 AM · accelerometermobile devicesgyroscope

How can I get the movement when a mobile device moves parallel to the ground?

Hi everyone, I'm new to Unity. I want to get the speed of mobile devices moving parallel to the ground. After days of searching, I found it seemed that Unity could only get the "rotating" acceleration of a device, not "translation"?

So is there any way I can get the moving speed of a device? I hope it was my neglect to miss the script. If there's no such function, can I do it in Android and link the result back in Unity? Thanks.

Comment
Add comment · Show 5
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 meat5000 ♦ · Apr 13, 2016 at 11:26 AM 0
Share

How about using GPS? Note that Gyro and Accelerometer are different.

avatar image odriewgib meat5000 ♦ · Apr 13, 2016 at 12:57 PM 0
Share

Thanks for your reply! I don't think GPS would be a good choice to me as I image I would need more accurate data in a smaller area.

Oh, yes I always got confused by the difference of gyro and accelerometer... O$$anonymous$$ I check them once again, so it's like I need accelerometer to get the acceleration of the device, and also need the gyro to get the orientation of the device? But the gravity seems a big trouble to the accelerometer reading to me, as a beginner...

avatar image meat5000 ♦ odriewgib · Apr 15, 2016 at 08:30 AM 1
Share

I always found that the docs were a bit inaccurate with regard to Gyro and Accel. It seems that a lot of devices have a Gyro and call it an Accelerometer.

The Accel is supposed to measure changes of orientation but if you look at its data you see that it just gives constant orientation, not just changes. This is a Gyro, no? :D

To use the Accel as an actual accelerometer you may need to access its raw data.

Show more comments
Show more comments

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by mptp · Apr 15, 2016 at 02:27 PM

You're up against a fundamental limitation of the humble IMU (the primary motion sensor in a smartphone).

I won't go into detail, but basically you need an external reference frame when trying to extract positional data from acceleration data. This is the topic of a lot of research right now, and it's why VR headsets that track position like the Oculus Rift have external tracking cameras.

Unfortunately, what you're trying to do is impossible without using the camera on your phone to track visual features in the scene and use those as the external reference point, which is a hell of a task better suited to a lab full of computer vision experts.

Comment
Add comment · Show 5 · 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
avatar image odriewgib · Apr 15, 2016 at 02:44 PM 0
Share

Thank you! Thank you for killing this project (it's a good thing, it's mission impossible to me)!

I was holding the idea that "what people can do with VR headsets, we should be able to do it with a mobile roughly"... Now I know I was wrong and those bulky VR headsets does have them reasons. (I only play Google's Cardboard so I thought VR shouldn't be that complicated after all...) And I seriously realized how ignorant I was...

I should read more articles about VR later I think... Thank you again for letting me abort this impossible mission.

avatar image meat5000 ♦ · Apr 15, 2016 at 02:52 PM 0
Share

Impossible? No. Uncalibrated? Totally.

The answer? Set it up and calibrate it with real world data. This will be fine for some/most apps.

Its easy to take a step to the left, step forward etc.

avatar image odriewgib meat5000 ♦ · Apr 15, 2016 at 03:13 PM 0
Share

So I missed your last reply. But getting the parallel movement seems really hard to me as I'm working alone and lack of professional knowledge. I imagined to track the movement of a device when the user is walking and turning. As I did found the accelerator acts like a gyro, it's very hard for me to peel the needed small variation off from those big changes coursed by tilting the device.

Oh, forgot to say, I'm bad at maths too, so the three dimensional calculating would be even harder... I would be doing both hard analysis and calculation... As this project is not that... eh... necessary, I do think the best option for me is to kill/suspend this project for now and wait for better technologies...

Thank you for giving me hope, I'll keep my $$anonymous$$d on some algorithm in this field.

avatar image meat5000 ♦ odriewgib · Apr 15, 2016 at 03:24 PM 0
Share

it's very hard for me to peel the needed small variation off from those big changes coursed by tilting the device.

The linked method does this for you

http://docs.unity3d.com/ScriptReference/Input-accelerationEvents.html

It takes all the movements and whacks them in to an array, movement and time taken for that movement.

mptp is correct in his answer but this is dependent on the need for accuracy.

Show more comments
avatar image
0

Answer by DoubleLee · May 17, 2017 at 06:32 PM

Input.gyro.userAcceration takes into account gravity and returns in a unity coordinate format m/s*s acceleration. This gets you the acceleration in theory this would be what you need but it doesn't take into account that rotations also increase the acceleration values means it's not the linear motion but linear and rotational combined. If you can use the gyro to remove the rotations you maybe able to use this. Good luck that's where I'm stuck.

I'm also attempting a similar movement controls by devices acceleration and it's very difficult. Also these values are dirty not always 0 0 0 when the phone is just sitting on the table. And the accuracy is probably not going to be correct enough for accurate movement required for a FPS style game/app.

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

Getting X axis input from accelerometer when mobile device is held upright? 4 Answers

How to judge intensity of shaking in android phones 1 Answer

Changing origin of cooridinates to decieve gyroscope in ARCore 0 Answers

Using custom accelerometer, gyro & magnetometer to move objects 1 Answer

gyro.attitude lags on Samsung Galaxy S2 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